1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-30 22:43:14 +03:00

- HTMLtree.c: applied patch from Jaroslaw Kolakowski to close bug

#55380
- tree.c: patch to xmlNodeGetContent() to get CDATA section content
Daniel
This commit is contained in:
Daniel Veillard
2001-05-30 18:32:34 +00:00
parent 9403a0495d
commit 2d70372ce3
3 changed files with 58 additions and 8 deletions

View File

@ -1,3 +1,9 @@
Wed May 30 20:30:47 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* HTMLtree.c: applied patch from Jaroslaw Kolakowski to close bug
#55380
* tree.c: patch to xmlNodeGetContent() to get CDATA section content
Mon May 28 12:56:29 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Mon May 28 12:56:29 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* TODO: updated * TODO: updated

View File

@ -662,34 +662,77 @@ htmlDocContentDump(xmlBufferPtr buf, xmlDocPtr cur) {
* htmlDocDumpMemory: * htmlDocDumpMemory:
* @cur: the document * @cur: the document
* @mem: OUT: the memory pointer * @mem: OUT: the memory pointer
* @size: OUT: the memory lenght * @size: OUT: the memory length
* *
* Dump an HTML document in memory and return the xmlChar * and it's size. * Dump an HTML document in memory and return the xmlChar * and it's size.
* It's up to the caller to free the memory. * It's up to the caller to free the memory.
*/ */
void void
htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) { htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
xmlBufferPtr buf; xmlOutputBufferPtr buf;
xmlCharEncodingHandlerPtr handler = NULL;
const char *encoding;
if (cur == NULL) { if (cur == NULL) {
#ifdef DEBUG_TREE #ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"htmlxmlDocDumpMemory : document == NULL\n"); "htmlDocDumpMemory : document == NULL\n");
#endif #endif
*mem = NULL; *mem = NULL;
*size = 0; *size = 0;
return; return;
} }
buf = xmlBufferCreate();
encoding = (const char *) htmlGetMetaEncoding(cur);
if (encoding != NULL) {
xmlCharEncoding enc;
enc = xmlParseCharEncoding(encoding);
if (enc != cur->charset) {
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
/*
* Not supported yet
*/
*mem = NULL;
*size = 0;
return;
}
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL) {
*mem = NULL;
*size = 0;
return;
}
}
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
buf = xmlAllocOutputBuffer(handler);
if (buf == NULL) { if (buf == NULL) {
*mem = NULL; *mem = NULL;
*size = 0; *size = 0;
return; return;
} }
htmlDocContentDump(buf, cur);
*mem = buf->content; htmlDocContentDumpOutput(buf, cur, NULL);
*size = buf->use; xmlOutputBufferFlush(buf);
xmlFree(buf); if (buf->conv != NULL) {
*size = buf->conv->use;
*mem = xmlStrndup(buf->conv->content, *size);
} else {
*size = buf->buffer->use;
*mem = xmlStrndup(buf->buffer->content, *size);
}
(void)xmlOutputBufferClose(buf);
} }

1
tree.c
View File

@ -3308,6 +3308,7 @@ xmlNodeGetContent(xmlNodePtr cur) {
while (tmp != NULL) { while (tmp != NULL) {
switch (tmp->type) { switch (tmp->type) {
case XML_ELEMENT_NODE: case XML_ELEMENT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE: case XML_TEXT_NODE:
if (tmp->content != NULL) if (tmp->content != NULL)
#ifndef XML_USE_BUFFER_CONTENT #ifndef XML_USE_BUFFER_CONTENT