Skip to content

Commit 256da57

Browse files
Remove invisible Unicode characters that can cause
// Remove invisible Unicode characters that can cause comparison issues // U+200B = ZERO WIDTH SPACE // U+200C = ZERO WIDTH NON-JOINER // U+200D = ZERO WIDTH JOINER // U+FEFF = ZERO WIDTH NO-BREAK SPACE (BOM)
1 parent acd49cc commit 256da57

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

main/exercise/fill_blanks.class.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,17 @@ public static function clearStudentAnswer($answer): string
14491449
private static function trimOption($text)
14501450
{
14511451
$text = trim($text);
1452-
1452+
1453+
// Remove invisible Unicode characters that can cause comparison issues
1454+
// U+200B = ZERO WIDTH SPACE
1455+
// U+200C = ZERO WIDTH NON-JOINER
1456+
// U+200D = ZERO WIDTH JOINER
1457+
// U+FEFF = ZERO WIDTH NO-BREAK SPACE (BOM)
1458+
$text = str_replace("\u{200B}", '', $text);
1459+
$text = str_replace("\u{200C}", '', $text);
1460+
$text = str_replace("\u{200D}", '', $text);
1461+
$text = str_replace("\u{FEFF}", '', $text);
1462+
14531463
return preg_replace("/\s+/", ' ', $text);
14541464
}
14551465
}

0 commit comments

Comments
 (0)