Commit bdd421d5 authored by generalredneck's avatar generalredneck

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

parent 20580b61
......@@ -22,7 +22,7 @@ function views_natural_sort_remove_beginning_words($string) {
array_walk($beginning_words, 'preg_quote');
return preg_replace(
'/^(' . implode('|', $beginning_words) . ')\s+/i',
'/^(' . implode('|', $beginning_words) . ')\s+/iu',
'',
$string
);
......@@ -46,8 +46,8 @@ function views_natural_sort_remove_words($string) {
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(
' ',
......@@ -72,7 +72,7 @@ function views_natural_sort_remove_symbols($string) {
return $string;
}
return preg_replace(
'/[' . preg_quote($symbols) . ']/',
'/[' . preg_quote($symbols) . ']/u',
'',
$string
);
......
......@@ -87,6 +87,22 @@ class ViewsNaturalSortBasicTest extends ViewsTestCase {
);
}
/**
* Test Unicode symbol removal in sorting.
*/
public function testNaturalSortUnicodeSymbols() {
$symbols = variable_set('views_natural_sort_symbols_remove', "#…\",'\\()[]«?!»¡¿");
$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(views_natural_sort_remove_symbols($title), $expected[$key]);
}
}
/**
* Test sorting strings that contain numbers in them.
*/
......
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