Skip to content

Commit b45ad0c

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

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/Http/RequestFactory.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,13 @@ 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);
113+
if (!preg_match(self::CHARS, rawurldecode(http_build_query($post))) || preg_last_error()) {
114+
$post = array();
125115
}
116+
if (!preg_match(self::CHARS, rawurldecode(http_build_query($cookies))) || preg_last_error()) {
117+
$cookies = array();
126118
}
127119
}
128-
unset($list, $key, $val, $k, $v);
129-
}
130120

131121

132122
// FILES and create FileUpload objects

0 commit comments

Comments
 (0)