Skip to content

Commit

Permalink
Directly encode bytes for U+FFFD
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Jul 12, 2024
1 parent 9d079be commit f2607c8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/standard/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,11 +1171,11 @@ PHPAPI zend_string *php_decode_html5_numeric_character_reference(zend_long conte
}

if (digit_count == 0) {
return zend_string_init("\uFFFD", 2, 0);
return zend_string_init("\xEF\xBF\xBD", 2, 0);
}

if (digit_count > (base == 16 ? 6 : 7)) {
return zend_string_init("\uFFFD", 2, 0);
return zend_string_init("\xEF\xBF\xBD", 2, 0);
}

uint32_t code_point = 0;
Expand All @@ -1197,7 +1197,7 @@ PHPAPI zend_string *php_decode_html5_numeric_character_reference(zend_long conte
}

if (code_point >= 0xD800 && code_point <= 0xDFFF) {
return zend_string_init("\uFFFD", 2, 0);
return zend_string_init("\xEF\xBF\xBD", 2, 0);
}

return html5_code_point_to_utf8_bytes(code_point);
Expand Down

0 comments on commit f2607c8

Please sign in to comment.