mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[xml] Force "utf-8" encoding.
It is a step backwards. At least test cases for document.write don't crash.
This commit is contained in:
parent
df28d4345b
commit
c9fe1bf546
@ -362,16 +362,16 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
|
||||
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 (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);
|
||||
// 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;
|
||||
@ -399,7 +399,7 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
|
||||
}
|
||||
|
||||
if (add_to_head) {
|
||||
mem_free_set(&cached->head, head.source);
|
||||
// mem_free_set(&cached->head, head.source);
|
||||
}
|
||||
render_html_document(cached, document, buffer);
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
||||
text += interpreter->writecode.source;
|
||||
text += "</root>";
|
||||
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, "utf-8", HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
// Encapsulate raw libxml document in a libxml++ wrapper
|
||||
xmlpp::Document doc1(doc);
|
||||
|
||||
@ -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, NULL,
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)str.source, NULL, "utf-8",
|
||||
HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
// Encapsulate raw libxml document in a libxml++ wrapper
|
||||
xmlpp::Document *docu = new xmlpp::Document(doc);
|
||||
|
@ -924,7 +924,7 @@ mjs_element_set_property_innerHtml(js_State *J)
|
||||
text += val;
|
||||
text += "</root>";
|
||||
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, "utf-8", HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
// Encapsulate raw libxml document in a libxml++ wrapper
|
||||
xmlpp::Document doc1(doc);
|
||||
|
||||
|
@ -928,7 +928,7 @@ js_element_set_property_innerHtml(JSContext *ctx, JSValueConst this_val, JSValue
|
||||
text += "</root>";
|
||||
JS_FreeCString(ctx, str);
|
||||
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, "utf-8", HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
// Encapsulate raw libxml document in a libxml++ wrapper
|
||||
xmlpp::Document doc1(doc);
|
||||
|
||||
|
@ -1309,7 +1309,12 @@ document_write_do(JSContext *ctx, unsigned int argc, JS::Value *rval, int newlin
|
||||
{
|
||||
for (unsigned int i = 0; i < argc; ++i)
|
||||
{
|
||||
jshandle_value_to_char_string(&interpreter->writecode, ctx, args[i]);
|
||||
char *str = jsval_to_string(ctx, args[i]);
|
||||
|
||||
if (str) {
|
||||
add_to_string(&interpreter->writecode, str);
|
||||
mem_free(str);
|
||||
}
|
||||
}
|
||||
|
||||
if (newline)
|
||||
|
@ -2074,7 +2074,7 @@ element_set_property_innerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
text += "</root>";
|
||||
mem_free_if(vv);
|
||||
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, "utf-8", HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
|
||||
// Encapsulate raw libxml document in a libxml++ wrapper
|
||||
xmlpp::Document doc1(doc);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user