Skip to content

Commit 67e1ce8

Browse files
committed
Additional ASCII character validation on MacOS
Fixes #57
1 parent c644a5c commit 67e1ce8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Parser.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ private static function parseString(ParsingInput $input): string
270270
}
271271
} elseif ($char === '"') {
272272
return $output;
273-
} elseif (!ctype_print($char)) {
273+
} elseif (
274+
!ctype_print($char)
275+
|| (PHP_OS_FAMILY === 'Darwin' && mb_detect_encoding($char, ['ASCII'], true) === false)
276+
) {
274277
throw new ParseException('Invalid character in string at position ' . ($input->position() - 1));
275278
}
276279

@@ -296,7 +299,10 @@ private static function parseDisplayString(ParsingInput $string): DisplayString
296299
while (!$string->empty()) {
297300
$char = $string->consumeChar();
298301

299-
if (!ctype_print($char)) {
302+
if (
303+
!ctype_print($char)
304+
|| (PHP_OS_FAMILY === 'Darwin' && mb_detect_encoding($char, ['ASCII'], true) === false)
305+
) {
300306
throw new ParseException(
301307
'Invalid character in display string at position ' . ($string->position() - 1)
302308
);

0 commit comments

Comments
 (0)