Author: amassari
Date: Fri May 12 14:21:05 2006
New Revision: 405875

URL: http://svn.apache.org/viewcvs?rev=405875&view=rev
Log:
Allow spaces in anyURIs, as they are 'legal but highly discouraged' (jira#1581)

Modified:
    xerces/c/trunk/src/xercesc/framework/psvi/XSValue.cpp
    xerces/c/trunk/src/xercesc/util/XMLUri.cpp
    xerces/c/trunk/src/xercesc/util/XMLUri.hpp
    xerces/c/trunk/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp

Modified: xerces/c/trunk/src/xercesc/framework/psvi/XSValue.cpp
URL: 
http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/framework/psvi/XSValue.cpp?rev=405875&r1=405874&r2=405875&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/framework/psvi/XSValue.cpp (original)
+++ xerces/c/trunk/src/xercesc/framework/psvi/XSValue.cpp Fri May 12 14:21:05 
2006
@@ -756,7 +756,7 @@
             }            
             break;
         case XSValue::dt_anyURI:
-            if (XMLUri::isValidURI(true, content) == false) {
+            if (XMLUri::isValidURI(true, content, true) == false) {
                 isValid = false;
             }        
             break;

Modified: xerces/c/trunk/src/xercesc/util/XMLUri.cpp
URL: 
http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/XMLUri.cpp?rev=405875&r1=405874&r2=405875&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLUri.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLUri.cpp Fri May 12 14:21:05 2006
@@ -2017,7 +2017,8 @@
 
 // NOTE: no check for NULL value of uriStr (caller responsiblilty)
 bool XMLUri::isValidURI(const XMLUri* const baseURI
-                       , const XMLCh* const uriStr)
+                       , const XMLCh* const uriStr
+                       , bool bAllowSpaces/*=false*/)
 {
     // get a trimmed version of uriStr
     // uriStr will NO LONGER be used in this function.
@@ -2108,7 +2109,7 @@
     // we need to check if index has exceed the lenght or not
     if (index < trimmedUriSpecLen)
     {
-           if (!processPath(trimmedUriSpec + index, trimmedUriSpecLen - index, 
foundScheme))
+           if (!processPath(trimmedUriSpec + index, trimmedUriSpecLen - index, 
foundScheme, bAllowSpaces))
             return false;
     }
 
@@ -2118,7 +2119,7 @@
 // NOTE: no check for NULL value of uriStr (caller responsiblilty)
 // NOTE: this routine is the same as above, but it uses a flag to
 //       indicate the existance of a baseURI rather than an XMLuri.
-bool XMLUri::isValidURI(bool haveBaseURI, const XMLCh* const uriStr)
+bool XMLUri::isValidURI(bool haveBaseURI, const XMLCh* const uriStr, bool 
bAllowSpaces/*=false*/)
 {
     // get a trimmed version of uriStr
     // uriStr will NO LONGER be used in this function.
@@ -2208,7 +2209,7 @@
     // we need to check if index has exceed the length or not
     if (index < trimmedUriSpecLen)
     {
-        if (!processPath(trimmedUriSpec + index, trimmedUriSpecLen - index, 
foundScheme))
+        if (!processPath(trimmedUriSpec + index, trimmedUriSpecLen - index, 
foundScheme, bAllowSpaces))
             return false;
     }
 
@@ -2417,7 +2418,8 @@
 
 bool XMLUri::processPath(const XMLCh* const pathStr,
                          const int pathStrLen,
-                         const bool isSchemePresent)
+                         const bool isSchemePresent,
+                         const bool bAllowSpaces/*=false*/)
 {
     if (pathStrLen != 0)
     {
@@ -2441,7 +2443,8 @@
                     !XMLString::isHex(pathStr[index+2]))
                         return false;
             }
-            else if (!isUnreservedCharacter(testChar) &&
+            else if ((testChar==chSpace && !bAllowSpaces) &&
+                     !isUnreservedCharacter(testChar) &&
                      ((isOpaque && !isPathCharacter(testChar)) ||
                       (!isOpaque && !isReservedCharacter(testChar))))
             {
@@ -2473,7 +2476,8 @@
                         !XMLString::isHex(pathStr[index+2]))
                         return false;
                 }
-                else if (!isReservedOrUnreservedCharacter(testChar))           
         
+                else if ((testChar==chSpace && !bAllowSpaces) &&
+                         !isReservedOrUnreservedCharacter(testChar))           
         
                 {
                     return false;
                 }

Modified: xerces/c/trunk/src/xercesc/util/XMLUri.hpp
URL: 
http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/XMLUri.hpp?rev=405875&r1=405874&r2=405875&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLUri.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLUri.hpp Fri May 12 14:21:05 2006
@@ -291,12 +291,14 @@
      * Determine whether a given string is a valid URI
      */
     static bool isValidURI( const XMLUri* const baseURI
-                          , const XMLCh* const uriStr);
+                          , const XMLCh* const uriStr
+                          , bool bAllowSpaces=false);
     /**
      * Determine whether a given string is a valid URI
      */
     static bool isValidURI( bool haveBaseURI
-                          , const XMLCh* const uriStr);
+                          , const XMLCh* const uriStr
+                          , bool bAllowSpaces=false);
 
 
     static void normalizeURI(const XMLCh*     const systemURI,
@@ -552,7 +554,7 @@
     static bool processAuthority(const XMLCh* const uriStr, const int authLen);
     static bool isWellFormedAddress(const XMLCh* const addr, const int 
addrLen);
     static bool processPath(const XMLCh* const pathStr, const int pathStrLen,
-                            const bool isSchemePresent);
+                            const bool isSchemePresent, const bool 
bAllowSpaces=false);
 
     // -----------------------------------------------------------------------
     //  Data members

Modified: 
xerces/c/trunk/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp
URL: 
http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp?rev=405875&r1=405874&r2=405875&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp 
(original)
+++ xerces/c/trunk/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp 
Fri May 12 14:21:05 2006
@@ -76,7 +76,7 @@
         //
         if (XMLString::stringLen(content))
         {          
-              if (!XMLUri::isValidURI(true, content))
+              if (!XMLUri::isValidURI(true, content, true))
                 ThrowXMLwithMemMgr1(InvalidDatatypeValueException
                     , XMLExcepts::VALUE_URI_Malformed
                     , content



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to