Skip to content

Commit

Permalink
RequestFactory: drops complete cookie/post when contain invalid chars…
Browse files Browse the repository at this point in the history
… (+ is faster)
  • Loading branch information
dg committed Dec 27, 2014
1 parent 93c3f35 commit 49e4e26
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,12 @@ public function createHttpRequest()

// remove invalid characters
if (!$this->binary) {
$list = array(& $post, & $cookies);
while (list($key, $val) = each($list)) {
foreach ($val as $k => $v) {
if (is_string($k) && (!preg_match(self::CHARS, $k) || preg_last_error())) {
unset($list[$key][$k]);

} elseif (is_array($v)) {
$list[$key][$k] = $v;
$list[] = & $list[$key][$k];

} elseif (!preg_match(self::CHARS, $v) || preg_last_error()) {
$list[$key][$k] = '';
}
}
if (!preg_match(self::CHARS, rawurldecode(http_build_query($post))) || preg_last_error()) {
$post = array();
}
if (!preg_match(self::CHARS, rawurldecode(http_build_query($cookies))) || preg_last_error()) {
$cookies = array();
}
unset($list, $key, $val, $k, $v);
}


Expand Down

0 comments on commit 49e4e26

Please sign in to comment.