Skip to content

Commit

Permalink
Merge pull request #1575 from NatLibFi/issue1574-alphabetical-index-d…
Browse files Browse the repository at this point in the history
…iacritic-fix

don't perform HTML escaping for server constants to avoid breaking alphabetical index for diacritics
  • Loading branch information
osma authored Jan 8, 2024
2 parents a1cd362 + 9d8511f commit 0801abd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function getQueryParamBoolean($paramName, $default)
public function getServerConstant($paramName)
{
if (!isset($this->serverConstants[$paramName])) return null;
return filter_var($this->serverConstants[$paramName], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
return filter_var($this->serverConstants[$paramName], FILTER_SANITIZE_ADD_SLASHES);
}

public function getCookie($paramName)
Expand Down
27 changes: 27 additions & 0 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,31 @@ public function testGetLangUrlSanitizeSpecialChars() {
$this->assertEquals("http//example.com", $langurl);
}

/**
* @covers Request::getServerConstant
*/
public function testGetServerConstant() {
$this->request->setServerConstant('PATH_INFO', '/myvocab/index/X');
$path_info = $this->request->getServerConstant('PATH_INFO');
$this->assertEquals('/myvocab/index/X', $path_info);
}

/**
* @covers Request::getServerConstant
*/
public function testGetServerConstantDiacriticNotEncoded() {
$this->request->setServerConstant('PATH_INFO', '/myvocab/index/Ä');
$path_info = $this->request->getServerConstant('PATH_INFO');
$this->assertEquals('/myvocab/index/Ä', $path_info);
}

/**
* @covers Request::getServerConstant
*/
public function testGetServerConstantQuoteIsEncoded() {
$this->request->setServerConstant('PATH_INFO', "/myvocab/index/'");
$path_info = $this->request->getServerConstant('PATH_INFO');
$this->assertEquals("/myvocab/index/\'", $path_info);
}

}

0 comments on commit 0801abd

Please sign in to comment.