Skip to content

Commit fe9e356

Browse files
committed
only disallow colons in strings returned by getLangUrl
1 parent 2932952 commit fe9e356

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

model/Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ public function getLangUrl($newlang=null)
184184
if ($newlang !== null) {
185185
$langurl = preg_replace("#^(.*/)?{$this->lang}/#", "$1{$newlang}/", $langurl);
186186
}
187-
// make sure that the resulting URL doesn't contain suspicious characters
188-
$langurl = preg_replace("#[^a-zA-Z0-9/-]#", "", $langurl);
187+
// make sure that the resulting URL isn't interpreted as an absolute URL
188+
$langurl = str_replace(":", "", $langurl);
189189
return $langurl;
190190
}
191191

tests/RequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function testGetLangUrlSanitizeSpecialChars() {
237237
$this->request->setServerConstant('REQUEST_URI', '/Skosmos/http://example.com');
238238
$this->request->setLang('en');
239239
$langurl = $this->request->getLangUrl();
240-
$this->assertEquals("http//examplecom", $langurl);
240+
$this->assertEquals("http//example.com", $langurl);
241241
}
242242

243243
}

0 commit comments

Comments
 (0)