aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/HtmlParser.c14
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;
+ }
}
}