rangerlee / htmlparser

a simple c++ html parser
Apache License 2.0
24 stars 14 forks source link

Text method fails to handle invalid start tags, resulting in incorrect output. #3

Open testmigrator opened 1 year ago

testmigrator commented 1 year ago

The text() method is not handling invalid start tags correctly, resulting in incorrect text output

TEST(test, handlesInvalidStartTags) {
    std::string html("<html><div>Hello < There <&amp;></div></html>");
    HtmlParser parser;
    shared_ptr<HtmlDocument> doc = parser.Parse(html);
    std::vector<shared_ptr<HtmlElement>> els = doc->SelectElement("//div");

    ASSERT_EQ(1, els.size());

    // ASSERT_EQ("Hello < There <&>", els[0]->text());
    ASSERT_EQ("Hello ", els[0]->text());
}