[xml] small patch to c14n.c



Daniel,

While testing XMLDSig I found a small bug in c14n code I wrote
(the namespace nodes were processed slightly incorrect in one
particular case). Please find the fix in attached diff.

Also thanks for taking care of few other bugs I made in this code.
You know that it is very difficult to test all possible options/compilers/platforms.

Thanks a lot for your support,

Aleksey.
Index: c14n.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/c14n.c,v
retrieving revision 1.3
diff -c -r1.3 c14n.c
*** c14n.c      2002/03/11 09:15:30     1.3
--- c14n.c      2002/03/15 07:59:14
***************
*** 266,273 ****
      xmlNsPtr ns;
      xmlListPtr list;
      xmlNodePtr visible_parent;
      xmlNsPtr prev;
! 
      if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
  #ifdef DEBUG_C14N
          xmlGenericError(xmlGenericErrorContext,
--- 266,274 ----
      xmlNsPtr ns;
      xmlListPtr list;
      xmlNodePtr visible_parent;
+     xmlNodePtr node;
      xmlNsPtr prev;
!     
      if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
  #ifdef DEBUG_C14N
          xmlGenericError(xmlGenericErrorContext,
***************
*** 302,307 ****
--- 303,309 ----
       * defined in node parents). By this we need to now walk thru 
       * all namespace in current node and all invisible ancesstors
       */
+     node = cur;
      while (cur != visible_parent) {
          for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
              /* 
***************
*** 311,316 ****
--- 313,323 ----
              if ((xmlC14NIsXmlNs(ns)) || (xmlListSearch(list, ns) != NULL)) {
                  continue;
              }
+           prev = xmlSearchNs(ctx->doc, node, ns->prefix);
+           if(prev != ns) {
+               /* we already processed a namespace with this name */
+               continue;
+           }
  
              /*
               * Lookup nearest namespace after visible parent having


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]