Skip to content

Commit

Permalink
Address an XSS vulnerability getgrav#15
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Oct 6, 2015
1 parent 93af0e7 commit 12101f6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions system/src/Grav/Common/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function init()

// process query string
if (isset($bits['query'])) {
parse_str($bits['query'], $this->query);
$this->query = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
$uri = $bits['path'];
}

Expand Down Expand Up @@ -169,7 +169,8 @@ private function processParams($uri, $delimiter = ':')
if (strpos($bit, $delimiter) !== false) {
$param = explode($delimiter, $bit);
if (count($param) == 2) {
$this->params[$param[0]] = str_replace(urlencode($delimiter), '/', filter_var($param[1], FILTER_SANITIZE_STRING));
$plain_var = strip_tags(filter_var(urldecode($param[1]), FILTER_SANITIZE_STRING));
$this->params[$param[0]] = $plain_var;
}
} else {
$path[] = $bit;
Expand Down Expand Up @@ -216,7 +217,7 @@ public function route($absolute = false, $domain = false)
public function query($id = null, $raw = false)
{
if (isset($id)) {
return isset($this->query[$id]) ? filter_var($this->query[$id], FILTER_SANITIZE_STRING) : null;
return isset($this->query[$id]) ? $this->query[$id] : null;
} else {
if ($raw) {
return $this->query;
Expand Down

0 comments on commit 12101f6

Please sign in to comment.