From f0027dea3b23e639a8dae0e258a6bcdacf399231 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Tue, 1 Aug 2000 13:31:12 +0200 Subject: [PATCH] Fixed case where parsing badly formatted data caused a fatal error (see test case). Rev: src/modules/Parser/html.c:1.95 Rev: src/modules/Parser/testsuite.in:1.36 --- src/modules/Parser/html.c | 3 ++- src/modules/Parser/testsuite.in | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/Parser/html.c b/src/modules/Parser/html.c index 9bbc8619e0..eff15c2967 100644 --- a/src/modules/Parser/html.c +++ b/src/modules/Parser/html.c @@ -2750,7 +2750,8 @@ static newstate find_end_of_container(struct parser_html_storage *this, pop_stack(); } - if (c3 < s3->s->len && index_shared_string (s3->s,c3) == this->tag_start) { + if (tagname->u.string->len > sp[-1].u.string->len && + c3 < s3->s->len && index_shared_string (s3->s,c3) == this->tag_start) { struct pike_string *cmp = string_slice (tagname->u.string, 0, sp[-1].u.string->len); if (cmp == sp[-1].u.string) { diff --git a/src/modules/Parser/testsuite.in b/src/modules/Parser/testsuite.in index 33fdbfdceb..d8eb5c7656 100644 --- a/src/modules/Parser/testsuite.in +++ b/src/modules/Parser/testsuite.in @@ -580,6 +580,12 @@ test_any([[{ "12-" "13-" "14-")); +test_any([[{ + object p = Parser.HTML(); + p->match_tag (0); + p->add_container ("foo", ""); + return p->finish ("<foo></foobar</foo>")->read(); +}]], ""); // Redefinition during parsing test_any([[ -- GitLab