summaryrefslogtreecommitdiff
path: root/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-04-12 12:38:51 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-04-12 12:38:51 +0200
commit5b0c98a43a4608eab2e245807b9a18ff3f5168cf (patch)
tree05039aad8c0d7c7e0bbd79d8c0e4331e91805626 /quickjs.c
parent67b48ae4e6fadb812334b5836aa4a6e6e46d459b (diff)
downloadquickjs-5b0c98a43a4608eab2e245807b9a18ff3f5168cf.tar.gz
quickjs-5b0c98a43a4608eab2e245807b9a18ff3f5168cf.zip
fixed HTML comments (chqrlie)
Diffstat (limited to 'quickjs.c')
-rw-r--r--quickjs.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/quickjs.c b/quickjs.c
index 8fb5f65..7323053 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -20013,6 +20013,7 @@ typedef struct JSParseState {
JSToken token;
BOOL got_lf; /* true if got line feed before the current token */
const uint8_t *last_ptr;
+ const uint8_t *buf_start;
const uint8_t *buf_ptr;
const uint8_t *buf_end;
@@ -20883,8 +20884,8 @@ static __exception int next_token(JSParseState *s)
p += 2;
s->token.val = TOK_MINUS_ASSIGN;
} else if (p[1] == '-') {
- if (s->allow_html_comments &&
- p[2] == '>' && s->last_line_num != s->line_num) {
+ if (s->allow_html_comments && p[2] == '>' &&
+ (s->got_lf || s->last_ptr == s->buf_start)) {
/* Annex B: `-->` at beginning of line is an html comment end.
It extends to the end of the line.
*/
@@ -34235,7 +34236,7 @@ static void js_parse_init(JSContext *ctx, JSParseState *s,
s->ctx = ctx;
s->filename = filename;
s->line_num = 1;
- s->buf_ptr = (const uint8_t *)input;
+ s->buf_start = s->buf_ptr = (const uint8_t *)input;
s->buf_end = s->buf_ptr + input_len;
s->token.val = ' ';
s->token.line_num = 1;