summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it.class4
-rwxr-xr-xtest/it.t4
2 files changed, 4 insertions, 4 deletions
diff --git a/it.class b/it.class
index 6ed5425..067b241 100644
--- a/it.class
+++ b/it.class
@@ -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)));
}
diff --git a/test/it.t b/test/it.t
index dc60727..d4225f4 100755
--- a/test/it.t
+++ b/test/it.t
@@ -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);