peiyongz 2004/05/25 11:09:51 Modified: c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner.hpp IGXMLScanner2.cpp ReaderMgr.cpp SGXMLScanner.cpp SGXMLScanner.hpp Log: XML1.0 3rd: 4.2.2 ...Since escaping is not always a fully reversible process, it must be performed only when absolutely necessary and as late as possible in a processing chain... Revision Changes Path 1.46 +16 -5 xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp Index: DGXMLScanner.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- DGXMLScanner.cpp 27 Apr 2004 19:17:51 -0000 1.45 +++ DGXMLScanner.cpp 25 May 2004 18:09:50 -0000 1.46 @@ -66,6 +66,7 @@ #include <xercesc/util/Janitor.hpp> #include <xercesc/util/RuntimeException.hpp> #include <xercesc/util/UnexpectedEOFException.hpp> +#include <xercesc/util/XMLUri.hpp> #include <xercesc/framework/URLInputSource.hpp> #include <xercesc/framework/LocalFileInputSource.hpp> #include <xercesc/framework/XMLDocumentHandler.hpp> @@ -2488,13 +2489,17 @@ XMLBufBid bbSys(&fBufMgr); XMLBuffer& expSysId = bbSys.getBuffer(); + XMLBuffer& normalizedSysId = bbSys.getBuffer(); + XMLString::removeChar(sysId, 0xFFFF, normalizedSysId); + const XMLCh* normalizedURI = normalizedSysId.getRawBuffer(); + // Allow the entity handler to expand the system id if they choose // to do so. InputSource* srcToFill = 0; if (fEntityHandler) { - if (!fEntityHandler->expandSystemId(sysId, expSysId)) - expSysId.set(sysId); + if (!fEntityHandler->expandSystemId(normalizedURI, expSysId)) + expSysId.set(normalizedURI); XMLResourceIdentifier resourceIdentifier(XMLResourceIdentifier::ExternalEntity, expSysId.getRawBuffer()); @@ -2502,7 +2507,7 @@ } else { - expSysId.set(sysId); + expSysId.set(normalizedURI); } // If they didn't create a source via the entity handler, then we @@ -2517,12 +2522,18 @@ (urlTmp.isRelative())) { if (!fStandardUriConformant) + { + XMLBufBid ddSys(&fBufMgr); + XMLBuffer& resolvedSysId = ddSys.getBuffer(); + XMLUri::normalizeURI(expSysId.getRawBuffer(), resolvedSysId); + srcToFill = new (fMemoryManager) LocalFileInputSource ( lastInfo.systemId - , expSysId.getRawBuffer() + , resolvedSysId.getRawBuffer() , fMemoryManager ); + } else ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } 1.22 +3 -4 xml-xerces/c/src/xercesc/internal/IGXMLScanner.hpp Index: IGXMLScanner.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner.hpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- IGXMLScanner.hpp 13 Apr 2004 17:00:23 -0000 1.21 +++ IGXMLScanner.hpp 25 May 2004 18:09:50 -0000 1.22 @@ -56,6 +56,11 @@ /* * $Log$ + * Revision 1.22 2004/05/25 18:09:50 peiyongz + * XML1.0 3rd: 4.2.2 ...Since escaping is not always a fully reversible process, + * it must be performed only when absolutely necessary and as late as possible + * in a processing chain... + * * Revision 1.21 2004/04/13 17:00:23 peiyongz * IdentityConstraintHandler * @@ -228,10 +233,6 @@ // ----------------------------------------------------------------------- void commonInit(); void cleanUp(); - - // 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); unsigned int buildAttList ( 1.64 +25 -34 xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp Index: IGXMLScanner2.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- IGXMLScanner2.cpp 3 May 2004 18:50:59 -0000 1.63 +++ IGXMLScanner2.cpp 25 May 2004 18:09:50 -0000 1.64 @@ -71,6 +71,7 @@ #include <xercesc/internal/IGXMLScanner.hpp> #include <xercesc/internal/EndOfEntityException.hpp> #include <xercesc/util/UnexpectedEOFException.hpp> +#include <xercesc/util/XMLUri.hpp> #include <xercesc/framework/LocalFileInputSource.hpp> #include <xercesc/framework/URLInputSource.hpp> #include <xercesc/framework/XMLDocumentHandler.hpp> @@ -1716,7 +1717,7 @@ XMLBuffer& expSysId = bbSys.getBuffer(); XMLBuffer& normalizedSysId = bbSys.getBuffer(); - normalizeURI(loc, normalizedSysId); + XMLString::removeChar(loc, 0xFFFF, normalizedSysId); // Allow the entity handler to expand the system id if they choose // to do so. @@ -1750,12 +1751,18 @@ (urlTmp.isRelative())) { if (!fStandardUriConformant) + { + XMLBufBid ddSys(&fBufMgr); + XMLBuffer& resolvedSysId = ddSys.getBuffer(); + XMLUri::normalizeURI(expSysId.getRawBuffer(), resolvedSysId); + srcToFill = new (fMemoryManager) LocalFileInputSource ( lastInfo.systemId - , expSysId.getRawBuffer() + , resolvedSysId.getRawBuffer() , fMemoryManager ); + } else ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } @@ -1889,23 +1896,27 @@ XMLBufBid bbSys(&fBufMgr); XMLBuffer& expSysId = bbSys.getBuffer(); + XMLBuffer& normalizedSysId = bbSys.getBuffer(); + XMLString::removeChar(sysId, 0xFFFF, normalizedSysId); + const XMLCh* normalizedURI = normalizedSysId.getRawBuffer(); + // Allow the entity handler to expand the system id if they choose // to do so. InputSource* srcToFill = 0; if (fEntityHandler) { - if (!fEntityHandler->expandSystemId(sysId, expSysId)) - expSysId.set(sysId); + if (!fEntityHandler->expandSystemId(normalizedURI, expSysId)) + expSysId.set(normalizedURI); ReaderMgr::LastExtEntityInfo lastInfo; fReaderMgr.getLastExtEntityInfo(lastInfo); XMLResourceIdentifier resourceIdentifier(XMLResourceIdentifier::ExternalEntity, - expSysId.getRawBuffer(), 0, XMLUni::fgZeroLenString, lastInfo.systemId); + expSysId.getRawBuffer(), 0, XMLUni::fgZeroLenString, lastInfo.systemId); srcToFill = fEntityHandler->resolveEntity(&resourceIdentifier); } else { - expSysId.set(sysId); + expSysId.set(normalizedURI); } // If they didn't create a source via the entity handler, then we @@ -1920,12 +1931,18 @@ (urlTmp.isRelative())) { if (!fStandardUriConformant) + { + XMLBufBid ddSys(&fBufMgr); + XMLBuffer& resolvedSysId = ddSys.getBuffer(); + XMLUri::normalizeURI(expSysId.getRawBuffer(), resolvedSysId); + srcToFill = new (fMemoryManager) LocalFileInputSource ( lastInfo.systemId - , expSysId.getRawBuffer() + , resolvedSysId.getRawBuffer() , fMemoryManager ); + } else ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } @@ -3232,32 +3249,6 @@ } return anyEncountered; -} - -void IGXMLScanner::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 if (*pszSrc == 0xFFFF) { //escaped character - pszSrc++; - } - else { - normalizedURI.append(*pszSrc); - pszSrc++; - } - } } inline XMLAttDefList& getAttDefList(bool isSchemaGrammar 1.23 +27 -9 xml-xerces/c/src/xercesc/internal/ReaderMgr.cpp Index: ReaderMgr.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/ReaderMgr.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- ReaderMgr.cpp 29 Jan 2004 11:46:30 -0000 1.22 +++ ReaderMgr.cpp 25 May 2004 18:09:51 -0000 1.23 @@ -69,6 +69,7 @@ #include <xercesc/util/XMLURL.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> +#include <xercesc/util/XMLUri.hpp> #include <xercesc/sax/InputSource.hpp> #include <xercesc/framework/LocalFileInputSource.hpp> #include <xercesc/framework/URLInputSource.hpp> @@ -510,18 +511,22 @@ // Create a buffer for expanding the system id XMLBuffer expSysId(1023, fMemoryManager); + XMLBuffer& normalizedSysId = expSysId; + XMLString::removeChar(sysId, 0xFFFF, normalizedSysId); + const XMLCh* normalizedURI = normalizedSysId.getRawBuffer(); + // // Allow the entity handler to expand the system id if they choose // to do so. // if (fEntityHandler) { - if (!fEntityHandler->expandSystemId(sysId, expSysId)) - expSysId.set(sysId); + if (!fEntityHandler->expandSystemId(normalizedURI, expSysId)) + expSysId.set(normalizedURI); } else { - expSysId.set(sysId); + expSysId.set(normalizedURI); } // Call the entity resolver interface to get an input source @@ -586,12 +591,17 @@ (urlTmp.isRelative())) { if (!fStandardUriConformant) + { + XMLBuffer resolvedSysId(1023, fMemoryManager); + XMLUri::normalizeURI(expSysId.getRawBuffer(), resolvedSysId); + srcToFill = new (fMemoryManager) LocalFileInputSource ( lastInfo.systemId - , expSysId.getRawBuffer() + , resolvedSysId.getRawBuffer() , fMemoryManager ); + } else ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } @@ -647,18 +657,21 @@ // Create a buffer for expanding the system id XMLBuffer expSysId(1023, fMemoryManager); + XMLBuffer& normalizedSysId = expSysId; + XMLString::removeChar(sysId, 0xFFFF, normalizedSysId); + const XMLCh* normalizedURI = normalizedSysId.getRawBuffer(); // // Allow the entity handler to expand the system id if they choose // to do so. // if (fEntityHandler) { - if (!fEntityHandler->expandSystemId(sysId, expSysId)) - expSysId.set(sysId); + if (!fEntityHandler->expandSystemId(normalizedURI, expSysId)) + expSysId.set(normalizedURI); } else { - expSysId.set(sysId); + expSysId.set(normalizedURI); } // Call the entity resolver interface to get an input source @@ -684,12 +697,17 @@ (urlTmp.isRelative())) { if (!fStandardUriConformant) + { + XMLBuffer resolvedSysId(1023, fMemoryManager); + XMLUri::normalizeURI(expSysId.getRawBuffer(), resolvedSysId); + srcToFill = new (fMemoryManager) LocalFileInputSource ( lastInfo.systemId - , expSysId.getRawBuffer() + , resolvedSysId.getRawBuffer() , fMemoryManager ); + } else ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } 1.81 +25 -33 xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp Index: SGXMLScanner.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -u -r1.80 -r1.81 --- SGXMLScanner.cpp 3 May 2004 18:50:59 -0000 1.80 +++ SGXMLScanner.cpp 25 May 2004 18:09:51 -0000 1.81 @@ -65,6 +65,7 @@ #include <xercesc/internal/SGXMLScanner.hpp> #include <xercesc/util/RuntimeException.hpp> #include <xercesc/util/UnexpectedEOFException.hpp> +#include <xercesc/util/XMLUri.hpp> #include <xercesc/framework/LocalFileInputSource.hpp> #include <xercesc/framework/URLInputSource.hpp> #include <xercesc/framework/XMLDocumentHandler.hpp> @@ -3634,7 +3635,7 @@ XMLBuffer& expSysId = bbSys.getBuffer(); XMLBuffer& normalizedSysId = bbSys.getBuffer(); - normalizeURI(loc, normalizedSysId); + XMLString::removeChar(loc, 0xFFFF, normalizedSysId); // Allow the entity handler to expand the system id if they choose // to do so. @@ -3668,12 +3669,18 @@ (urlTmp.isRelative())) { if (!fStandardUriConformant) + { + XMLBufBid ddSys(&fBufMgr); + XMLBuffer& resolvedSysId = ddSys.getBuffer(); + XMLUri::normalizeURI(expSysId.getRawBuffer(), resolvedSysId); + srcToFill = new (fMemoryManager) LocalFileInputSource ( lastInfo.systemId - , expSysId.getRawBuffer() + , resolvedSysId.getRawBuffer() , fMemoryManager ); + } else ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } @@ -3681,6 +3688,7 @@ { if (fStandardUriConformant && urlTmp.hasInvalidChar()) ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -3785,13 +3793,17 @@ XMLBufBid bbSys(&fBufMgr); XMLBuffer& expSysId = bbSys.getBuffer(); + XMLBuffer& normalizedSysId = bbSys.getBuffer(); + XMLString::removeChar(sysId, 0xFFFF, normalizedSysId); + const XMLCh* normalizedURI = normalizedSysId.getRawBuffer(); + // Allow the entity handler to expand the system id if they choose // to do so. InputSource* srcToFill = 0; if (fEntityHandler) { - if (!fEntityHandler->expandSystemId(sysId, expSysId)) - expSysId.set(sysId); + if (!fEntityHandler->expandSystemId(normalizedURI, expSysId)) + expSysId.set(normalizedURI); ReaderMgr::LastExtEntityInfo lastInfo; fReaderMgr.getLastExtEntityInfo(lastInfo); @@ -3801,7 +3813,7 @@ } else { - expSysId.set(sysId); + expSysId.set(normalizedURI); } // If they didn't create a source via the entity handler, then we @@ -3816,12 +3828,18 @@ (urlTmp.isRelative())) { if (!fStandardUriConformant) + { + XMLBufBid ddSys(&fBufMgr); + XMLBuffer& resolvedSysId = ddSys.getBuffer(); + XMLUri::normalizeURI(expSysId.getRawBuffer(), resolvedSysId); + srcToFill = new (fMemoryManager) LocalFileInputSource ( lastInfo.systemId - , expSysId.getRawBuffer() + , resolvedSysId.getRawBuffer() , fMemoryManager ); + } else ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); } @@ -4733,32 +4751,6 @@ } return anyEncountered; -} - -void SGXMLScanner::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 if (*pszSrc == 0xFFFF) { //escaped character - pszSrc++; - } - else { - normalizedURI.append(*pszSrc); - pszSrc++; - } - } } inline XMLAttDefList& getAttDefList(ComplexTypeInfo* currType, XMLElementDecl* elemDecl) 1.19 +3 -4 xml-xerces/c/src/xercesc/internal/SGXMLScanner.hpp Index: SGXMLScanner.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.hpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- SGXMLScanner.hpp 13 Apr 2004 16:56:58 -0000 1.18 +++ SGXMLScanner.hpp 25 May 2004 18:09:51 -0000 1.19 @@ -56,6 +56,11 @@ /* * $Log$ + * Revision 1.19 2004/05/25 18:09:51 peiyongz + * XML1.0 3rd: 4.2.2 ...Since escaping is not always a fully reversible process, + * it must be performed only when absolutely necessary and as late as possible + * in a processing chain... + * * Revision 1.18 2004/04/13 16:56:58 peiyongz * IdentityConstraintHandler * @@ -218,10 +223,6 @@ // ----------------------------------------------------------------------- void commonInit(); void cleanUp(); - - // 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); unsigned int buildAttList (
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]