@@ -81,8 +81,9 @@ public function createHttpRequest()
81
81
}
82
82
83
83
// path & query
84
+ $ reChars = '#^[ ' . self ::CHARS . ']*+\z#u ' ;
84
85
$ 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 ())) {
86
87
// TODO: invalid request
87
88
}
88
89
$ requestUrl = Strings::replace ($ requestUrl , $ this ->urlFilters ['url ' ]);
@@ -108,24 +109,13 @@ public function createHttpRequest()
108
109
$ cookies = $ useFilter ? filter_input_array (INPUT_COOKIE , FILTER_UNSAFE_RAW ) : (empty ($ _COOKIE ) ? [] : $ _COOKIE );
109
110
110
111
// remove invalid characters
111
- $ reChars = '#^[ ' . self ::CHARS . ']*+\z#u ' ;
112
112
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 = [];
127
118
}
128
- unset($ list , $ key , $ val , $ k , $ v );
129
119
}
130
120
131
121
0 commit comments