Skip to content

Commit 49e4e26

Browse files
committed
RequestFactory: drops complete cookie/post when contain invalid chars (+ is faster)
1 parent 93c3f35 commit 49e4e26

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/Http/RequestFactory.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,12 @@ public function createHttpRequest()
112112

113113
// remove invalid characters
114114
if (!$this->binary) {
115-
$list = array(& $post, & $cookies);
116-
while (list($key, $val) = each($list)) {
117-
foreach ($val as $k => $v) {
118-
if (is_string($k) && (!preg_match(self::CHARS, $k) || preg_last_error())) {
119-
unset($list[$key][$k]);
120-
121-
} elseif (is_array($v)) {
122-
$list[$key][$k] = $v;
123-
$list[] = & $list[$key][$k];
124-
125-
} elseif (!preg_match(self::CHARS, $v) || preg_last_error()) {
126-
$list[$key][$k] = '';
127-
}
128-
}
115+
if (!preg_match(self::CHARS, rawurldecode(http_build_query($post))) || preg_last_error()) {
116+
$post = array();
117+
}
118+
if (!preg_match(self::CHARS, rawurldecode(http_build_query($cookies))) || preg_last_error()) {
119+
$cookies = array();
129120
}
130-
unset($list, $key, $val, $k, $v);
131121
}
132122

133123

0 commit comments

Comments
 (0)