}
else if (html_document_state == html_document_state::head) {
if (!(cur_tag->flags & (CM_EMPTY | CM_HEAD))) {
- if (parent_tag && parent_tag->id == Tag_HEAD) {
+ if (parent_tag && (parent_tag->id == Tag_HEAD || !(parent_tag->flags & CM_HEAD))) {
/*
* As by standard, we have to close the HEAD tag
* and switch to the body state
else if (cur_tag->id == Tag_BODY) {
html_document_state = html_document_state::body;
}
+ else {
+ /*
+ * For propagation in something like
+ * <title><p><a>ololo</a></p></title> - should be unprocessed
+ */
+ cur_tag->flags |= CM_HEAD;
+ }
}
}
{
using namespace std::string_literals;
const std::vector<std::tuple<std::string, std::vector<std::string>, std::optional<std::string>>> cases{
+ {"<style></style><a href=\"https://www.example.com\">yolo</a>",
+ {"https://www.example.com"}, "yolo"},
{"<a href=\"https://example.com\">test</a>", {"https://example.com"}, "test"},
{"<a <poo href=\"http://example.com\">hello</a>", {"http://example.com"}, "hello"},
{"<html>\n"
"<body>\n"
"<a href=\"https://www.example.com\">hello</a>\n"
"</body>\n"
- "</html>", {"https://www.example.com"}, "hello"}
+ "</html>", {"https://www.example.com"}, "hello"},
};
rspamd_url_init(NULL);