mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[document] pass charset to document_parse_text
This commit is contained in:
parent
e470cf76dc
commit
40b825eadd
@ -17,17 +17,18 @@
|
||||
#include "cache/cache.h"
|
||||
#include "document/document.h"
|
||||
#include "document/libdom/doc.h"
|
||||
#include "intl/charsets.h"
|
||||
#include "util/string.h"
|
||||
|
||||
void *
|
||||
document_parse_text(char *data, size_t length)
|
||||
document_parse_text(const char *charset, char *data, size_t length)
|
||||
{
|
||||
dom_hubbub_parser *parser = NULL;
|
||||
dom_hubbub_error error;
|
||||
dom_hubbub_parser_params params;
|
||||
dom_document *doc;
|
||||
|
||||
params.enc = NULL;
|
||||
params.enc = charset;
|
||||
params.fix_enc = true;
|
||||
params.enable_script = false;
|
||||
params.msg = NULL;
|
||||
@ -72,12 +73,13 @@ document_parse(struct document *document)
|
||||
#endif
|
||||
struct cache_entry *cached = document->cached;
|
||||
struct fragment *f = get_cache_fragment(cached);
|
||||
const char *charset = document->cp >= 0 ? get_cp_mime_name(document->cp) : "";
|
||||
|
||||
if (!f || !f->length) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return document_parse_text(f->data, f->length);
|
||||
return document_parse_text(charset, f->data, f->length);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -8,7 +8,7 @@ extern "C" {
|
||||
struct document;
|
||||
struct string;
|
||||
|
||||
void *document_parse_text(char *data, size_t length);
|
||||
void *document_parse_text(const char *charset, char *data, size_t length);
|
||||
void *document_parse(struct document *document);
|
||||
void free_document(void *doc);
|
||||
|
||||
|
@ -40,7 +40,7 @@ mjs_implementation_createHTMLDocument(js_State *J)
|
||||
add_html_to_string(&str, title, strlen(title));
|
||||
add_to_string(&str, "</title></head><body></body></html>");
|
||||
|
||||
void *docu = document_parse_text(str.source, str.length);
|
||||
void *docu = document_parse_text("utf-8", str.source, str.length);
|
||||
done_string(&str);
|
||||
mjs_push_document(J, docu);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ js_implementation_createHTMLDocument(JSContext *ctx, JSValueConst this_val, int
|
||||
add_html_to_string(&str, title, len);
|
||||
add_to_string(&str, "</title></head><body></body></html>");
|
||||
|
||||
void *docu = document_parse_text(str.source, str.length);
|
||||
void *docu = document_parse_text("utf-8", str.source, str.length);
|
||||
done_string(&str);
|
||||
JS_FreeCString(ctx, title);
|
||||
|
||||
|
@ -78,7 +78,7 @@ implementation_createHTMLDocument(JSContext *ctx, unsigned int argc, JS::Value *
|
||||
add_html_to_string(&str, title, strlen(title));
|
||||
add_to_string(&str, "</title></head><body></body></html>");
|
||||
|
||||
void *docu = document_parse_text(str.source, str.length);
|
||||
void *docu = document_parse_text("utf-8", str.source, str.length);
|
||||
done_string(&str);
|
||||
mem_free(title);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user