diff --git a/src/xercesc/internal/DGXMLScanner.cpp b/src/xercesc/internal/DGXMLScanner.cpp index 8cbc99dad255a0ef64593a835acf51df70c24e8a..8e6382b89816849408c0addd829503280ca16e3e 100644 --- a/src/xercesc/internal/DGXMLScanner.cpp +++ b/src/xercesc/internal/DGXMLScanner.cpp @@ -2451,27 +2451,10 @@ InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId) ReaderMgr::LastExtEntityInfo lastInfo; fReaderMgr.getLastExtEntityInfo(lastInfo); - try - { - XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); - if (urlTmp.isRelative()) - { - ThrowXMLwithMemMgr - ( - MalformedURLException - , XMLExcepts::URL_NoProtocolPresent - , fMemoryManager - ); - } - else { - if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); - } - } - catch(const MalformedURLException& e) + XMLURL urlTmp(fMemoryManager); + if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) || + (urlTmp.isRelative())) { - // Its not a URL, so lets assume its a local file name if non-standard uri is allowed if (!fStandardUriConformant) srcToFill = new (fMemoryManager) LocalFileInputSource ( @@ -2480,8 +2463,14 @@ InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId) , fMemoryManager ); else - throw e; + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } + else + { + if (fStandardUriConformant && urlTmp.hasInvalidChar()) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); + } } return srcToFill; diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp index a24552ac01af8f53427a642be7a663f84016b6be..36178286a1f54b5bc4f5b0107ee63d34f172b5b5 100644 --- a/src/xercesc/internal/IGXMLScanner2.cpp +++ b/src/xercesc/internal/IGXMLScanner2.cpp @@ -1738,28 +1738,10 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con ReaderMgr::LastExtEntityInfo lastInfo; fReaderMgr.getLastExtEntityInfo(lastInfo); - try + XMLURL urlTmp(fMemoryManager); + if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) || + (urlTmp.isRelative())) { - XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer(), fMemoryManager); - if (urlTmp.isRelative()) - { - ThrowXMLwithMemMgr - ( - MalformedURLException - , XMLExcepts::URL_NoProtocolPresent - , fMemoryManager - ); - } - else { - if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); - } - } - - catch(const MalformedURLException& e) - { - // Its not a URL, so lets assume its a local file name if non-standard uri is allowed if (!fStandardUriConformant) srcToFill = new (fMemoryManager) LocalFileInputSource ( @@ -1768,8 +1750,14 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con , fMemoryManager ); else - throw e; + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } + else + { + if (fStandardUriConformant && urlTmp.hasInvalidChar()) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); + } } // Put a janitor on the input source @@ -1920,27 +1908,10 @@ InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId) ReaderMgr::LastExtEntityInfo lastInfo; fReaderMgr.getLastExtEntityInfo(lastInfo); - try + XMLURL urlTmp(fMemoryManager); + if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) || + (urlTmp.isRelative())) { - XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); - if (urlTmp.isRelative()) - { - ThrowXMLwithMemMgr - ( - MalformedURLException - , XMLExcepts::URL_NoProtocolPresent - , fMemoryManager - ); - } - else { - if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); - } - } - catch(const MalformedURLException& e) - { - // Its not a URL, so lets assume its a local file name if non-standard uri is allowed if (!fStandardUriConformant) srcToFill = new (fMemoryManager) LocalFileInputSource ( @@ -1949,8 +1920,14 @@ InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId) , fMemoryManager ); else - throw e; + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } + else + { + if (fStandardUriConformant && urlTmp.hasInvalidChar()) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); + } } return srcToFill; diff --git a/src/xercesc/internal/ReaderMgr.cpp b/src/xercesc/internal/ReaderMgr.cpp index afa3734dc0e69482b42b04b5fd635844b9ae8834..ef7a41bfba02c7c86e4a906ba2951957d24967d5 100644 --- a/src/xercesc/internal/ReaderMgr.cpp +++ b/src/xercesc/internal/ReaderMgr.cpp @@ -544,6 +544,10 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const sysId LastExtEntityInfo lastInfo; getLastExtEntityInfo(lastInfo); +// Keep this #if 0 block as it was exposing a threading problem on AIX. +// Got rid of the problem by changing XMLURL to not throw malformedurl +// exceptions. +#if 0 try { XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer(), fMemoryManager); @@ -576,6 +580,28 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const sysId else throw e; } +#else + XMLURL urlTmp(fMemoryManager); + if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) || + (urlTmp.isRelative())) + { + if (!fStandardUriConformant) + srcToFill = new (fMemoryManager) LocalFileInputSource + ( + lastInfo.systemId + , expSysId.getRawBuffer() + , fMemoryManager + ); + else + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + } + else + { + if (fStandardUriConformant && urlTmp.hasInvalidChar()) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); + } +#endif } // Put a janitor on the input source @@ -653,29 +679,10 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const baseURI LastExtEntityInfo lastInfo; getLastExtEntityInfo(lastInfo); - try - { - XMLURL urlTmp((!baseURI || !*baseURI) ? lastInfo.systemId : baseURI, expSysId.getRawBuffer(), fMemoryManager); - - if (urlTmp.isRelative()) - { - ThrowXMLwithMemMgr - ( - MalformedURLException - , XMLExcepts::URL_NoProtocolPresent - , fMemoryManager - ); - } - else { - if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); - } - } - - catch(const MalformedURLException& e) + XMLURL urlTmp(fMemoryManager); + if ((!urlTmp.setURL((!baseURI || !*baseURI) ? lastInfo.systemId : baseURI, expSysId.getRawBuffer(), urlTmp)) || + (urlTmp.isRelative())) { - // Its not a URL, so lets assume its a local file name if non-standard uri is allowed if (!fStandardUriConformant) srcToFill = new (fMemoryManager) LocalFileInputSource ( @@ -684,8 +691,14 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const baseURI , fMemoryManager ); else - throw e; + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } + else + { + if (fStandardUriConformant && urlTmp.hasInvalidChar()) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); + } } // Put a janitor on the input source diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp index 77337007dccb32c1ca8fc98b1f5cfae036e4408a..41f7b6fc3c9aa44660c66414b3af9d59524d7724 100644 --- a/src/xercesc/internal/SGXMLScanner.cpp +++ b/src/xercesc/internal/SGXMLScanner.cpp @@ -3769,28 +3769,10 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con ReaderMgr::LastExtEntityInfo lastInfo; fReaderMgr.getLastExtEntityInfo(lastInfo); - try + XMLURL urlTmp(fMemoryManager); + if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) || + (urlTmp.isRelative())) { - XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); - if (urlTmp.isRelative()) - { - ThrowXMLwithMemMgr - ( - MalformedURLException - , XMLExcepts::URL_NoProtocolPresent - , fMemoryManager - ); - } - else { - if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); - } - } - - catch(const MalformedURLException& e) - { - // Its not a URL, so lets assume its a local file name if non-standard uri is allowed if (!fStandardUriConformant) srcToFill = new (fMemoryManager) LocalFileInputSource ( @@ -3799,8 +3781,14 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con , fMemoryManager ); else - throw e; + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } + else + { + if (fStandardUriConformant && urlTmp.hasInvalidChar()) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); + } } // Put a janitor on the input source @@ -3929,27 +3917,10 @@ InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId) ReaderMgr::LastExtEntityInfo lastInfo; fReaderMgr.getLastExtEntityInfo(lastInfo); - try + XMLURL urlTmp(fMemoryManager); + if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) || + (urlTmp.isRelative())) { - XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); - if (urlTmp.isRelative()) - { - ThrowXMLwithMemMgr - ( - MalformedURLException - , XMLExcepts::URL_NoProtocolPresent - , fMemoryManager - ); - } - else { - if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); - } - } - catch(const MalformedURLException& e) - { - // Its not a URL, so lets assume its a local file name if non-standard uri is allowed if (!fStandardUriConformant) srcToFill = new (fMemoryManager) LocalFileInputSource ( @@ -3958,8 +3929,14 @@ InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId) , fMemoryManager ); else - throw e; + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } + else + { + if (fStandardUriConformant && urlTmp.hasInvalidChar()) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); + } } return srcToFill; diff --git a/src/xercesc/internal/XMLScanner.cpp b/src/xercesc/internal/XMLScanner.cpp index 7f962e514da6f525b7c2e30b5fb330a15ad6f7cb..9ea47919657f127b4c917cc30ff4087a706c0bf4 100644 --- a/src/xercesc/internal/XMLScanner.cpp +++ b/src/xercesc/internal/XMLScanner.cpp @@ -433,15 +433,6 @@ void XMLScanner::scanDocument( const XMLCh* const systemId) ); return; } - catch(const OutOfMemoryException&) - { - throw; - } - catch(...) - { - // Just rethrow this, since its not our problem - throw; - } Janitor<InputSource> janSrc(srcToUse); scanDocument(*srcToUse); @@ -472,28 +463,49 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId // Create a temporary URL. Since this is the primary document, // it has to be fully qualified. If not, then assume we are just // mistaking a file for a URL. - XMLURL tmpURL(systemId, fMemoryManager); - if (tmpURL.isRelative()) { + XMLURL tmpURL(fMemoryManager); + if (XMLURL::parse(systemId, tmpURL)) { + if (tmpURL.isRelative()) { + if (!fStandardUriConformant) + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); + else { + // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr + // emit the error directly + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); + fInException = true; + emitError + ( + XMLErrs::XMLException_Fatal + , e.getType() + , e.getMessage() + ); + return false; + } + } + else + { + if (fStandardUriConformant && tmpURL.hasInvalidChar()) { + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL, fMemoryManager); + fInException = true; + emitError + ( + XMLErrs::XMLException_Fatal + , e.getType() + , e.getMessage() + ); + return false; + } + srcToUse = new (fMemoryManager) URLInputSource(tmpURL, fMemoryManager); + } + } + else { if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr // emit the error directly - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); - fInException = true; - emitError - ( - XMLErrs::XMLException_Fatal - , e.getType() - , e.getMessage() - ); - return false; - } - } - else - { - if (fStandardUriConformant && tmpURL.hasInvalidChar()) { - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL, fMemoryManager); + // lazy bypass ... since all MalformedURLException are fatal, no need to check the type + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL); fInException = true; emitError ( @@ -503,25 +515,6 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId ); return false; } - srcToUse = new (fMemoryManager) URLInputSource(tmpURL, fMemoryManager); - } - } - catch(const MalformedURLException& e) - { - if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); - else { - // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr - // emit the error directly - // lazy bypass ... since all MalformedURLException are fatal, no need to check the type - fInException = true; - emitError - ( - XMLErrs::XMLException_Fatal - , e.getType() - , e.getMessage() - ); - return false; } } catch(const XMLException& excToCatch) @@ -552,15 +545,6 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId ); return false; } - catch(const OutOfMemoryException&) - { - throw; - } - catch(...) - { - // Just rethrow this, since its not our problem - throw; - } Janitor<InputSource> janSrc(srcToUse); return scanFirst(*srcToUse, toFill); @@ -1631,29 +1615,53 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId // Create a temporary URL. Since this is the primary document, // it has to be fully qualified. If not, then assume we are just // mistaking a file for a URL. - XMLURL tmpURL(systemId, fMemoryManager); - if (tmpURL.isRelative()) + XMLURL tmpURL(fMemoryManager); + + if (XMLURL::parse(systemId, tmpURL)) { + + if (tmpURL.isRelative()) + { + if (!fStandardUriConformant) + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); + else { + // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr + // emit the error directly + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); + fInException = true; + emitError + ( + XMLErrs::XMLException_Fatal + , e.getType() + , e.getMessage() + ); + return 0; + } + } + else + { + if (fStandardUriConformant && tmpURL.hasInvalidChar()) { + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL, fMemoryManager); + fInException = true; + emitError + ( + XMLErrs::XMLException_Fatal + , e.getType() + , e.getMessage() + ); + return 0; + } + srcToUse = new (fMemoryManager) URLInputSource(tmpURL, fMemoryManager); + } + } + else { if (!fStandardUriConformant) srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr // emit the error directly - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); - fInException = true; - emitError - ( - XMLErrs::XMLException_Fatal - , e.getType() - , e.getMessage() - ); - return 0; - } - } - else - { - if (fStandardUriConformant && tmpURL.hasInvalidChar()) { - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL, fMemoryManager); + // lazy bypass ... since all MalformedURLException are fatal, no need to check the type + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL); fInException = true; emitError ( @@ -1663,25 +1671,6 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId ); return 0; } - srcToUse = new (fMemoryManager) URLInputSource(tmpURL, fMemoryManager); - } - } - catch(const MalformedURLException& e) - { - if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); - else { - // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr - // emit the error directly - // lazy bypass ... since all MalformedURLException are fatal, no need to check the type - fInException = true; - emitError - ( - XMLErrs::XMLException_Fatal - , e.getType() - , e.getMessage() - ); - return 0; } } catch(const XMLException& excToCatch) @@ -1712,15 +1701,6 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId ); return 0; } - catch(const OutOfMemoryException&) - { - throw; - } - catch(...) - { - // Just rethrow this, since its not our problem - throw; - } } Janitor<InputSource> janSrc(srcToUse); diff --git a/src/xercesc/util/XMLURL.cpp b/src/xercesc/util/XMLURL.cpp index 7387093962d0b029a16d560f03995d4001de0d16..bf2ceca17b73ef8b3494f06a2d0caf548955f87f 100644 --- a/src/xercesc/util/XMLURL.cpp +++ b/src/xercesc/util/XMLURL.cpp @@ -221,8 +221,8 @@ XMLURL::XMLURL(const XMLCh* const baseURL , fHasInvalidChar(false) { try - { - setURL(baseURL, relativeURL); + { + setURL(baseURL, relativeURL); } catch(const OutOfMemoryException&) { @@ -424,6 +424,7 @@ XMLURL::XMLURL(const XMLURL& toCopy) : catch(...) { cleanup(); + throw; } } @@ -539,6 +540,35 @@ void XMLURL::setURL(const XMLCh* const baseURL } } +// this version of setURL doesn't throw a malformedurl exception +// instead it returns false when it failed (or when it would of +// thrown a malformedurl exception) +bool XMLURL::setURL(const XMLCh* const baseURL + , const XMLCh* const relativeURL + , XMLURL& xmlURL) +{ + cleanup(); + + // Parse our URL string + if (parse(relativeURL, xmlURL)) + { + // If its relative and the base is non-null and non-empty, then + // parse the base URL string and conglomerate them. + // + if (isRelative() && baseURL && *baseURL) + { + XMLURL basePart(fMemoryManager); + if (parse(baseURL, basePart) && conglomerateWithBase(basePart, false)) + { + return true; + } + } + else + return true; + } + return false; +} + void XMLURL::setURL(const XMLURL& baseURL , const XMLCh* const relativeURL) { diff --git a/src/xercesc/util/XMLURL.hpp b/src/xercesc/util/XMLURL.hpp index 2faaa46229bf8470274da41596e054a2e26993a4..47ae27c370f65e4e7d60780ebe6cbb0ddafd6d9d 100644 --- a/src/xercesc/util/XMLURL.hpp +++ b/src/xercesc/util/XMLURL.hpp @@ -175,8 +175,11 @@ public: const XMLURL& baseURL , const XMLCh* const relativeURL ); - - + // a version of setURL that doesn't throw malformed url exceptions + bool setURL( + const XMLCh* const baseURL + , const XMLCh* const relativeURL + , XMLURL& xmlURL); // ----------------------------------------------------------------------- // Miscellaneous methods // ----------------------------------------------------------------------- diff --git a/src/xercesc/validators/schema/TraverseSchema.cpp b/src/xercesc/validators/schema/TraverseSchema.cpp index 08bcfb003b63b8d3ae9da7947933846d20f60cfb..44cc01ac7e71b6e4b6f0d29e7181f7945ebf0c49 100644 --- a/src/xercesc/validators/schema/TraverseSchema.cpp +++ b/src/xercesc/validators/schema/TraverseSchema.cpp @@ -6448,28 +6448,25 @@ InputSource* TraverseSchema::resolveSchemaLocation(const XMLCh* const loc, // the update resolveEntity accepting nameSpace, a schemImport could // pass a null schemaLocation) if (!srcToFill && loc) { - - try { - - XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), normalizedURI, fMemoryManager); - - if (urlTmp.isRelative()) { - ThrowXMLwithMemMgr(MalformedURLException, - XMLExcepts::URL_NoProtocolPresent, fMemoryManager); - } - else { - if (fScanner->getStandardUriConformant() && urlTmp.hasInvalidChar()) - ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); - } - } - catch(const MalformedURLException& e) { - // Its not a URL, so lets assume its a local file name if non-standard URI is allowed - if (!fScanner->getStandardUriConformant()) - srcToFill = new (fMemoryManager) LocalFileInputSource(fSchemaInfo->getCurrentSchemaURL(),normalizedURI, fMemoryManager); + XMLURL urlTmp(fMemoryManager); + if ((!urlTmp.setURL(fSchemaInfo->getCurrentSchemaURL(), normalizedURI, urlTmp)) || + (urlTmp.isRelative())) + { + if (!fScanner->getStandardUriConformant()) + srcToFill = new (fMemoryManager) LocalFileInputSource + ( fSchemaInfo->getCurrentSchemaURL() + , normalizedURI + , fMemoryManager + ); else - throw e; + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } + else + { + if (fScanner->getStandardUriConformant() && urlTmp.hasInvalidChar()) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); + } } return srcToFill;