diff --git a/src/document/html/internal.h b/src/document/html/internal.h index 968b208e..643ba09e 100644 --- a/src/document/html/internal.h +++ b/src/document/html/internal.h @@ -67,6 +67,7 @@ struct html_context { unsigned int was_br:1; unsigned int was_xmp:1; + unsigned int was_style:1; unsigned int has_link_lines:1; unsigned int was_body:1; /* For META refresh inside
. */ unsigned int was_body_background:1; /* For with style. */ diff --git a/src/document/html/parser/general.c b/src/document/html/parser/general.c index f84e4e95..59d97f13 100644 --- a/src/document/html/parser/general.c +++ b/src/document/html/parser/general.c @@ -353,6 +353,7 @@ void html_style(struct html_context *html_context, unsigned char *a, unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5) { + html_context->was_style = 1; html_skip(html_context, a); } diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index 0eba68fd..824cfa17 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -700,7 +700,7 @@ next_break: } if (html + 2 <= eof && html[0] == '<' && (html[1] == '!' || html[1] == '?') - && !html_context->was_xmp) { + && !(html_context->was_xmp || html_context->was_style)) { put_chrs(html_context, base_pos, html - base_pos); html = skip_comment(html, eof); continue; @@ -901,6 +901,7 @@ end_element(struct element_info *ei, int kill = 0; if (ei->func == html_xmp) html_context->was_xmp = 0; + if (ei->func == html_style) html_context->was_style = 0; html_context->was_br = 0; if (ei->type == ELEMENT_TYPE_NON_PAIRABLE @@ -974,8 +975,8 @@ process_element(unsigned char *name, int namelen, int endingtag, #else ei = (struct element_info *) fastfind_search(&ff_tags_index, name, namelen); #endif - if (html_context->was_xmp) { - if (!ei || ei->func != html_xmp || !endingtag) { + if (html_context->was_xmp || html_context->was_style) { + if (!ei || (ei->func != html_xmp && ei->func != html_style) || !endingtag) { put_chrs(html_context, "<", 1); return prev_html + 1; }