Skip to content
Snippets Groups Projects
Commit 4fd5a8c2 authored by Jared Hancock's avatar Jared Hancock
Browse files

search: Stop mangling text submitted to searching

parent 749d46fb
Branches
Tags
No related merge requests found
......@@ -724,36 +724,6 @@ class Format {
// Normalize text input :: remove diacritics and such
$text = normalizer_normalize($text, Normalizer::FORM_C);
}
else {
// As a lightweight compatiblity, use a lightweight C
// normalizer with diacritic removal, thanks
// http://ahinea.com/en/tech/accented-translate.html
$tr = array(
"ä" => "a", "ñ" => "n", "ö" => "o", "ü" => "u", "ÿ" => "y"
);
$text = strtr($text, $tr);
}
// Decompose compatible versions of characters (ä => ae)
$tr = array(
"ß" => "ss", "Æ" => "AE", "æ" => "ae", "IJ" => "IJ",
"ij" => "ij", "Œ" => "OE", "œ" => "oe", "Ð" => "D",
"Đ" => "D", "ð" => "d", "đ" => "d", "Ħ" => "H", "ħ" => "h",
"ı" => "i", "ĸ" => "k", "Ŀ" => "L", "Ł" => "L", "ŀ" => "l",
"ł" => "l", "Ŋ" => "N", "ʼn" => "n", "ŋ" => "n", "Ø" => "O",
"ø" => "o", "ſ" => "s", "Þ" => "T", "Ŧ" => "T", "þ" => "t",
"ŧ" => "t", "ä" => "ae", "ö" => "oe", "ü" => "ue",
"Ä" => "AE", "Ö" => "OE", "Ü" => "UE",
);
$text = strtr($text, $tr);
// Drop separated diacritics
$text = preg_replace('/\p{M}/u', '', $text);
// Drop extraneous whitespace
$text = preg_replace('/(\s)\s+/u', '$1', $text);
// Drop leading and trailing whitespace
$text = trim($text);
if (false && class_exists('IntlBreakIterator')) {
// Split by word boundaries
......@@ -772,6 +742,12 @@ class Format {
// http://www.unicode.org/reports/tr29/#Word_Boundaries
// Punt for now
// Drop extraneous whitespace
$text = preg_replace('/(\s)\s+/u', '$1', $text);
// Drop leading and trailing whitespace
$text = trim($text);
}
return $text;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment