Skip to content

Commit

Permalink
adjust handling for greek characters. fixes #3188
Browse files Browse the repository at this point in the history
This fixes an error in the case conversion table and removes "normal"
greek letters from the list of special characters. Mathematical symbols
based on greek letters are still considered special chars.
  • Loading branch information
splitbrain committed Jul 1, 2020
1 parent 5a56359 commit a1c2692
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 30 deletions.
51 changes: 31 additions & 20 deletions _test/tests/inc/utf8_stripspecials.test.php
@@ -1,27 +1,38 @@
<?php
// use no mbstring help here
if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);

class utf8_stripspecials extends DokuWikiTest {
class utf8_stripspecials extends DokuWikiTest
{

/**
* @return array
* @see testGivens
*/
function provideGivens()
{
return [
['asciistring', '', '', 'asciistring'],
['asciistring', '', '\._\-:', 'asciistring'],
['ascii.string', '', '\._\-:', 'asciistring'],
['ascii.string', ' ', '\._\-:', 'ascii string'],
['2.1.14', ' ', '\._\-:', '2 1 14'],
['ascii.string', '', '\._\-:\*', 'asciistring'],
['ascii.string', ' ', '\._\-:\*', 'ascii string'],
['2.1.14', ' ', '\._\-:\*', '2 1 14'],
['string with nbsps', '_', '\*', 'string_with_nbsps'],
['αβγδεϝϛζηθικλμνξοπϟϙρστυφχψωϡ', '_', '', 'αβγδεϝϛζηθικλμνξοπϟϙρστυφχψωϡ'], // #3188
];
}

function test1(){
// we test multiple cases here - format: string, repl, additional, test
$tests = array();
$tests[] = array('asciistring','','','asciistring');
$tests[] = array('asciistring','','\._\-:','asciistring');
$tests[] = array('ascii.string','','\._\-:','asciistring');
$tests[] = array('ascii.string',' ','\._\-:','ascii string');
$tests[] = array('2.1.14',' ','\._\-:','2 1 14');
$tests[] = array('ascii.string','','\._\-:\*','asciistring');
$tests[] = array('ascii.string',' ','\._\-:\*','ascii string');
$tests[] = array('2.1.14',' ','\._\-:\*','2 1 14');
$tests[] = array('string with nbsps','_','\*','string_with_nbsps');

foreach($tests as $test){
$this->assertEquals(\dokuwiki\Utf8\Clean::stripspecials($test[0],$test[1],$test[2]),$test[3]);
}
/**
* @param string $string
* @param string $replacement
* @param string $additional
* @param string $expected
* @dataProvider provideGivens
*/
function testGivens($string, $replacement, $additional, $expected)
{
$this->assertEquals($expected, \dokuwiki\Utf8\Clean::stripspecials($string, $replacement, $additional));
}

}
//Setup VIM: ex: et ts=4 :
4 changes: 4 additions & 0 deletions _test/tests/inc/utf8_strtolower.test.php
Expand Up @@ -14,6 +14,10 @@ public function provideGivens()
['ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'],
['players:Bruce', 'players:bruce'],
['players:GERALD', 'players:gerald'],
[
'Α Β Γ Δ Ε Ϝ Ϛ Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ϟ ϙ Ρ Σ Τ Υ Φ Χ Ψ Ω Ϡ',
'α β γ δ ε ϝ ϛ ζ η θ ι κ λ μ ν ξ ο π ϟ ϙ ρ σ τ υ φ χ ψ ω ϡ'
], // #3188
];
}

Expand Down
2 changes: 1 addition & 1 deletion inc/Utf8/tables/case.php
Expand Up @@ -239,7 +239,7 @@
'Ο' => 'ο',
'Π' => 'π',
'Ρ' => 'ρ',
'Σ' => 'ς',
'Σ' => 'σ',
'Τ' => 'τ',
'Υ' => 'υ',
'Φ' => 'φ',
Expand Down
13 changes: 4 additions & 9 deletions inc/Utf8/tables/specials.php
Expand Up @@ -130,11 +130,6 @@
0x384, // ΄
0x385, // ΅
0x387, // ·
0x3c6, // φ
0x3d1, // ϑ
0x3d2, // ϒ
0x3d5, // ϕ
0x3d6, // ϖ
0x5b0, // ְ
0x5b1, // ֱ
0x5b2, // ֲ
Expand Down Expand Up @@ -613,8 +608,8 @@
0x1d71a, // 𝜚
0x1d71b, // 𝜛
0xc2a0, // 슠
0xe28087, //
0xe280af, //
0xe281a0, //
0xefbbbf, //
0xe28087, //
0xe280af, //
0xe281a0, //
0xefbbbf, //
];

0 comments on commit a1c2692

Please sign in to comment.