Commit b4e1e840 authored by Jan Köster's avatar Jan Köster
Browse files

test

parent c77ec057
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -1074,8 +1074,31 @@ size_t libhtmlpp::HtmlElement::parseElement(



    // Quote-aware scan for this tag's own '>' -- a '<'/'>' inside a quoted
    // attribute value (e.g. title="a < b") doesn't end the tag. Critically,
    // an UNQUOTED '<' encountered here means this tag itself was never
    // terminated (a missing '>', e.g. a malformed "</div" straight into the
    // next markup) -- stopping at that '<' instead of scanning past it
    // keeps that next tag intact for the caller to (re-)dispatch on its own
    // merits (e.g. a following <script> still gets ScriptElement's raw-text
    // handling) rather than silently swallowing it as bogus "attribute"
    // content of this broken tag, whose own closing '>' would otherwise
    // wrongly end up terminating THIS one instead.
    size_t close = i;
    while (close < in.size() && in[close] != HTMLTAG_CLOSE) { // '>'
    bool foundClose = false;
    char quote = 0;
    while (close < in.size()) {
        char c = in[close];
        if (quote) {
            if (c == quote) quote = 0;
        } else if (c == HTMLTAG_CLOSE) { // '>'
            foundClose = true;
            break;
        } else if (c == HTMLTAG_OPEN) { // '<'
            break;
        } else if (c == '"' || c == '\'') {
            quote = c;
        }
        ++close;
    }

@@ -1094,7 +1117,7 @@ size_t libhtmlpp::HtmlElement::parseElement(

    reinterpret_cast<HtmlElement*>(el.get())->_serialelize(tel);

    return ++close;
    return foundClose ? close + 1 : close;
}

namespace libhtmlpp {