diff --git a/src/model/Request.php b/src/model/Request.php index 137032511..bc1c316b5 100644 --- a/src/model/Request.php +++ b/src/model/Request.php @@ -130,7 +130,7 @@ 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) diff --git a/tests/GlobalConfigTest.php b/tests/GlobalConfigTest.php index 364cbdd00..55e30d7e5 100644 --- a/tests/GlobalConfigTest.php +++ b/tests/GlobalConfigTest.php @@ -61,7 +61,7 @@ public function testGetBaseHref() public function testGetLanguages() { - $this->assertEquals(array('en' => 'en_GB.utf8', 'fi' => 'fi_FI.utf8', 'fr' => 'fr_FR.utf8'), $this->config->getLanguages()); + $this->assertEquals(array('en' => 'en_GB.utf8', 'fi' => 'fi_FI.utf8', 'fr' => 'fr_FR.utf8', 'sv' => 'sv_SE.utf8'), $this->config->getLanguages()); } public function testGetSearchResultsSize() diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 9eb502fa0..043fd43dc 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -256,4 +256,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); + } + } diff --git a/tests/WebControllerTest.php b/tests/WebControllerTest.php index 5b90b8c80..0d3319071 100644 --- a/tests/WebControllerTest.php +++ b/tests/WebControllerTest.php @@ -257,7 +257,7 @@ public function testGuessLanguageAcceptLanguageSimple() { public function testGuessLanguageAcceptLanguageBestMatch() { $request = new Request($this->model); - $request->setServerConstant('HTTP_ACCEPT_LANGUAGE', 'sv, de;q=0.9, fi;q=0.8, fr;q=0.5'); + $request->setServerConstant('HTTP_ACCEPT_LANGUAGE', 'da, de;q=0.9, fi;q=0.8, fr;q=0.5'); $guessedLanguage = $this->webController->guessLanguage($request); // configured/available languages are en, fi, fr // the best matching language for the given Accept-Language is fi diff --git a/tests/cypress/template/vocab-home.cy.js b/tests/cypress/template/vocab-home.cy.js index 8cdb756aa..1c43cca2d 100644 --- a/tests/cypress/template/vocab-home.cy.js +++ b/tests/cypress/template/vocab-home.cy.js @@ -39,4 +39,15 @@ describe('Vocabulary home page', () => { // check that the first entry is Carp cy.get('#tab-alphabetical .sidebar-list').children().first().invoke('text').should('equal', 'Carp') }) -}) + it('alphabetical index diacritic letters are clickable', () => { + cy.visit('/yso/sv/') // go to the YSO home page in Swedish language + + // click on the last letter (Ö) + cy.get('#tab-alphabetical .pagination :nth-last-child(1) > .page-link').click() + + // check that we have the correct number of entries + cy.get('#tab-alphabetical .sidebar-list').children().should('have.length', 4) + + // check that the first entry is "östliga handelsvägar" + cy.get('#tab-alphabetical .sidebar-list').children().first().children().first().invoke('text').should('equal', 'östliga handelsvägar') + })}) diff --git a/tests/testconfig.ttl b/tests/testconfig.ttl index 442b75a4e..730840f12 100644 --- a/tests/testconfig.ttl +++ b/tests/testconfig.ttl @@ -38,6 +38,7 @@ # interface languages available, and the corresponding system locales skosmos:languages ( [ rdfs:label "en" ; rdf:value "en_GB.utf8" ] [ rdfs:label "fi" ; rdf:value "fi_FI.utf8" ] + [ rdfs:label "sv" ; rdf:value "sv_SE.utf8" ] [ rdfs:label "fr" ; rdf:value "fr_FR.utf8" ] ) ; # how many results (maximum) to load at a time on the search results page skosmos:searchResultsSize 5 ;