summaryrefslogtreecommitdiffstats
path: root/third_party/libxml/xmlsave.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libxml/xmlsave.c')
-rw-r--r--third_party/libxml/xmlsave.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/third_party/libxml/xmlsave.c b/third_party/libxml/xmlsave.c
index cbabd78..2a61577 100644
--- a/third_party/libxml/xmlsave.c
+++ b/third_party/libxml/xmlsave.c
@@ -727,8 +727,8 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
}
if (cur->type == XML_CDATA_SECTION_NODE) {
- if (cur->content == NULL) {
- xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
+ if (cur->content == NULL || *cur->content == '\0') {
+ xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
} else {
start = end = cur->content;
while (*end != '\0') {
@@ -1236,21 +1236,25 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
}
if (cur->type == XML_CDATA_SECTION_NODE) {
- start = end = cur->content;
- while (*end != '\0') {
- if (*end == ']' && *(end + 1) == ']' && *(end + 2) == '>') {
- end = end + 2;
+ if (cur->content == NULL || *cur->content == '\0') {
+ xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
+ } else {
+ start = end = cur->content;
+ while (*end != '\0') {
+ if (*end == ']' && *(end + 1) == ']' && *(end + 2) == '>') {
+ end = end + 2;
+ xmlOutputBufferWrite(buf, 9, "<![CDATA[");
+ xmlOutputBufferWrite(buf, end - start, (const char *)start);
+ xmlOutputBufferWrite(buf, 3, "]]>");
+ start = end;
+ }
+ end++;
+ }
+ if (start != end) {
xmlOutputBufferWrite(buf, 9, "<![CDATA[");
- xmlOutputBufferWrite(buf, end - start, (const char *)start);
+ xmlOutputBufferWriteString(buf, (const char *)start);
xmlOutputBufferWrite(buf, 3, "]]>");
- start = end;
}
- end++;
- }
- if (start != end) {
- xmlOutputBufferWrite(buf, 9, "<![CDATA[");
- xmlOutputBufferWriteString(buf, (const char *)start);
- xmlOutputBufferWrite(buf, 3, "]]>");
}
return;
}