knoaman 2002/08/16 08:46:18 Modified: c/src/xercesc/internal XMLScanner.hpp XMLScanner2.cpp c/src/xercesc/validators/schema TraverseSchema.cpp TraverseSchema.hpp Log: Bug 7698 : filenames with embedded spaces in schemaLocation strings not handled properly. Revision Changes Path 1.10 +6 -0 xml-xerces/c/src/xercesc/internal/XMLScanner.hpp Index: XMLScanner.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- XMLScanner.hpp 31 Jul 2002 18:49:29 -0000 1.9 +++ XMLScanner.hpp 16 Aug 2002 15:46:17 -0000 1.10 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2002/08/16 15:46:17 knoaman + * Bug 7698 : filenames with embedded spaces in schemaLocation strings not handled properly. + * * Revision 1.9 2002/07/31 18:49:29 tng * [Bug 6227] Make method getLastExtLocation() constant. * @@ -615,6 +618,9 @@ void resetURIStringPool(); InputSource* resolveSystemId(const XMLCh* const sysId); // return owned by caller + // Spaces are not allowed in URI, so %20 is used instead. + // Convert %20 to spaces before resolving the URI + void normalizeURI(const XMLCh* const systemURI, XMLBuffer& normalizedURI); // ----------------------------------------------------------------------- // Private helper methods 1.13 +29 -4 xml-xerces/c/src/xercesc/internal/XMLScanner2.cpp Index: XMLScanner2.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner2.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- XMLScanner2.cpp 11 Jul 2002 18:22:13 -0000 1.12 +++ XMLScanner2.cpp 16 Aug 2002 15:46:17 -0000 1.13 @@ -1421,23 +1421,27 @@ // Create a buffer for expanding the system id XMLBufBid bbSys(&fBufMgr); XMLBuffer& expSysId = bbSys.getBuffer(); + XMLBuffer& normalizedSysId = bbSys.getBuffer(); + + normalizeURI(loc, normalizedSysId); // // Allow the entity handler to expand the system id if they choose // to do so. // InputSource* srcToFill = 0; + const XMLCh* normalizedURI = normalizedSysId.getRawBuffer(); if (fEntityHandler) { - if (!fEntityHandler->expandSystemId(loc, expSysId)) - expSysId.set(loc); + if (!fEntityHandler->expandSystemId(normalizedURI, expSysId)) + expSysId.set(normalizedURI); srcToFill = fEntityHandler->resolveEntity( XMLUni::fgZeroLenString , expSysId.getRawBuffer()); } else { - expSysId.set(loc); + expSysId.set(normalizedURI); } // @@ -3193,4 +3197,25 @@ return anyEncountered; } +void XMLScanner::normalizeURI(const XMLCh* const systemURI, + XMLBuffer& normalizedURI) +{ + const XMLCh* pszSrc = systemURI; + + normalizedURI.reset(); + while (*pszSrc) { + + if ((*(pszSrc) == chPercent) + && (*(pszSrc+1) == chDigit_2) + && (*(pszSrc+2) == chDigit_0)) + { + pszSrc += 3; + normalizedURI.append(chSpace); + } + else { + normalizedURI.append(*pszSrc); + pszSrc++; + } + } +} 1.24 +6 -4 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp Index: TraverseSchema.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- TraverseSchema.cpp 16 Jul 2002 14:28:00 -0000 1.23 +++ TraverseSchema.cpp 16 Aug 2002 15:46:17 -0000 1.24 @@ -6046,9 +6046,11 @@ // Create an input source // ------------------------------------------------------------------ InputSource* srcToFill = 0; + normalizeURI(loc, fBuffer); + const XMLCh* normalizedURI = fBuffer.getRawBuffer(); if (fEntityHandler){ - srcToFill = fEntityHandler->resolveEntity(XMLUni::fgZeroLenString, loc); + srcToFill = fEntityHandler->resolveEntity(XMLUni::fgZeroLenString, normalizedURI); } // If they didn't create a source via the entity resolver, then we @@ -6057,7 +6059,7 @@ try { - XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), loc); + XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), normalizedURI); if (urlTmp.isRelative()) { ThrowXML(MalformedURLException, @@ -6068,7 +6070,7 @@ } catch(const MalformedURLException&) { // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource(fSchemaInfo->getCurrentSchemaURL(),loc); + srcToFill = new LocalFileInputSource(fSchemaInfo->getCurrentSchemaURL(),normalizedURI); } } 1.13 +28 -1 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp Index: TraverseSchema.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- TraverseSchema.hpp 11 Jul 2002 18:59:57 -0000 1.12 +++ TraverseSchema.hpp 16 Aug 2002 15:46:17 -0000 1.13 @@ -690,6 +690,10 @@ void processKeyRefFor(SchemaInfo* const aSchemaInfo, ValueVectorOf<SchemaInfo*>* const infoList); + // Spaces are not allowed in URI, so %20 is used instead. + // Convert %20 to spaces before resolving the URI + void normalizeURI(const XMLCh* const systemURI, XMLBuffer& normalizedURI); + // ----------------------------------------------------------------------- // Private constants // ----------------------------------------------------------------------- @@ -921,6 +925,29 @@ for (int i=0; i < redefineCounter; i++) { newTypeName.append(SchemaSymbols::fgRedefIdentifier); + } +} + +inline void TraverseSchema::normalizeURI(const XMLCh* const systemURI, + XMLBuffer& normalizedURI) +{ + const XMLCh* pszSrc = systemURI; + + normalizedURI.reset(); + + while (*pszSrc) { + + if ((*(pszSrc) == chPercent) + && (*(pszSrc+1) == chDigit_2) + && (*(pszSrc+2) == chDigit_0)) + { + pszSrc += 3; + normalizedURI.append(chSpace); + } + else { + normalizedURI.append(*pszSrc); + pszSrc++; + } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]