diff --git a/html_parser.hpp b/html_parser.hpp index d8b6c07..bd87705 100644 --- a/html_parser.hpp +++ b/html_parser.hpp @@ -18,7 +18,7 @@ #include #include -#if __cplusplus <= 199711L +#if __cplusplus < 199711L #if linux #include #else @@ -408,7 +408,8 @@ class HtmlElement : public enable_shared_from_this { std::cerr << "WARN : attribute unexpected " << input << std::endl; } else if (input == ' ') { if (!k.empty()) { - attribute[k] = v; + if (!attribute.count(k)) + attribute[k] = v; k.clear(); } } else if (input == '=') { @@ -422,7 +423,8 @@ class HtmlElement : public enable_shared_from_this { case PARSE_ATTR_VALUE_BEGIN:{ if (input == '\t' || input == '\r' || input == '\n' || input == ' ') { if (!k.empty()) { - attribute[k] = v; + if (!attribute.count(k)) + attribute[k] = v; k.clear(); } state = PARSE_ATTR_KEY; @@ -440,7 +442,8 @@ class HtmlElement : public enable_shared_from_this { case PARSE_ATTR_VALUE_END: { if((quota && input == split) || (!quota && (input == '\t' || input == '\r' || input == '\n' || input == ' '))) { - attribute[k] = v; + if (!attribute.count(k)) + attribute[k] = v; k.clear(); v.clear(); state = PARSE_ATTR_KEY; @@ -455,7 +458,8 @@ class HtmlElement : public enable_shared_from_this { } if(!k.empty()){ - attribute[k] = v; + if (!attribute.count(k)) + attribute[k] = v; } //trim