add packaging
[platform/upstream/libxml2.git] / packaging / fix-perl.diff
1 commit 77b77b1301e052d90e6a0967534a698506afcd86
2 Author: Daniel Veillard <veillard@redhat.com>
3 Date:   Thu Jan 26 19:11:02 2012 +0800
4
5     Fix SAX2 builder in case of undefined element namespaces
6     
7     Work as in XML-1.0 before namespaces, and use prefix:localname
8     as the new element name (and no namespace of course)
9     Also fix 3 cases in the regression tests where the prefix: was
10     erroneously dropped in such case
11
12 diff --git a/SAX2.c b/SAX2.c
13 index c0482c0..0c48d65 100644
14 --- a/SAX2.c
15 +++ b/SAX2.c
16 @@ -2163,6 +2163,7 @@ xmlSAX2StartElementNs(void *ctx,
17      xmlNodePtr parent;
18      xmlNsPtr last = NULL, ns;
19      const xmlChar *uri, *pref;
20 +    xmlChar *lname = NULL;
21      int i, j;
22  
23      if (ctx == NULL) return;
24 @@ -2182,6 +2183,20 @@ xmlSAX2StartElementNs(void *ctx,
25      }
26  
27      /*
28 +     * Take care of the rare case of an undefined namespace prefix
29 +     */
30 +    if ((prefix != NULL) && (URI == NULL)) {
31 +        if (ctxt->dictNames) {
32 +           const xmlChar *fullname;
33 +
34 +           fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
35 +           if (fullname != NULL)
36 +               localname = fullname;
37 +       } else {
38 +           lname = xmlBuildQName(localname, prefix, NULL, 0);
39 +       }
40 +    }
41 +    /*
42       * allocate the node
43       */
44      if (ctxt->freeElems != NULL) {
45 @@ -2194,7 +2209,10 @@ xmlSAX2StartElementNs(void *ctx,
46         if (ctxt->dictNames)
47             ret->name = localname;
48         else {
49 -           ret->name = xmlStrdup(localname);
50 +           if (lname == NULL)
51 +               ret->name = xmlStrdup(localname);
52 +           else
53 +               ret->name = lname;
54             if (ret->name == NULL) {
55                 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
56                 return;
57 @@ -2206,8 +2224,11 @@ xmlSAX2StartElementNs(void *ctx,
58         if (ctxt->dictNames)
59             ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, 
60                                        (xmlChar *) localname, NULL);
61 -       else
62 +       else if (lname == NULL)
63             ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
64 +       else
65 +           ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, 
66 +                                      (xmlChar *) lname, NULL);
67         if (ret == NULL) {
68             xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
69             return;
70 diff --git a/result/namespaces/err_7.xml b/result/namespaces/err_7.xml
71 index f4e5164..4b4c662 100644
72 --- a/result/namespaces/err_7.xml
73 +++ b/result/namespaces/err_7.xml
74 @@ -1,2 +1,2 @@
75  <?xml version="1.0"?>
76 -<foo/>
77 +<f:foo/>
78 diff --git a/result/xmlid/id_tst2.xml b/result/xmlid/id_tst2.xml
79 index 33ee896..856a320 100644
80 --- a/result/xmlid/id_tst2.xml
81 +++ b/result/xmlid/id_tst2.xml
82 @@ -1,6 +1,6 @@
83  Object is a Node Set :
84  Set contains 1 nodes:
85 -1  ELEMENT foo
86 +1  ELEMENT n:foo
87      ATTRIBUTE id
88        TEXT
89          content=bar
90 diff --git a/result/xmlid/id_tst3.xml b/result/xmlid/id_tst3.xml
91 index e2f8228..6d8865c 100644
92 --- a/result/xmlid/id_tst3.xml
93 +++ b/result/xmlid/id_tst3.xml
94 @@ -1,6 +1,6 @@
95  Object is a Node Set :
96  Set contains 1 nodes:
97 -1  ELEMENT o:o
98 +1  ELEMENT f:o:o
99      ATTRIBUTE id
100        TEXT
101          content=bar
102 commit 1c989278d9650daafc79e55750bec5a5a224a553
103 Author: Daniel Veillard <veillard@redhat.com>
104 Date:   Thu Jan 26 19:43:06 2012 +0800
105
106     Fix SAX2 builder in case of undefined attributes namespace
107     
108     To follow the early XML-1.0 REC, the new localname is "prefix:localname"
109     and there is obviously now namespace.
110
111 diff --git a/SAX2.c b/SAX2.c
112 index 0c48d65..e230cea 100644
113 --- a/SAX2.c
114 +++ b/SAX2.c
115 @@ -2335,8 +2335,33 @@ xmlSAX2StartElementNs(void *ctx,
116       */
117      if (nb_attributes > 0) {
118          for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
119 +           /*
120 +            * Handle the rare case of an undefined atribute prefix
121 +            */
122 +           if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
123 +               if (ctxt->dictNames) {
124 +                   const xmlChar *fullname;
125 +
126 +                   fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
127 +                                             attributes[j]);
128 +                   if (fullname != NULL) {
129 +                       xmlSAX2AttributeNs(ctxt, fullname, NULL,
130 +                                          attributes[j+3], attributes[j+4]);
131 +                       continue;
132 +                   }
133 +               } else {
134 +                   lname = xmlBuildQName(attributes[j], attributes[j+1],
135 +                                         NULL, 0);
136 +                   if (lname != NULL) {
137 +                       xmlSAX2AttributeNs(ctxt, lname, NULL,
138 +                                          attributes[j+3], attributes[j+4]);
139 +                       xmlFree(lname);
140 +                       continue;
141 +                   }
142 +               }
143 +           }
144             xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
145 -                              attributes[j+3], attributes[j+4]);
146 +                              attributes[j+3], attributes[j+4]);
147         }
148      }
149