Commit 6b8f779b authored by generalredneck's avatar generalredneck

Issue #2775643 by generalredneck, nirbhasa: Unicode issue with views_natural_sort_remove_symbols

parent d460e969
......@@ -20,7 +20,7 @@ class RemoveBeginningWords extends TransformationBase {
array_walk($beginning_words, 'preg_quote');
return preg_replace(
'/^(' . implode('|', $beginning_words) . ')\s+/i',
'/^(' . implode('|', $beginning_words) . ')\s+/iu',
'',
$string
);
......
......@@ -18,7 +18,7 @@ class RemoveSymbols extends TransformationBase {
return $string;
}
return preg_replace(
'/[' . preg_quote($symbols) . ']/',
'/[' . preg_quote($symbols) . ']/u',
'',
$string
);
......
......@@ -21,8 +21,8 @@ class RemoveWords extends TransformationBase {
array_walk($words, 'preg_quote');
return preg_replace(
array(
'/\s(' . implode('|', $words) . ')\s+/i',
'/^(' . implode('|', $words) . ')\s+/i',
'/\s(' . implode('|', $words) . ')\s+/iu',
'/^(' . implode('|', $words) . ')\s+/iu',
),
array(
' ',
......
......@@ -120,6 +120,24 @@ class BasicTest extends ViewsKernelTestBase {
);
}
/**
* Test Unicode symbol removal in sorting.
*/
public function testNaturalSortUnicodeSymbols() {
$plugin = new \Drupal\views_natural_sort\Plugin\IndexRecordContentTransformation\RemoveSymbols([
'settings' => "#…\",'\\()[]«?!»¡¿",
], '', '');
$titles = array(
'Cuando… se abre, ¿dará algún tipo de señal?',
);
$expected = array(
'Cuando se abre dará algún tipo de señal',
);
foreach ($titles as $key => $title) {
$this->assertEqual($plugin->transform($title), $expected[$key]);
}
}
public function testNaturalSortNumbers() {
$node1 = Node::create([
'type' => 'views_natural_sort_test_content',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment