blautenb    2003/08/09 03:10:11

  Modified:    c/src/canon XSECC14n20010315.cpp XSECC14n20010315.hpp
  Log:
  Fix bug in ordering of attributes when namespace is empty
  
  Revision  Changes    Path
  1.11      +15 -38    xml-security/c/src/canon/XSECC14n20010315.cpp
  
  Index: XSECC14n20010315.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/canon/XSECC14n20010315.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XSECC14n20010315.cpp      5 Aug 2003 11:36:09 -0000       1.10
  +++ XSECC14n20010315.cpp      9 Aug 2003 10:10:11 -0000       1.11
  @@ -1191,51 +1191,28 @@
                                                toIns = new XSECNodeListElt;
                                                toIns->element = 
tmpAtts->item(i);
                                                
  -                                             // First the correct prefix     
                                        
  +                                             // First the correct prefix to 
ensure will be sorted
  +                                             // in correct placing against 
XMLNS nodes
  +
                                                
toIns->sortString.sbStrcpyIn(ATTRIBUTE_PREFIX);
                                                
  -                                             // Now break down the name to 
see if it has a namespace
  -                                             int len = 
currentName.sbStrlen();
  -                                             int k;
  -                                             
  -                                             for (k = 0; k < len; ++k) {
  -                                                     
  -                                                     if (currentName[k] == 
':')
  -                                                             break;
  -                                                     
  -                                             }
  -
  -                                             safeBuffer      tsb, tsc;
  +                                             // Find the namespace URI
  +                                             const XMLCh * nsURI = 
  +                                                     
tmpAtts->item(i)->getNamespaceURI();
   
  -                                             tsb.sbStrcpyIn("xmlns:");
  -                                             
  -                                             if (k < len) {
  -                                                     
  -                                                     // Have a namespace 
delcleration
  -                                                     
  -                                                     
  -                                                     
tsc.sbStrncpyIn(currentName, k);
  -                                                     tsb.sbStrcatIn(tsc);
  -                                                     
  -                                                     
  +                                             if (nsURI == NULL) {
  +                                                     
toIns->sortString.sbStrcatIn(NOURI_PREFIX);
                                                }
  -                                             // find the URL matching 
identifier tsb
  -                                             XMLCh * tsbXMLCh = 
XMLString::transcode(tsb.rawCharBuffer());
  -                                             DOMNode *nsd = 
mp_nextNode->getAttributes()->getNamedItem(tsbXMLCh);
  -                                             delete[] tsbXMLCh;
  -
  -                                             if (nsd != NULL) {
  -                                                     // Found a namespace!
  -                                                     *formatter << 
nsd->getNodeValue();
  +                                             else {
  +                                                     *formatter << nsURI;
  +                                                     
toIns->sortString.sbStrcatIn(HAVEURI_PREFIX);
                                                        
toIns->sortString.sbStrcatIn(formatBuffer);
  -                                                     
toIns->sortString.sbStrcatIn(":");
                                                }
   
  -                                             // Should throw!
  +                                             // Append the local name as the 
secondary key
  +                                             *formatter << 
tmpAtts->item(i)->getLocalName();
  +                                             
toIns->sortString.sbStrcatIn(formatBuffer);
   
  -                                             // Append rest of name.  Don't 
need value as name should be unique
  -                                             
toIns->sortString.sbStrcatIn(currentName);
  -                                             
                                                // Insert node
                                                mp_attributes = 
insertNodeIntoList(mp_attributes, toIns);
                                                
  
  
  
  1.4       +3 -0      xml-security/c/src/canon/XSECC14n20010315.hpp
  
  Index: XSECC14n20010315.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/canon/XSECC14n20010315.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSECC14n20010315.hpp      5 Jul 2003 10:30:30 -0000       1.3
  +++ XSECC14n20010315.hpp      9 Aug 2003 10:10:11 -0000       1.4
  @@ -158,6 +158,9 @@
   #define XMLNS_PREFIX         "a"
   #define ATTRIBUTE_PREFIX     "b"
   
  +#define NOURI_PREFIX         "a"
  +#define HAVEURI_PREFIX       "b"
  +
   // 
--------------------------------------------------------------------------------
   //           XSECC14n20010315 Object definition
   // 
--------------------------------------------------------------------------------
  
  
  

Reply via email to