Commit 9c2bd54f authored by jan.koester's avatar jan.koester
Browse files

Merge branch 'main' of git.tuxist.de:jan.koester/libhtmlpp

parents cb5886c3 67ceff6a
Loading
Loading
Loading
Loading
+24 −4
Original line number Diff line number Diff line
@@ -48,7 +48,11 @@ namespace libhtmlpp {
    const char *ContainerTypes[]={
        "div",
        "script",
        "style",
        "span",
        "frame",
        "iframe",
        "textarea",
        nullptr
    };

@@ -1234,21 +1238,37 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){
    const char typevalue[] = { 'h','t','m','l' };
    size_t tpvl = 4;

    const char typevalue4[] = {'H','T','M','L',' ','P','U','B','L','I','C'};
    size_t tpvl4 = 11;

    if ((i + tpvl) > page.size()) {
        HTMLException excp;
        excp[HTMLException::Critical] << "Doctype header broken or wrong type";
        throw excp;
    }

    int ii = 0,ie=i+tpvl;
    int ii = 0,ie=i+tpvl,oldpos=i;

    while (i < ie) {
        if (page[i] != typevalue[ii]) {
            i=oldpos;
            if ((i + tpvl4) > page.size()) {
                HTMLException excp;
                excp[HTMLException::Critical] << "Doctype header broken or wrong type";
                throw excp;
            }
            int ii4 = 0,ie4=i+tpvl4;
            while (i < ie4) {
                if(page[i] != typevalue4[ii4]){
                    HTMLException excp;
                    excp[HTMLException::Critical] << "wrong Doctype";
                    throw excp;
                }
                ++i;
                ++ii4;
            }
        }
        ++i;
        ++ii;
    }
}