diff --git a/src/xercesc/internal/XMLScanner.hpp b/src/xercesc/internal/XMLScanner.hpp index 000afcc38018b76b4136ca917cd47668b75524cc..663e74a958d6ce6aea77dcac44ccfcc5e24ef5ab 100644 --- a/src/xercesc/internal/XMLScanner.hpp +++ b/src/xercesc/internal/XMLScanner.hpp @@ -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 @@ private : 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 diff --git a/src/xercesc/internal/XMLScanner2.cpp b/src/xercesc/internal/XMLScanner2.cpp index aa23da49b9d047a7baa46b20d50d71ad87dd6151..2fb2d3b708e39a00d8320026258e0797ccde8b6f 100644 --- a/src/xercesc/internal/XMLScanner2.cpp +++ b/src/xercesc/internal/XMLScanner2.cpp @@ -1421,23 +1421,27 @@ void XMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* const // 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 @@ bool XMLScanner::anyAttributeValidation(SchemaAttDef* attWildCard, unsigned int 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++; + } + } +} diff --git a/src/xercesc/validators/schema/TraverseSchema.cpp b/src/xercesc/validators/schema/TraverseSchema.cpp index 90a3952efefad9d8ff324abd578897cb12166c06..2b54a80e06e5ac50069080e96fbb3f9d2b874516 100644 --- a/src/xercesc/validators/schema/TraverseSchema.cpp +++ b/src/xercesc/validators/schema/TraverseSchema.cpp @@ -6046,9 +6046,11 @@ InputSource* TraverseSchema::resolveSchemaLocation(const XMLCh* const loc) { // 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 @@ InputSource* TraverseSchema::resolveSchemaLocation(const XMLCh* const loc) { try { - XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), loc); + XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), normalizedURI); if (urlTmp.isRelative()) { ThrowXML(MalformedURLException, @@ -6068,7 +6070,7 @@ InputSource* TraverseSchema::resolveSchemaLocation(const XMLCh* const loc) { } 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); } } diff --git a/src/xercesc/validators/schema/TraverseSchema.hpp b/src/xercesc/validators/schema/TraverseSchema.hpp index 310e33e195e28bb7364198c85f46c554ba77f366..e3fc580ffaf5338d5d9244ed6a6b9a18c616c7a9 100644 --- a/src/xercesc/validators/schema/TraverseSchema.hpp +++ b/src/xercesc/validators/schema/TraverseSchema.hpp @@ -690,6 +690,10 @@ private: 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 // ----------------------------------------------------------------------- @@ -924,6 +928,29 @@ inline void TraverseSchema::getRedefineNewTypeName(const XMLCh* const oldTypeNam } } +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++; + } + } +} + #endif /**