Fix script tag comment parsing

This commit is contained in:
Wilson Lin 2018-08-08 13:37:29 +12:00
parent 48820d8377
commit f0e5b5e66e
2 changed files with 9 additions and 2 deletions

View File

@ -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 </script>
// NOTE: Closing tag must not contain whitespace
while (!hbu_pipe_accept_if_matches_line_terminator(pipe) &&
!hbu_pipe_matches_i(pipe, "</script>")) {
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 </script>
// NOTE: Closing tag must not contain whitespace
while (!hbu_pipe_accept_if_matches(pipe, "*/") &&
!hbu_pipe_matches_i(pipe, "</script>")) {
hbu_pipe_accept(pipe);
}
}

View File

@ -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);
}