Skip to content

Commit a2644ca

Browse files
committed
RequestFactory: drops complete cookie/post when contain invalid chars (+ is faster)
1 parent 1c598fe commit a2644ca

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
@@ -110,22 +110,12 @@ public function createHttpRequest()
110110
// remove invalid characters
111111
$reChars = '#^[' . self::CHARS . ']*+\z#u';
112112
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(self::CHARS, rawurldecode(http_build_query($post))) || preg_last_error()) {
114+
$post = [];
115+
}
116+
if (!preg_match(self::CHARS, rawurldecode(http_build_query($cookies))) || preg_last_error()) {
117+
$cookies = [];
127118
}
128-
unset($list, $key, $val, $k, $v);
129119
}
130120

131121

0 commit comments

Comments
 (0)