fix: decode uppercase-X hex numeric character references (#18708)

uppercase X is also valid per the HTML spec
pull/18710/head
Jawad Ali 4 days ago committed by GitHub
parent 2b740e496e
commit 1b02aa28c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: decode uppercase-`X` hex numeric character references (`&#X...;`)

@ -20,7 +20,7 @@ function reg_exp_entity(entity_name, is_attribute_value) {
/** @param {boolean} is_attribute_value */
function get_entity_pattern(is_attribute_value) {
const reg_exp_num = '#(?:x[a-fA-F\\d]+|\\d+)(?:;)?';
const reg_exp_num = '#(?:[xX][a-fA-F\\d]+|\\d+)(?:;)?';
const reg_exp_entities = Object.keys(entities).map(
/** @param {any} entity_name */ (entity_name) => reg_exp_entity(entity_name, is_attribute_value)
);
@ -50,7 +50,7 @@ export function decode_character_references(html, is_attribute_value) {
// Handle named entities
if (entity[0] !== '#') {
code = entities[entity];
} else if (entity[1] === 'x') {
} else if (entity[1] === 'x' || entity[1] === 'X') {
code = parseInt(entity.substring(2), 16);
} else {
code = parseInt(entity.substring(1), 10);

@ -7,6 +7,7 @@ export default test({
<span>*</span>
<span>*</span>
<span>*</span>
<span>*</span>
<span></span>
<span>A</span>

@ -2,6 +2,7 @@
<span>&midast;</span>
<span>&#x0002A;</span>
<span>&#x0002A</span>
<span>&#X0002A;</span>
<span>&#42;</span>
<span>&#10;</span>

Loading…
Cancel
Save