@@ -81,8 +81,9 @@ public function createHttpRequest()
8181 }
8282
8383 // path & query
84+ $ reChars = '#^[ ' . self ::CHARS . ']*+\z#u ' ;
8485 $ requestUrl = isset ($ _SERVER ['REQUEST_URI ' ]) ? $ _SERVER ['REQUEST_URI ' ] : '/ ' ;
85- if (!$ this ->binary && (!preg_match (self :: CHARS , rawurldecode ($ requestUrl )) || preg_last_error ())) {
86+ if (!$ this ->binary && (!preg_match ($ reChars , rawurldecode ($ requestUrl )) || preg_last_error ())) {
8687 // TODO: invalid request
8788 }
8889 $ requestUrl = Strings::replace ($ requestUrl , $ this ->urlFilters ['url ' ]);
@@ -108,24 +109,13 @@ public function createHttpRequest()
108109 $ cookies = $ useFilter ? filter_input_array (INPUT_COOKIE , FILTER_UNSAFE_RAW ) : (empty ($ _COOKIE ) ? [] : $ _COOKIE );
109110
110111 // remove invalid characters
111- $ reChars = '#^[ ' . self ::CHARS . ']*+\z#u ' ;
112112 if (!$ this ->binary ) {
113- $ list = array (& $ post , & $ cookies );
114- while (list ($ key , $ val ) = each ($ list )) {
115- foreach ($ val as $ k => $ v ) {
116- if (is_string ($ k ) && (!preg_match ($ reChars , $ k ) || preg_last_error ())) {
117- unset($ list [$ key ][$ k ]);
118-
119- } elseif (is_array ($ v )) {
120- $ list [$ key ][$ k ] = $ v ;
121- $ list [] = & $ list [$ key ][$ k ];
122-
123- } else {
124- $ list [$ key ][$ k ] = (string ) preg_replace ('#[^ ' . self ::CHARS . ']+#u ' , '' , $ v );
125- }
126- }
113+ if (!preg_match ($ reChars , rawurldecode (http_build_query ($ post ))) || preg_last_error ()) {
114+ $ post = [];
115+ }
116+ if (!preg_match ($ reChars , rawurldecode (http_build_query ($ cookies ))) || preg_last_error ()) {
117+ $ cookies = [];
127118 }
128- unset($ list , $ key , $ val , $ k , $ v );
129119 }
130120
131121
0 commit comments