mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Made TextHelper::highlight utf8 compatible, fixes #4602
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6952 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
fa410d207c
commit
3204ced2ed
2 changed files with 8 additions and 2 deletions
|
@ -74,7 +74,7 @@ class TextHelper extends AppHelper {
|
|||
if ($considerHtml) {
|
||||
$key = '(?![^<]+>)' . $key . '(?![^<]+>)';
|
||||
}
|
||||
$replace[] = '|' . $key . '|i';
|
||||
$replace[] = '|' . $key . '|iu';
|
||||
$with[] = empty($value) ? $highlighter : $value;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class TextHelper extends AppHelper {
|
|||
$phrase = '(?![^<]+>)' . $phrase . '(?![^<]+>)';
|
||||
}
|
||||
|
||||
return preg_replace('|'.$phrase.'|i', $highlighter, $text);
|
||||
return preg_replace('|'.$phrase.'|iu', $highlighter, $text);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -91,6 +91,12 @@ class TextTest extends UnitTestCase {
|
|||
$phrases = null;
|
||||
$result = $this->Text->highlight($text, $phrases, '<b>\1</b>');
|
||||
$this->assertEqual($result, $text);
|
||||
|
||||
$text = 'Ich saß in einem Café am Übergang';
|
||||
$expected = 'Ich <b>saß</b> in einem <b>Café</b> am <b>Übergang</b>';
|
||||
$phrases = array('saß', 'café', 'übergang');
|
||||
$result = $this->Text->highlight($text, $phrases, '<b>\1</b>');
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testHighlightConsiderHtml() {
|
||||
|
|
Loading…
Reference in a new issue