\x{N} is a syntax error

This commit is contained in:
Fabrice Bellard
2025-12-22 15:05:37 +01:00
parent 31ef02b907
commit 7bd1ae2c76

View File

@@ -757,9 +757,21 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16)
c = '\v'; c = '\v';
break; break;
case 'x': case 'x':
{
int h0, h1;
h0 = from_hex(*p++);
if (h0 < 0)
return -1;
h1 = from_hex(*p++);
if (h1 < 0)
return -1;
c = (h0 << 4) | h1;
}
break;
case 'u': case 'u':
{ {
int h, n, i; int h, i;
uint32_t c1; uint32_t c1;
if (*p == '{' && allow_utf16) { if (*p == '{' && allow_utf16) {
@@ -777,14 +789,8 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16)
} }
p++; p++;
} else { } else {
if (c == 'x') {
n = 2;
} else {
n = 4;
}
c = 0; c = 0;
for(i = 0; i < n; i++) { for(i = 0; i < 4; i++) {
h = from_hex(*p++); h = from_hex(*p++);
if (h < 0) { if (h < 0) {
return -1; return -1;