From 631eb6444d95f63ed6ebec82a8983bd34d2fa173 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Tue, 24 Nov 2015 15:28:32 +0900 Subject: [PATCH] Sync with tizen 2.4 Change-Id: I91b18973bff0d40687c3e02a193174b9480fde9c Signed-off-by: DongHun Kwak --- SAX2.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/SAX2.c b/SAX2.c index cf29f06..ffef3e1 100644 --- a/SAX2.c +++ b/SAX2.c @@ -2209,6 +2209,7 @@ xmlSAX2StartElementNs(void *ctx, xmlNodePtr parent; xmlNsPtr last = NULL, ns; const xmlChar *uri, *pref; + xmlChar *lname = NULL; int i, j; if (ctx == NULL) return; @@ -2228,6 +2229,20 @@ xmlSAX2StartElementNs(void *ctx, } /* + * Take care of the rare case of an undefined namespace prefix + */ + if ((prefix != NULL) && (URI == NULL)) { + if (ctxt->dictNames) { + const xmlChar *fullname; + + fullname = xmlDictQLookup(ctxt->dict, prefix, localname); + if (fullname != NULL) + localname = fullname; + } else { + lname = xmlBuildQName(localname, prefix, NULL, 0); + } + } + /* * allocate the node */ if (ctxt->freeElems != NULL) { @@ -2240,7 +2255,10 @@ xmlSAX2StartElementNs(void *ctx, if (ctxt->dictNames) ret->name = localname; else { - ret->name = xmlStrdup(localname); + if (lname == NULL) + ret->name = xmlStrdup(localname); + else + ret->name = lname; if (ret->name == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs"); return; @@ -2252,8 +2270,11 @@ xmlSAX2StartElementNs(void *ctx, if (ctxt->dictNames) ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, (xmlChar *) localname, NULL); - else + else if (lname == NULL) ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL); + else + ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, + (xmlChar *) lname, NULL); if (ret == NULL) { xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs"); return; @@ -2360,8 +2381,33 @@ xmlSAX2StartElementNs(void *ctx, */ if (nb_attributes > 0) { for (j = 0,i = 0;i < nb_attributes;i++,j+=5) { + /* + * Handle the rare case of an undefined atribute prefix + */ + if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) { + if (ctxt->dictNames) { + const xmlChar *fullname; + + fullname = xmlDictQLookup(ctxt->dict, attributes[j+1], + attributes[j]); + if (fullname != NULL) { + xmlSAX2AttributeNs(ctxt, fullname, NULL, + attributes[j+3], attributes[j+4]); + continue; + } + } else { + lname = xmlBuildQName(attributes[j], attributes[j+1], + NULL, 0); + if (lname != NULL) { + xmlSAX2AttributeNs(ctxt, lname, NULL, + attributes[j+3], attributes[j+4]); + xmlFree(lname); + continue; + } + } + } xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1], - attributes[j+3], attributes[j+4]); + attributes[j+3], attributes[j+4]); } } -- 2.7.4