Commit bdb9ba77 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

- tree.c: fixed xmlStringGetNodeList() to handle charrefs

- result/wml.xml: resulted in a small output change
Daniel
parent d2f3ec78
Wed Apr 11 13:26:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* tree.c: fixed xmlStringGetNodeList() to handle charrefs
* result/wml.xml: resulted in a small output change
Wed Apr 11 09:47:55 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Wed Apr 11 09:47:55 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* tree.c: xmlNewDoc was missing the charset initialization * tree.c: xmlNewDoc was missing the charset initialization
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<wml> <wml>
<card id="card1" title="Rubriques 75008"> <card id="card1" title="Rubriques 75008">
<p> <p>
<a href="rubmenu.asp?CP=75008&#38;RB=01">Cin&#xE9;ma</a><br/> <a href="rubmenu.asp?CP=75008&amp;RB=01">Cin&#xE9;ma</a><br/>
</p> </p>
</card> </card>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <libxml/entities.h> #include <libxml/entities.h>
#include <libxml/valid.h> #include <libxml/valid.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns); xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
...@@ -57,9 +58,6 @@ static int xmlCompressMode = 0; ...@@ -57,9 +58,6 @@ static int xmlCompressMode = 0;
static int xmlCheckDTD = 1; static int xmlCheckDTD = 1;
int xmlSaveNoEmptyTags = 0; int xmlSaveNoEmptyTags = 0;
#define IS_BLANK(c) \
(((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' '))
#define UPDATE_LAST_CHILD_AND_PARENT(n) if ((n) != NULL) { \ #define UPDATE_LAST_CHILD_AND_PARENT(n) if ((n) != NULL) { \
xmlNodePtr ulccur = (n)->children; \ xmlNodePtr ulccur = (n)->children; \
if (ulccur == NULL) { \ if (ulccur == NULL) { \
...@@ -646,11 +644,10 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) { ...@@ -646,11 +644,10 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
q = cur; q = cur;
while (*cur != 0) { while (*cur != 0) {
/* TODO: attributes can inherits &#38; ... if (cur[0] == '&') {
if ((*cur == '&') && (cur[1] == '#')) { int charval = 0;
int val = xmlChar tmp;
} else */
if (*cur == '&') {
/* /*
* Save the current text. * Save the current text.
*/ */
...@@ -669,55 +666,113 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) { ...@@ -669,55 +666,113 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
} }
} }
} }
/*
* Read the entity string
*/
cur++;
q = cur; q = cur;
while ((*cur != 0) && (*cur != ';')) cur++; if ((cur[1] == '#') && (cur[2] == 'x')) {
if (*cur == 0) { cur += 3;
#ifdef DEBUG_TREE tmp = *cur;
xmlGenericError(xmlGenericErrorContext, while (tmp != ';') { /* Non input consuming loop */
"xmlStringGetNodeList: unterminated entity %30s\n", q); if ((tmp >= '0') && (tmp <= '9'))
#endif charval = charval * 16 + (tmp - '0');
return(ret); else if ((tmp >= 'a') && (tmp <= 'f'))
} charval = charval * 16 + (tmp - 'a') + 10;
if (cur != q) { else if ((tmp >= 'A') && (tmp <= 'F'))
charval = charval * 16 + (tmp - 'A') + 10;
else {
xmlGenericError(xmlGenericErrorContext,
"xmlStringGetNodeList: incharvalid hexadecimal charvalue\n");
charval = 0;
break;
}
cur++;
tmp = *cur;
}
if (tmp == ';')
cur++;
q = cur;
} else if (cur[1] == '#') {
cur += 2;
tmp = *cur;
while (tmp != ';') { /* Non input consuming loops */
if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 10 + (tmp - '0');
else {
xmlGenericError(xmlGenericErrorContext,
"xmlStringGetNodeList: incharvalid decimal charvalue\n");
charval = 0;
break;
}
cur++;
tmp = *cur;
}
if (tmp == ';')
cur++;
q = cur;
} else {
/* /*
* Predefined entities don't generate nodes * Read the entity string
*/ */
val = xmlStrndup(q, cur - q); cur++;
ent = xmlGetDocEntity(doc, val); q = cur;
if ((ent != NULL) && while ((*cur != 0) && (*cur != ';')) cur++;
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { if (*cur == 0) {
if (last == NULL) { #ifdef DEBUG_TREE
node = xmlNewDocText(doc, ent->content); xmlGenericError(xmlGenericErrorContext,
last = ret = node; "xmlStringGetNodeList: unterminated entity %30s\n", q);
} else #endif
xmlNodeAddContent(last, ent->content); return(ret);
}
} else { if (cur != q) {
/* /*
* Create a new REFERENCE_REF node * Predefined entities don't generate nodes
*/ */
node = xmlNewReference(doc, val); val = xmlStrndup(q, cur - q);
if (node == NULL) { ent = xmlGetDocEntity(doc, val);
if (val != NULL) xmlFree(val); if ((ent != NULL) &&
return(ret); (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
if (last == NULL) {
node = xmlNewDocText(doc, ent->content);
last = ret = node;
} else
xmlNodeAddContent(last, ent->content);
} else {
/*
* Create a new REFERENCE_REF node
*/
node = xmlNewReference(doc, val);
if (node == NULL) {
if (val != NULL) xmlFree(val);
return(ret);
}
if (last == NULL) {
last = ret = node;
} else {
last = xmlAddNextSibling(last, node);
}
} }
if (last == NULL) xmlFree(val);
}
cur++;
q = cur;
}
if (charval != 0) {
xmlChar buf[10];
int len;
len = xmlCopyCharMultiByte(buf, charval);
buf[len] = 0;
node = xmlNewDocText(doc, buf);
if (node != NULL) {
if (last == NULL) {
last = ret = node; last = ret = node;
else { } else {
last->next = node; last = xmlAddNextSibling(last, node);
node->prev = last;
last = node;
} }
} }
xmlFree(val);
charval = 0;
} }
cur++; } else
q = cur;
} else
cur++; cur++;
} }
if (cur != q) { if (cur != q) {
...@@ -729,12 +784,10 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) { ...@@ -729,12 +784,10 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
} else { } else {
node = xmlNewDocTextLen(doc, q, cur - q); node = xmlNewDocTextLen(doc, q, cur - q);
if (node == NULL) return(ret); if (node == NULL) return(ret);
if (last == NULL) if (last == NULL) {
last = ret = node; last = ret = node;
else { } else {
last->next = node; last = xmlAddNextSibling(last, node);
node->prev = last;
last = node;
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment