Skip to content

Commit 93c3f35

Browse files
committed
RequestFactory: rejects invalid URL [Closes #30]
1 parent 96b498c commit 93c3f35

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Http/RequestFactory.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public function createHttpRequest()
8282

8383
// path & query
8484
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
85+
if (!$this->binary && (!preg_match(self::CHARS, rawurldecode($requestUrl)) || preg_last_error())) {
86+
// TODO: invalid request
87+
}
8588
$requestUrl = Strings::replace($requestUrl, $this->urlFilters['url']);
8689
$tmp = explode('?', $requestUrl, 2);
8790
$path = Strings::fixEncoding(Strings::replace($tmp[0], $this->urlFilters['path']));
@@ -97,10 +100,8 @@ public function createHttpRequest()
97100
}
98101
$url->setScriptPath($path);
99102

100-
// GET, POST, COOKIE
103+
// POST, COOKIE
101104
$useFilter = (!in_array(ini_get('filter.default'), array('', 'unsafe_raw')) || ini_get('filter.default_flags'));
102-
103-
$query = $url->getQueryParameters();
104105
$post = $useFilter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? array() : $_POST);
105106
$cookies = $useFilter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? array() : $_COOKIE);
106107

@@ -111,7 +112,7 @@ public function createHttpRequest()
111112

112113
// remove invalid characters
113114
if (!$this->binary) {
114-
$list = array(& $query, & $post, & $cookies);
115+
$list = array(& $post, & $cookies);
115116
while (list($key, $val) = each($list)) {
116117
foreach ($val as $k => $v) {
117118
if (is_string($k) && (!preg_match(self::CHARS, $k) || preg_last_error())) {
@@ -128,7 +129,6 @@ public function createHttpRequest()
128129
}
129130
unset($list, $key, $val, $k, $v);
130131
}
131-
$url->setQuery($query);
132132

133133

134134
// FILES and create FileUpload objects

0 commit comments

Comments
 (0)