diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index bbe64c12..a5c57063 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -2585,6 +2585,7 @@ render_html_document(struct cache_entry *cached, struct document *document, char *end; struct string title; struct string head; + int xml2; assert(cached && document); if_assert_failed return; @@ -2601,15 +2602,19 @@ render_html_document(struct cache_entry *cached, struct document *document, put_chars_conv, line_break, html_special); if (!html_context) return; - +#ifdef CONFIG_ECMASCRIPT + xml2 = !!document->dom; +#else + xml2 = 0; +#endif renderer_context.g_ctrl_num = 0; renderer_context.cached = cached; renderer_context.convert_table = get_convert_table(head.source, document->options.cp, - document->options.assume_cp, + xml2 ? get_cp_index("utf-8") : document->options.assume_cp, &document->cp, &document->cp_status, - document->options.hard_assume); + xml2 ? 1 : document->options.hard_assume); #ifdef CONFIG_UTF8 html_context->options->utf8 = is_cp_utf8(document->options.cp); #endif /* CONFIG_UTF8 */ diff --git a/src/document/xml/renderer2.cpp b/src/document/xml/renderer2.cpp index e32bc872..5774b50f 100644 --- a/src/document/xml/renderer2.cpp +++ b/src/document/xml/renderer2.cpp @@ -354,26 +354,9 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str if (!document->dom) { return; } - struct string head; - assert(cached && document); if_assert_failed return; - if (!init_string(&head)) return; - - bool add_to_head = true; -// if (cached->head) { -// if (!strncmp(cached->head, "\r\nContent-Type: text/html; charset=utf-8\r\n", -// sizeof("\r\nContent-Type: text/html; charset=utf-8\r\n") - 1)) { -// add_to_head = false; -// } -// } - - if (add_to_head) { -// add_to_string(&head, "\r\nContent-Type: text/html; charset=utf-8\r\n"); -// if (cached->head) add_to_string(&head, cached->head); - } - xmlpp::Document *doc = (xmlpp::Document *)document->dom; xmlpp::Element* root = (xmlpp::Element *)doc->get_root_node(); @@ -381,7 +364,6 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str struct string tt; if (!init_string(&tt)) { - done_string(&head); return; } std::map *mapa = (std::map *)document->element_map; @@ -397,9 +379,5 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str buffer = &tt; document->text = tt.source; } - - if (add_to_head) { -// mem_free_set(&cached->head, head.source); - } render_html_document(cached, document, buffer); } diff --git a/src/ecmascript/ecmascript.cpp b/src/ecmascript/ecmascript.cpp index 9e0697c9..cb61581c 100644 --- a/src/ecmascript/ecmascript.cpp +++ b/src/ecmascript/ecmascript.cpp @@ -889,7 +889,7 @@ document_parse(struct document *document) add_bytes_to_string(&str, f->data, f->length); // Parse HTML and create a DOM tree - xmlDoc* doc = htmlReadDoc((xmlChar*)str.source, NULL, "utf-8", + xmlDoc* doc = htmlReadDoc((xmlChar*)str.source, NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING); // Encapsulate raw libxml document in a libxml++ wrapper xmlpp::Document *docu = new xmlpp::Document(doc);