@@ -79,8 +79,9 @@ public function createHttpRequest()
7979 }
8080
8181 // path & query
82+ $ reChars = '#^[ ' . self ::CHARS . ']*+\z#u ' ;
8283 $ requestUrl = isset ($ _SERVER ['REQUEST_URI ' ]) ? $ _SERVER ['REQUEST_URI ' ] : '/ ' ;
83- if (!$ this ->binary && (!preg_match (self :: CHARS , rawurldecode ($ requestUrl )) || preg_last_error ())) {
84+ if (!$ this ->binary && (!preg_match ($ reChars , rawurldecode ($ requestUrl )) || preg_last_error ())) {
8485 // TODO: invalid request
8586 }
8687 $ requestUrl = Strings::replace ($ requestUrl , $ this ->urlFilters ['url ' ]);
@@ -106,24 +107,13 @@ public function createHttpRequest()
106107 $ cookies = $ useFilter ? filter_input_array (INPUT_COOKIE , FILTER_UNSAFE_RAW ) : (empty ($ _COOKIE ) ? [] : $ _COOKIE );
107108
108109 // remove invalid characters
109- $ reChars = '#^[ ' . self ::CHARS . ']*+\z#u ' ;
110110 if (!$ this ->binary ) {
111- $ list = array (& $ post , & $ cookies );
112- while (list ($ key , $ val ) = each ($ list )) {
113- foreach ($ val as $ k => $ v ) {
114- if (is_string ($ k ) && (!preg_match ($ reChars , $ k ) || preg_last_error ())) {
115- unset($ list [$ key ][$ k ]);
116-
117- } elseif (is_array ($ v )) {
118- $ list [$ key ][$ k ] = $ v ;
119- $ list [] = & $ list [$ key ][$ k ];
120-
121- } else {
122- $ list [$ key ][$ k ] = (string ) preg_replace ('#[^ ' . self ::CHARS . ']+#u ' , '' , $ v );
123- }
124- }
111+ if (!preg_match ($ reChars , rawurldecode (http_build_query ($ post ))) || preg_last_error ()) {
112+ $ post = [];
113+ }
114+ if (!preg_match ($ reChars , rawurldecode (http_build_query ($ cookies ))) || preg_last_error ()) {
115+ $ cookies = [];
125116 }
126- unset($ list , $ key , $ val , $ k , $ v );
127117 }
128118
129119
0 commit comments