Skip to content

Commit

Permalink
only disallow colons in strings returned by getLangUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Apr 26, 2022
1 parent 2932952 commit fe9e356
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public function getLangUrl($newlang=null)
if ($newlang !== null) {
$langurl = preg_replace("#^(.*/)?{$this->lang}/#", "$1{$newlang}/", $langurl);
}
// make sure that the resulting URL doesn't contain suspicious characters
$langurl = preg_replace("#[^a-zA-Z0-9/-]#", "", $langurl);
// make sure that the resulting URL isn't interpreted as an absolute URL
$langurl = str_replace(":", "", $langurl);
return $langurl;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function testGetLangUrlSanitizeSpecialChars() {
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/http://example.com');
$this->request->setLang('en');
$langurl = $this->request->getLangUrl();
$this->assertEquals("http//examplecom", $langurl);
$this->assertEquals("http//example.com", $langurl);
}

}

0 comments on commit fe9e356

Please sign in to comment.