tng 2003/01/03 12:08:40 Modified: c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner2.cpp ReaderMgr.cpp ReaderMgr.hpp SGXMLScanner.cpp XMLScanner.cpp XMLScanner.hpp Log: New feature StandardUriConformant to force strict standard uri conformance. Revision Changes Path 1.4 +11 -8 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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DGXMLScanner.cpp 24 Dec 2002 16:11:39 -0000 1.3 +++ DGXMLScanner.cpp 3 Jan 2003 20:08:39 -0000 1.4 @@ -2272,14 +2272,17 @@ } srcToFill = new URLInputSource(urlTmp); } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource - ( - lastInfo.systemId - , expSysId.getRawBuffer() - ); + // Its not a URL, so lets assume its a local file name if non-standard uri is allowed + if (!fStandardUriConformant) + srcToFill = new LocalFileInputSource + ( + lastInfo.systemId + , expSysId.getRawBuffer() + ); + else + throw e; } } 1.6 +21 -15 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- IGXMLScanner2.cpp 24 Dec 2002 16:11:39 -0000 1.5 +++ IGXMLScanner2.cpp 3 Jan 2003 20:08:39 -0000 1.6 @@ -1273,14 +1273,17 @@ srcToFill = new URLInputSource(urlTmp); } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource - ( - lastInfo.systemId - , expSysId.getRawBuffer() - ); + // Its not a URL, so lets assume its a local file name if non-standard uri is allowed + if (!fStandardUriConformant) + srcToFill = new LocalFileInputSource + ( + lastInfo.systemId + , expSysId.getRawBuffer() + ); + else + throw e; } } @@ -1422,14 +1425,17 @@ } srcToFill = new URLInputSource(urlTmp); } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource - ( - lastInfo.systemId - , expSysId.getRawBuffer() - ); + // Its not a URL, so lets assume its a local file name if non-standard uri is allowed + if (!fStandardUriConformant) + srcToFill = new LocalFileInputSource + ( + lastInfo.systemId + , expSysId.getRawBuffer() + ); + else + throw e; } } 1.10 +22 -15 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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ReaderMgr.cpp 20 Dec 2002 22:09:56 -0000 1.9 +++ ReaderMgr.cpp 3 Jan 2003 20:08:39 -0000 1.10 @@ -94,6 +94,7 @@ , fReaderStack(0) , fThrowEOE(false) , fXMLVersion(XMLReader::XMLV1_0) + , fStandardUriConformant(false) { } @@ -549,14 +550,17 @@ srcToFill = new URLInputSource(urlTmp); } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource - ( - lastInfo.systemId - , expSysId.getRawBuffer() - ); + // Its not a URL, so lets assume its a local file name if non-standard uri is allowed + if (!fStandardUriConformant) + srcToFill = new LocalFileInputSource + ( + lastInfo.systemId + , expSysId.getRawBuffer() + ); + else + throw e; } } @@ -652,14 +656,17 @@ srcToFill = new URLInputSource(urlTmp); } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource - ( - lastInfo.systemId - , expSysId.getRawBuffer() - ); + // Its not a URL, so lets assume its a local file name if non-standard uri is allowed + if (!fStandardUriConformant) + srcToFill = new LocalFileInputSource + ( + lastInfo.systemId + , expSysId.getRawBuffer() + ); + else + throw e; } } 1.7 +13 -0 xml-xerces/c/src/xercesc/internal/ReaderMgr.hpp Index: ReaderMgr.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/ReaderMgr.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ReaderMgr.hpp 20 Dec 2002 22:09:56 -0000 1.6 +++ ReaderMgr.hpp 3 Jan 2003 20:08:39 -0000 1.7 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/01/03 20:08:39 tng + * New feature StandardUriConformant to force strict standard uri conformance. + * * Revision 1.6 2002/12/20 22:09:56 tng * XML 1.1 * @@ -289,6 +292,7 @@ void setEntityHandler(XMLEntityHandler* const newHandler); void setThrowEOE(const bool newValue); void setXMLVersion(const XMLReader::XMLVersion version); + void setStandardUriConformant(const bool newValue); // ----------------------------------------------------------------------- // Implement the SAX Locator interface @@ -347,6 +351,9 @@ // fXMLVersion // Enum to indicate if each Reader should be created as XML 1.1 or // XML 1.0 conformant + // + // fStandardUriConformant + // This flag controls whether we force conformant URI // ----------------------------------------------------------------------- XMLEntityDecl* fCurEntity; XMLReader* fCurReader; @@ -356,6 +363,7 @@ RefStackOf<XMLReader>* fReaderStack; bool fThrowEOE; XMLReader::XMLVersion fXMLVersion; + bool fStandardUriConformant; }; @@ -418,6 +426,11 @@ inline void ReaderMgr::setThrowEOE(const bool newValue) { fThrowEOE = newValue; +} + +inline void ReaderMgr::setStandardUriConformant(const bool newValue) +{ + fStandardUriConformant = newValue; } inline bool ReaderMgr::skippedString(const XMLCh* const toSkip) 1.6 +21 -15 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SGXMLScanner.cpp 24 Dec 2002 16:11:39 -0000 1.5 +++ SGXMLScanner.cpp 3 Jan 2003 20:08:39 -0000 1.6 @@ -2986,14 +2986,17 @@ srcToFill = new URLInputSource(urlTmp); } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource - ( - lastInfo.systemId - , expSysId.getRawBuffer() - ); + // Its not a URL, so lets assume its a local file name if non-standard uri is allowed + if (!fStandardUriConformant) + srcToFill = new LocalFileInputSource + ( + lastInfo.systemId + , expSysId.getRawBuffer() + ); + else + throw e; } } @@ -3112,14 +3115,17 @@ } srcToFill = new URLInputSource(urlTmp); } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource - ( - lastInfo.systemId - , expSysId.getRawBuffer() - ); + // Its not a URL, so lets assume its a local file name if non-standard uri is allowed + if (!fStandardUriConformant) + srcToFill = new LocalFileInputSource + ( + lastInfo.systemId + , expSysId.getRawBuffer() + ); + else + throw e; } } 1.35 +125 -10 xml-xerces/c/src/xercesc/internal/XMLScanner.cpp Index: XMLScanner.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- XMLScanner.cpp 30 Dec 2002 20:15:51 -0000 1.34 +++ XMLScanner.cpp 3 Jan 2003 20:08:39 -0000 1.35 @@ -189,6 +189,7 @@ , fRootElemName(0) , fExternalSchemaLocation(0) , fExternalNoNamespaceSchemaLocation(0) + , fStandardUriConformant(false) { commonInit(); @@ -243,6 +244,7 @@ , fRootElemName(0) , fExternalSchemaLocation(0) , fExternalNoNamespaceSchemaLocation(0) + , fStandardUriConformant(false) { commonInit(); @@ -288,7 +290,21 @@ // mistaking a file for a URL. XMLURL tmpURL(systemId); if (tmpURL.isRelative()) { - srcToUse = new LocalFileInputSource(systemId); + if (!fStandardUriConformant) + srcToUse = new LocalFileInputSource(systemId); + else { + // since this is the top of the try/catch, cannot call ThrowXML + // emit the error directly + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent); + fInException = true; + emitError + ( + XMLErrs::XMLException_Fatal + , e.getType() + , e.getMessage() + ); + return; + } } else { @@ -296,9 +312,23 @@ } } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - srcToUse = new LocalFileInputSource(systemId); + if (!fStandardUriConformant) + srcToUse = new LocalFileInputSource(systemId); + else { + // since this is the top of the try/catch, cannot call ThrowXML + // 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; + } } catch(const XMLException& excToCatch) @@ -366,16 +396,44 @@ // mistaking a file for a URL. XMLURL tmpURL(systemId); if (tmpURL.isRelative()) { - srcToUse = new LocalFileInputSource(systemId); + if (!fStandardUriConformant) + srcToUse = new LocalFileInputSource(systemId); + else { + // since this is the top of the try/catch, cannot call ThrowXML + // emit the error directly + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent); + fInException = true; + emitError + ( + XMLErrs::XMLException_Fatal + , e.getType() + , e.getMessage() + ); + return false; + } } else { srcToUse = new URLInputSource(tmpURL); } } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - srcToUse = new LocalFileInputSource(systemId); + if (!fStandardUriConformant) + srcToUse = new LocalFileInputSource(systemId); + else { + // since this is the top of the try/catch, cannot call ThrowXML + // 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) { @@ -550,6 +608,7 @@ setDoNamespaces(refScanner->getDoNamespaces()); setDoSchema(refScanner->getDoSchema()); setCalculateSrcOfs(refScanner->getCalculateSrcOfs()); + setStandardUriConformant(refScanner->getStandardUriConformant()); setExitOnFirstFatal(refScanner->getExitOnFirstFatal()); setValidationConstraintFatal(refScanner->getValidationConstraintFatal()); setValidationSchemaFullChecking(refScanner->getValidationSchemaFullChecking()); @@ -1458,16 +1517,72 @@ XMLURL tmpURL(systemId); if (tmpURL.isRelative()) { - srcToUse = new LocalFileInputSource(systemId); + if (!fStandardUriConformant) + srcToUse = new LocalFileInputSource(systemId); + else { + // since this is the top of the try/catch, cannot call ThrowXML + // emit the error directly + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent); + fInException = true; + emitError + ( + XMLErrs::XMLException_Fatal + , e.getType() + , e.getMessage() + ); + return 0; + } } else { srcToUse = new URLInputSource(tmpURL); } } - catch(const MalformedURLException&) + catch(const MalformedURLException& e) { - srcToUse = new LocalFileInputSource(systemId); + if (!fStandardUriConformant) + srcToUse = new LocalFileInputSource(systemId); + else { + // since this is the top of the try/catch, cannot call ThrowXML + // 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) + { + // For any other XMLException, + // emit the error and catch any user exception thrown from here. + fInException = true; + if (excToCatch.getErrorType() == XMLErrorReporter::ErrType_Warning) + emitError + ( + XMLErrs::XMLException_Warning + , excToCatch.getType() + , excToCatch.getMessage() + ); + else if (excToCatch.getErrorType() >= XMLErrorReporter::ErrType_Fatal) + emitError + ( + XMLErrs::XMLException_Fatal + , excToCatch.getType() + , excToCatch.getMessage() + ); + else + emitError + ( + XMLErrs::XMLException_Error + , excToCatch.getType() + , excToCatch.getMessage() + ); + return 0; } catch(...) { 1.16 +25 -1 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.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- XMLScanner.hpp 27 Dec 2002 16:16:51 -0000 1.15 +++ XMLScanner.hpp 3 Jan 2003 20:08:40 -0000 1.16 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.16 2003/01/03 20:08:40 tng + * New feature StandardUriConformant to force strict standard uri conformance. + * * Revision 1.15 2002/12/27 16:16:51 knoaman * Set scanner options and handlers. * @@ -503,6 +506,8 @@ /* tell if the validator comes from user */ bool isValidatorFromUser(); + /* tell if standard URI are forced */ + bool getStandardUriConformant() const; // ----------------------------------------------------------------------- // Setter methods @@ -533,6 +538,7 @@ void setNormalizeData(const bool normalizeData); void setCalculateSrcOfs(const bool newValue); void setParseSettings(XMLScanner* const refScanner); + void setStandardUriConformant(const bool newValue); // ----------------------------------------------------------------------- // Mutator methods @@ -583,7 +589,7 @@ // ----------------------------------------------------------------------- // Grammar preparsing methods - // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- Grammar* loadGrammar ( const XMLCh* const systemId @@ -819,7 +825,14 @@ // This flag indicates whether the parser should perform datatype // normalization that is defined in the schema. // + // fCalculateSrcOfs + // This flag indicates the parser should calculate the source offset. + // Turning this on may impact performance. + // + // fStandardUriConformant + // This flag controls whether we force conformant URI // ----------------------------------------------------------------------- + bool fStandardUriConformant; bool fCalculateSrcOfs; bool fDoNamespaces; bool fExitOnFirstFatal; @@ -1105,6 +1118,11 @@ return fRootGrammar; } +inline bool XMLScanner::getStandardUriConformant() const +{ + return fStandardUriConformant; +} + // --------------------------------------------------------------------------- // XMLScanner: Setter methods // --------------------------------------------------------------------------- @@ -1235,6 +1253,12 @@ inline void XMLScanner::setCalculateSrcOfs(const bool newValue) { fCalculateSrcOfs = newValue; +} + +inline void XMLScanner::setStandardUriConformant(const bool newValue) +{ + fStandardUriConformant = newValue; + fReaderMgr.setStandardUriConformant(newValue); } // ---------------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]