Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't perform HTML escaping for server constants to avoid breaking alphabetical index for diacritics #1575

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}
Loading