mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-01 10:06:59 +03:00
Fix xmlCtxtReadDoc with encoding
xmlCtxtReadDoc used to create an input stream involving
xmlNewStringInputStream. This would create a stream without an input
buffer, causing problems with encodings (see #34).
After commit aab584dc3
, an error was returned even with UTF-8 encodings
which happened to work before.
Make xmlCtxtReadDoc call xmlCtxtReadMemory which doesn't suffer from
these issues. Also fix htmlCtxtReadDoc.
Fixes #397.
This commit is contained in:
17
HTMLparser.c
17
HTMLparser.c
@ -7116,22 +7116,13 @@ htmlDocPtr
|
|||||||
htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
|
htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
|
||||||
const char *URL, const char *encoding, int options)
|
const char *URL, const char *encoding, int options)
|
||||||
{
|
{
|
||||||
xmlParserInputPtr stream;
|
const char *buf;
|
||||||
|
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if (ctxt == NULL)
|
buf = (const char *) cur;
|
||||||
return (NULL);
|
return (htmlCtxtReadMemory(ctxt, buf, strlen(buf), URL, encoding,
|
||||||
xmlInitParser();
|
options));
|
||||||
|
|
||||||
htmlCtxtReset(ctxt);
|
|
||||||
|
|
||||||
stream = xmlNewStringInputStream(ctxt, cur);
|
|
||||||
if (stream == NULL) {
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
inputPush(ctxt, stream);
|
|
||||||
return (htmlDoRead(ctxt, URL, encoding, options, 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
16
parser.c
16
parser.c
@ -15359,22 +15359,12 @@ xmlDocPtr
|
|||||||
xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
|
xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
|
||||||
const char *URL, const char *encoding, int options)
|
const char *URL, const char *encoding, int options)
|
||||||
{
|
{
|
||||||
xmlParserInputPtr stream;
|
const char *buf;
|
||||||
|
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if (ctxt == NULL)
|
buf = (const char *) cur;
|
||||||
return (NULL);
|
return (xmlCtxtReadMemory(ctxt, buf, strlen(buf), URL, encoding, options));
|
||||||
xmlInitParser();
|
|
||||||
|
|
||||||
xmlCtxtReset(ctxt);
|
|
||||||
|
|
||||||
stream = xmlNewStringInputStream(ctxt, cur);
|
|
||||||
if (stream == NULL) {
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
inputPush(ctxt, stream);
|
|
||||||
return (xmlDoRead(ctxt, URL, encoding, options, 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user