Commit 8fd810be authored by Jan Koester's avatar Jan Koester
Browse files

test

parent 283c1f06
Loading
Loading
Loading
Loading
+3034 −3015
Original line number Diff line number Diff line
@@ -2722,16 +2722,35 @@ void libhtmlpp::HtmlElement::setAttribute(const std::string &name, const std::st
        return false;
    };

    if(checkForbidden(name) || checkForbidden(value)){
    // Attribute names come from the code, not user data, so an embedded '"'
    // there stays a hard error. Values routinely carry arbitrary user text
    // (alt text, titles, ...) and print() always wraps them in ="..." -- a
    // literal '"' would otherwise break out of that quoting, so encode it
    // instead of rejecting the whole call (a real DOM setAttribute() never
    // throws for this either).
    if(checkForbidden(name)){
        HTMLException e;
        e[HTMLException::Error] << "setAttribute " << name.c_str() << "forbidden sign is used !";
        throw e;
    }

    std::string safeValue = value;
    if(checkForbidden(safeValue)){
        std::string escaped;
        escaped.reserve(safeValue.size());
        for(char c : safeValue){
            if(c == '\"')
                escaped += "&quot;";
            else
                escaped += c;
        }
        safeValue.swap(escaped);
    }

    for (cattr= _firstAttr.get(); cattr; cattr=cattr->_nextAttr.get()) {
        if(name.size() == cattr->_Key.size() && std::equal(name.begin(),name.end(),cattr->_Key.begin())){
            cattr->_Value.clear();
            std::copy(value.begin(),value.end(),std::back_inserter(cattr->_Value));
            std::copy(safeValue.begin(),safeValue.end(),std::back_inserter(cattr->_Value));
            return;
        }
    }
@@ -2745,7 +2764,7 @@ void libhtmlpp::HtmlElement::setAttribute(const std::string &name, const std::st

    cattr = _lastAttr;
    std::copy(name.begin(),name.end(),std::back_inserter(cattr->_Key) );
    std::copy(value.begin(),value.end(),std::back_inserter(cattr->_Value));
    std::copy(safeValue.begin(),safeValue.end(),std::back_inserter(cattr->_Value));
}

void libhtmlpp::HtmlElement::setIntAttribute(const std::string& name, int value) {
+95 −95

File changed.

Contains only whitespace changes.

+41 −41

File changed.

Contains only whitespace changes.

+432 −432

File changed.

Contains only whitespace changes.

+103 −103

File changed.

Contains only whitespace changes.

+1281 −1281

File changed.

Contains only whitespace changes.

+373 −373

File changed.

Contains only whitespace changes.

+142 −142

File changed.

Contains only whitespace changes.

Loading