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

Fix diacritic letters in alphabetical index (Skosmos 3) #1580

Merged
merged 4 commits into from
Jan 24, 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 src/model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/GlobalConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
27 changes: 27 additions & 0 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
2 changes: 1 addition & 1 deletion tests/WebControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion tests/cypress/template/vocab-home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})})
1 change: 1 addition & 0 deletions tests/testconfig.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down