Ignore / characters inside HTML tags when they appear between single or double quotes

This commit is contained in:
2025-10-16 15:29:15 +02:00
parent 4cff48b9e1
commit 89cb5b6fb4
+11 -2
View File
@@ -761,12 +761,21 @@ static Node *parse_html(Parser *p)
bool no_body = false;
Scanner *s = &p->s;
for (;;) {
for (int quote = 0;;) {
int off = s->cur;
while (s->cur < s->len && s->src[s->cur] != '\\' && (s->src[s->cur] != '/' && s->src[s->cur] != '>'))
while (s->cur < s->len && s->src[s->cur] != '\\' && (quote || (s->src[s->cur] != '/' && s->src[s->cur] != '>'))) {
if (quote) {
if (quote == s->src[s->cur])
quote = 0;
} else {
char c = s->src[s->cur];
if (c == '"' || c == '\'')
quote = c;
}
s->cur++;
}
if (s->cur > off) {