[libxml2] Fix SAX2 builder in case of undefined attributes namespace
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Fix SAX2 builder in case of undefined attributes namespace
- Date: Fri, 27 Jan 2012 11:31:18 +0000 (UTC)
commit 1c989278d9650daafc79e55750bec5a5a224a553
Author: Daniel Veillard <veillard redhat com>
Date: Thu Jan 26 19:43:06 2012 +0800
Fix SAX2 builder in case of undefined attributes namespace
To follow the early XML-1.0 REC, the new localname is "prefix:localname"
and there is obviously now namespace.
SAX2.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/SAX2.c b/SAX2.c
index 0c48d65..e230cea 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2335,8 +2335,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]);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]