diff options
| -rw-r--r-- | it.class | 4 | ||||
| -rwxr-xr-x | test/it.t | 4 |
2 files changed, 4 insertions, 4 deletions
@@ -609,8 +609,8 @@ static function any2utf8($value, $errprefix = "") list($value, $error) = array(preg_replace('/\xef\xb7[\x90-\xaf]|\xef\xbf[\xbe\xbf]/', " ", $value), "forbidden utf-8 character. input=$value"); $value = preg_replace('/\xc2\xad/', '', $value); # Kill invisible soft hyphens $value = normalizer_normalize($value, Normalizer::FORM_C); - if (preg_match('/^\pM/u', $value)) # Remove combining characters (e.g. U+0338 "Combining Long Solidus Overlay") at beginning of string - list($value, $error) = array(preg_replace('/^\pM+/u', "", $value), "combining character at beginning of string. input=$value"); + if (preg_match('/(^| )\pM/u', $value)) # Remove combining characters (e.g. U+0338 "Combining Long Solidus Overlay") at start of after blank + list($value, $error) = array(preg_replace('/(^| )\pM+/u', '$1', $value), "combining character at beginning of string. input=$value"); if ($error && $errprefix) it::error(array('title' => "$errprefix: " . trim($error))); } @@ -437,8 +437,6 @@ is(it::substr_replace('abc', 'xyz', 0, 2), substr_replace('abc', 'xyz', 0, 2), ' is(it::substr_replace('abc', 'xyz', 0, 10), substr_replace('abc', 'xyz', 0, 10), 'it::substr_replace replacing past end of haystack'); is(it::substr_replace('abcdefgh', 'xyz', 10, 4), substr_replace('abcdefgh', 'xyz', 10, 4), 'it::substr_replace outside of string'); -is(grapheme_strlen("\xc1"), null, "need grapheme_strlen side effect for any2utf8"); - is(it::any2utf8('Meier'), 'Meier', "it::any2utf8 ascii input"); is(it::any2utf8('Müller'), 'Müller', "it::any2utf8 utf8 input"); is(it::any2utf8('Aslı'), 'Aslı', "it::any2utf8 utf8 non-latin1 input"); @@ -481,6 +479,8 @@ foreach ([ 'a' => 'ä', 'e' => 'ë', 'i' => 'ï', 'o' => 'ö', 'u' => 'ü' ] as } is(it::any2utf8("\x65\xcc\x81"), "é", "it::any2utf8 convert to normal form C"); +is(it::any2utf8("\xcc\xb8x"), "x", "bad (un-nomalizable) combining char"); +is(it::any2utf8(" \xcc\xb8x"), " x", "bad (un-normalizable) combining char"); foreach ([$dummy, false, true, null, 1, "a", "Ä", "/", []] as $var) is(it::json_decode(it::json_encode($var)), $var); |