1919class RequestFactory extends Nette \Object
2020{
2121 /** @internal */
22- const CHARS = '#^[ \x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}]*+\z#u ' ;
22+ const CHARS = '\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF} ' ;
2323
2424 /** @var array */
2525 public $ urlFilters = array (
@@ -137,6 +137,7 @@ public function createHttpRequest()
137137 $ gpc = (bool ) get_magic_quotes_gpc ();
138138
139139 // remove fucking quotes, control characters and check encoding
140+ $ reChars = '#^[ ' . self ::CHARS . ']*+\z#u ' ;
140141 if ($ gpc || !$ this ->binary ) {
141142 $ list = array (& $ query , & $ post , & $ cookies );
142143 while (list ($ key , $ val ) = each ($ list )) {
@@ -147,7 +148,7 @@ public function createHttpRequest()
147148 $ k = stripslashes ($ k );
148149 }
149150
150- if (!$ this ->binary && is_string ($ k ) && (!preg_match (self :: CHARS , $ k ) || preg_last_error ())) {
151+ if (!$ this ->binary && is_string ($ k ) && (!preg_match ($ reChars , $ k ) || preg_last_error ())) {
151152 // invalid key -> ignore
152153
153154 } elseif (is_array ($ v )) {
@@ -158,8 +159,8 @@ public function createHttpRequest()
158159 if ($ gpc && !$ useFilter ) {
159160 $ v = stripSlashes ($ v );
160161 }
161- if (!$ this ->binary && (! preg_match ( self :: CHARS , $ v ) || preg_last_error ()) ) {
162- $ v = '' ;
162+ if (!$ this ->binary ) {
163+ $ v = ( string ) preg_replace ( ' #[^ ' . self :: CHARS . ' ]+#u ' , '' , $ v ) ;
163164 }
164165 $ list [$ key ][$ k ] = $ v ;
165166 }
@@ -174,7 +175,7 @@ public function createHttpRequest()
174175 $ list = array ();
175176 if (!empty ($ _FILES )) {
176177 foreach ($ _FILES as $ k => $ v ) {
177- if (!$ this ->binary && is_string ($ k ) && (!preg_match (self :: CHARS , $ k ) || preg_last_error ())) {
178+ if (!$ this ->binary && is_string ($ k ) && (!preg_match ($ reChars , $ k ) || preg_last_error ())) {
178179 continue ;
179180 }
180181 $ v ['@ ' ] = & $ files [$ k ];
@@ -190,7 +191,7 @@ public function createHttpRequest()
190191 if ($ gpc ) {
191192 $ v ['name ' ] = stripSlashes ($ v ['name ' ]);
192193 }
193- if (!$ this ->binary && (!preg_match (self :: CHARS , $ v ['name ' ]) || preg_last_error ())) {
194+ if (!$ this ->binary && (!preg_match ($ reChars , $ v ['name ' ]) || preg_last_error ())) {
194195 $ v ['name ' ] = '' ;
195196 }
196197 if ($ v ['error ' ] !== UPLOAD_ERR_NO_FILE ) {
@@ -200,7 +201,7 @@ public function createHttpRequest()
200201 }
201202
202203 foreach ($ v ['name ' ] as $ k => $ foo ) {
203- if (!$ this ->binary && is_string ($ k ) && (!preg_match (self :: CHARS , $ k ) || preg_last_error ())) {
204+ if (!$ this ->binary && is_string ($ k ) && (!preg_match ($ reChars , $ k ) || preg_last_error ())) {
204205 continue ;
205206 }
206207 $ list [] = array (
0 commit comments