diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-07-02 18:34:30 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-07-02 18:34:30 +0200 |
commit | d17da715d2300cdcbc79088491cc15f0bb67d84a (patch) | |
tree | ba30000b269657809d23d12c6819d54f1c43a29e /src | |
parent | 2b1a4ac7ad5743400fa875a91ee6869fcd94a9ed (diff) |
Return error if too many unclosed tags
Diffstat (limited to 'src')
-rw-r--r-- | src/HtmlParser.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/HtmlParser.c b/src/HtmlParser.c index aadf2a8..efc9e27 100644 --- a/src/HtmlParser.c +++ b/src/HtmlParser.c @@ -148,14 +148,15 @@ static void html_parser_advance_char(HtmlParser *self) { ++self->offset; } -static void html_parser_try_append_unclosed_tag(HtmlParser *self, const char *data, size_t size) { +static int html_parser_try_append_unclosed_tag(HtmlParser *self, const char *data, size_t size) { if(self->unclosed_tags_offset == UNCLOSED_TAGS_SIZE) { fprintf(stderr, "Reached the maximum number of unclosed tags! the html source is too broken\n"); - return; + return 1; } self->unclosed_tags[self->unclosed_tags_offset].data = data; self->unclosed_tags[self->unclosed_tags_offset].size = size; ++self->unclosed_tags_offset; + return 0; } static void html_parser_pop_unclosed_tag(HtmlParser *self) { @@ -399,7 +400,9 @@ static int html_parser_parse_tag_start(HtmlParser *self) { if(self->is_tag_void) { self->tag_before_void_tag = prev_tag_name; } else { - html_parser_try_append_unclosed_tag(self, self->tag_name.data, self->tag_name.size); + res = html_parser_try_append_unclosed_tag(self, self->tag_name.data, self->tag_name.size); + if(res != 0) + return res; self->inside_script_tag = string_view_equals_case_insensitive(&self->tag_name, &script_tag); } res = self->parse_callback(self, HTML_PARSE_TAG_START, self->callback_userdata); |