From f0e5b5e66efe5e04f800a0ae055a32beebf61bf3 Mon Sep 17 00:00:00 2001 From: Wilson Lin Date: Wed, 8 Aug 2018 13:37:29 +1200 Subject: [PATCH] Fix script tag comment parsing --- src/main/c/stream/helper/script.c | 10 ++++++++-- src/main/c/stream/helper/style.c | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/c/stream/helper/script.c b/src/main/c/stream/helper/script.c index 999e6fb..75efac2 100644 --- a/src/main/c/stream/helper/script.c +++ b/src/main/c/stream/helper/script.c @@ -8,7 +8,10 @@ static void _hbsh_script_slcomment(hbu_pipe_t pipe) { hbu_pipe_require_match(pipe, "//"); - while (!hbu_pipe_accept_if_matches_line_terminator(pipe)) { + // Comment can end at closing + // NOTE: Closing tag must not contain whitespace + while (!hbu_pipe_accept_if_matches_line_terminator(pipe) && + !hbu_pipe_matches_i(pipe, "")) { hbu_pipe_accept(pipe); } } @@ -16,7 +19,10 @@ static void _hbsh_script_slcomment(hbu_pipe_t pipe) { static void _hbsh_script_mlcomment(hbu_pipe_t pipe) { hbu_pipe_require_match(pipe, "/*"); - while (!hbu_pipe_accept_if_matches(pipe, "*/")) { + // Comment can end at closing + // NOTE: Closing tag must not contain whitespace + while (!hbu_pipe_accept_if_matches(pipe, "*/") && + !hbu_pipe_matches_i(pipe, "")) { hbu_pipe_accept(pipe); } } diff --git a/src/main/c/stream/helper/style.c b/src/main/c/stream/helper/style.c index f88c28f..d3d7d0d 100644 --- a/src/main/c/stream/helper/style.c +++ b/src/main/c/stream/helper/style.c @@ -8,6 +8,7 @@ static void _hbsh_style_comment(hbu_pipe_t pipe) { hbu_pipe_require_match(pipe, "/*"); + // Unlike script tags, style comments do NOT end at closing tag while (!hbu_pipe_accept_if_matches(pipe, "*/")) { hbu_pipe_accept(pipe); }