Skip to content

Commit 5fc99ff

Browse files
committed
RequestFactory: drops complete cookie/post when contain invalid chars (+ is faster)
1 parent 47a2ae5 commit 5fc99ff

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
@@ -113,22 +113,12 @@ public function createHttpRequest()
113113

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

134124

0 commit comments

Comments
 (0)