1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-04-01 10:50:08 +03:00

html: Remove encoding hack in htmlCreateFileParserCtxt

Switch encoding directly instead of calling htmlCheckEncoding with faked
content.
This commit is contained in:
Nick Wellnhofer 2023-08-14 12:53:49 +02:00
parent 5db5a704eb
commit 0d24fc0a47

View File

@ -6292,8 +6292,6 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
htmlParserCtxtPtr ctxt;
htmlParserInputPtr inputStream;
char *canonicFilename;
/* htmlCharEncoding enc; */
xmlChar *content, *content_line = (xmlChar *) "charset=";
if (filename == NULL)
return(NULL);
@ -6319,17 +6317,12 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
/* set encoding */
if (encoding) {
size_t l = strlen(encoding);
xmlCharEncodingHandlerPtr hdlr;
if (l < 1000) {
content = xmlMallocAtomic (xmlStrlen(content_line) + l + 1);
if (content) {
strcpy ((char *)content, (char *)content_line);
strcat ((char *)content, (char *)encoding);
htmlCheckEncoding (ctxt, content);
xmlFree (content);
}
}
hdlr = xmlFindCharEncodingHandler(encoding);
if (hdlr != NULL) {
xmlSwitchToEncoding(ctxt, hdlr);
}
}
return(ctxt);