diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-07-02 20:05:34 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-07-02 20:05:34 +0200 |
commit | 27e448cf28cfe4ba24ab838cb6eb96711bf103a6 (patch) | |
tree | c937c43a5cbdb5b2b124a9426cda163d123db055 /src | |
parent | d17da715d2300cdcbc79088491cc15f0bb67d84a (diff) |
Do not callback for text that is empty after stripping
Diffstat (limited to 'src')
-rw-r--r-- | src/HtmlParser.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/HtmlParser.c b/src/HtmlParser.c index efc9e27..287f322 100644 --- a/src/HtmlParser.c +++ b/src/HtmlParser.c @@ -299,7 +299,11 @@ static int html_parser_goto_script_end_tag(HtmlParser *self) { html_parser_advance_char(self); } } - return self->parse_callback(self, HTML_PARSE_JAVASCRIPT_CODE, self->callback_userdata); + + if(self->text_stripped.size > 0) + return self->parse_callback(self, HTML_PARSE_JAVASCRIPT_CODE, self->callback_userdata); + else + return 0; } static void html_parser_goto_comment_end(HtmlParser *self) { @@ -504,9 +508,11 @@ int html_parser_parse(const char *html_source, size_t len, HtmlParseCallback par } self.text.size = (self.source + self.offset) - self.text.data; strip(self.text.data, self.text.size, &self.text_stripped.data, &self.text_stripped.size, is_whitespace); - res = self.parse_callback(&self, HTML_PARSE_TEXT, self.callback_userdata); - if(res != 0) - return res; + if(self.text_stripped.size > 0) { + res = self.parse_callback(&self, HTML_PARSE_TEXT, self.callback_userdata); + if(res != 0) + return res; + } } } |