From 9ac9f8ecf8a9e8720deb3b10329a66faaad0e9c9 Mon Sep 17 00:00:00 2001 From: Tinny Ng <tng@apache.org> Date: Mon, 9 Jul 2001 13:42:20 +0000 Subject: [PATCH] Partial Markup in Parameter Entity is validity constraint and thus should be just error, not fatal error. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@172857 13f79535-47bb-0310-9956-ffa450edef68 --- src/NLS/EN_US/XMLErrList_EN_US.Xml | 1 + src/framework/XMLValidityCodes.hpp | 11 ++-- src/internal/XMLScanner.cpp | 4 +- src/internal/XMLScanner.hpp | 9 +++ src/internal/XMLScanner2.cpp | 4 +- .../MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp | 3 +- .../MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg | 1 + src/util/Platforms/Win32/Version.rc | 3 + src/validators/DTD/DTDScanner.cpp | 56 +++++++++++++------ 9 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/NLS/EN_US/XMLErrList_EN_US.Xml b/src/NLS/EN_US/XMLErrList_EN_US.Xml index e375ef7bf..21128a874 100644 --- a/src/NLS/EN_US/XMLErrList_EN_US.Xml +++ b/src/NLS/EN_US/XMLErrList_EN_US.Xml @@ -325,6 +325,7 @@ <Message Id="NoAttNormForStandalone" Text="Attribute '{0}' must not be changed by normalization in a standalone document."/> <Message Id="NoWSForStandalone" Text="White space must not occur between externally declared elements with element content in a standalone document."/> <Message Id="VC_EntityNotFound" Text="Entity '{0}' was not found"/> + <Message Id="PartialMarkupInPE" Text="Partial markup in parameter entity replacement text."/> </Error> </MsgDomain> <MsgDomain Domain="http://apache.org/xml/messages/XML4CErrors"> diff --git a/src/framework/XMLValidityCodes.hpp b/src/framework/XMLValidityCodes.hpp index 9345ea863..d7b5ae54e 100644 --- a/src/framework/XMLValidityCodes.hpp +++ b/src/framework/XMLValidityCodes.hpp @@ -97,11 +97,12 @@ public : , NoAttNormForStandalone = 84 , NoWSForStandalone = 85 , VC_EntityNotFound = 86 - , E_HighBounds = 87 - , W_LowBounds = 88 - , W_HighBounds = 89 - , F_LowBounds = 90 - , F_HighBounds = 91 + , PartialMarkupInPE = 87 + , E_HighBounds = 88 + , W_LowBounds = 89 + , W_HighBounds = 90 + , F_LowBounds = 91 + , F_HighBounds = 92 }; static bool isFatal(const XMLValid::Codes toCheck) diff --git a/src/internal/XMLScanner.cpp b/src/internal/XMLScanner.cpp index 8bcbe35e2..2c6bc2d84 100644 --- a/src/internal/XMLScanner.cpp +++ b/src/internal/XMLScanner.cpp @@ -2849,7 +2849,7 @@ bool XMLScanner::scanStartTagNS(bool& gotData) ); } - if (elemDecl) { + if (elemDecl && fValidate) { fValidator->emitError ( XMLValid::ElementNotUnQualified @@ -2896,7 +2896,7 @@ bool XMLScanner::scanStartTagNS(bool& gotData) , currentScope ); - if (elemDecl) { + if (elemDecl && fValidate) { fValidator->emitError ( XMLValid::ElementNotQualified diff --git a/src/internal/XMLScanner.hpp b/src/internal/XMLScanner.hpp index 9a6f9a7b0..d19998e22 100644 --- a/src/internal/XMLScanner.hpp +++ b/src/internal/XMLScanner.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.24 2001/07/09 13:42:08 tng + * Partial Markup in Parameter Entity is validity constraint and thus should be just error, not fatal error. + * * Revision 1.23 2001/07/05 13:12:11 tng * Standalone checking is validity constraint and thus should be just error, not fatal error: * @@ -326,6 +329,7 @@ public : NameIdPoolEnumerator<DTDEntityDecl> getEntityEnumerator() const; const XMLStringPool* getURIStringPool() const; XMLStringPool* getURIStringPool(); + bool getHasNoDTD() const; // ----------------------------------------------------------------------- // Getter methods @@ -1001,6 +1005,11 @@ inline XMLStringPool* XMLScanner::getURIStringPool() return fURIStringPool; } +inline bool XMLScanner::getHasNoDTD() const +{ + return fHasNoDTD; +} + // --------------------------------------------------------------------------- // XMLScanner: Setter methods // --------------------------------------------------------------------------- diff --git a/src/internal/XMLScanner2.cpp b/src/internal/XMLScanner2.cpp index c5a533099..81c91bd1b 100644 --- a/src/internal/XMLScanner2.cpp +++ b/src/internal/XMLScanner2.cpp @@ -488,7 +488,7 @@ XMLScanner::buildAttList(const RefVectorOf<KVStringPair>& providedAttrs { //attribute is provided // (schema) report error for PROHIBITED attrs that are present (V_TAGc) - if (defType == XMLAttDef::Prohibited) + if (defType == XMLAttDef::Prohibited && fValidate) fValidator->emitError ( XMLValid::ProhibitedAttributePresent @@ -520,7 +520,7 @@ void XMLScanner::checkIDRefs() const XMLRefInfo& curRef = refEnum.nextElement(); // If its used but not declared, then its an error - if (!curRef.getDeclared() && curRef.getUsed()) + if (!curRef.getDeclared() && curRef.getUsed() && fValidate) fValidator->emitError(XMLValid::IDNotDeclared, curRef.getRefName()); } } diff --git a/src/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp b/src/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp index b843195c9..c0456bcef 100644 --- a/src/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp +++ b/src/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp @@ -327,10 +327,11 @@ const XMLCh gXMLValidityArray[][128] = , { 0x0041,0x0074,0x0074,0x0072,0x0069,0x0062,0x0075,0x0074,0x0065,0x0020,0x0027,0x007B,0x0030,0x007D,0x0027,0x0020,0x006D,0x0075,0x0073,0x0074,0x0020,0x006E,0x006F,0x0074,0x0020,0x0062,0x0065,0x0020,0x0063,0x0068,0x0061,0x006E,0x0067,0x0065,0x0064,0x0020,0x0062,0x0079,0x0020,0x006E,0x006F,0x0072,0x006D,0x0061,0x006C,0x0069,0x007A,0x0061,0x0074,0x0069,0x006F,0x006E,0x0020,0x0069,0x006E,0x0020,0x0061,0x0020,0x0073,0x0074,0x0061,0x006E,0x0064,0x0061,0x006C,0x006F,0x006E,0x0065,0x0020,0x0064,0x006F,0x0063,0x0075,0x006D,0x0065,0x006E,0x0074,0x002E,0x00 } , { 0x0057,0x0068,0x0069,0x0074,0x0065,0x0020,0x0073,0x0070,0x0061,0x0063,0x0065,0x0020,0x006D,0x0075,0x0073,0x0074,0x0020,0x006E,0x006F,0x0074,0x0020,0x006F,0x0063,0x0063,0x0075,0x0072,0x0020,0x0062,0x0065,0x0074,0x0077,0x0065,0x0065,0x006E,0x0020,0x0065,0x0078,0x0074,0x0065,0x0072,0x006E,0x0061,0x006C,0x006C,0x0079,0x0020,0x0064,0x0065,0x0063,0x006C,0x0061,0x0072,0x0065,0x0064,0x0020,0x0065,0x006C,0x0065,0x006D,0x0065,0x006E,0x0074,0x0073,0x0020,0x0077,0x0069,0x0074,0x0068,0x0020,0x0065,0x006C,0x0065,0x006D,0x0065,0x006E,0x0074,0x0020,0x0063,0x006F,0x006E,0x0074,0x0065,0x006E,0x0074,0x0020,0x0069,0x006E,0x0020,0x0061,0x0020,0x0073,0x0074,0x0061,0x006E,0x0064,0x0061,0x006C,0x006F,0x006E,0x0065,0x0020,0x0064,0x006F,0x0063,0x0075,0x006D,0x0065,0x006E,0x0074,0x002E,0x00 } , { 0x0045,0x006E,0x0074,0x0069,0x0074,0x0079,0x0020,0x0027,0x007B,0x0030,0x007D,0x0027,0x0020,0x0077,0x0061,0x0073,0x0020,0x006E,0x006F,0x0074,0x0020,0x0066,0x006F,0x0075,0x006E,0x0064,0x00 } + , { 0x0050,0x0061,0x0072,0x0074,0x0069,0x0061,0x006C,0x0020,0x006D,0x0061,0x0072,0x006B,0x0075,0x0070,0x0020,0x0069,0x006E,0x0020,0x0070,0x0061,0x0072,0x0061,0x006D,0x0065,0x0074,0x0065,0x0072,0x0020,0x0065,0x006E,0x0074,0x0069,0x0074,0x0079,0x0020,0x0072,0x0065,0x0070,0x006C,0x0061,0x0063,0x0065,0x006D,0x0065,0x006E,0x0074,0x0020,0x0074,0x0065,0x0078,0x0074,0x002E,0x00 } , { 0x0045,0x005F,0x0045,0x006E,0x0064,0x00 } }; -const unsigned int gXMLValidityArraySize = 92; +const unsigned int gXMLValidityArraySize = 93; const XMLCh gXMLExceptArray[][128] = { diff --git a/src/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg b/src/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg index 777b20722..511c3de92 100644 --- a/src/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg +++ b/src/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg @@ -312,6 +312,7 @@ $set 2 84 Attribute '{0}' must not be changed by normalization in a standalone document. 85 White space must not occur between externally declared elements with element content in a standalone document. 86 Entity '{0}' was not found + 87 Partial markup in parameter entity replacement text. $set 3 diff --git a/src/util/Platforms/Win32/Version.rc b/src/util/Platforms/Win32/Version.rc index 01ba63c9e..910497cab 100644 --- a/src/util/Platforms/Win32/Version.rc +++ b/src/util/Platforms/Win32/Version.rc @@ -102,6 +102,8 @@ END + + // ---------------------------------------------------------------- // This file was generated from the XML error message source. // so do not edit this file directly!! @@ -421,6 +423,7 @@ BEGIN 16468 L"\x0041\x0074\x0074\x0072\x0069\x0062\x0075\x0074\x0065\x0020\x0027\x007B\x0030\x007D\x0027\x0020\x006D\x0075\x0073\x0074\x0020\x006E\x006F\x0074\x0020\x0062\x0065\x0020\x0063\x0068\x0061\x006E\x0067\x0065\x0064\x0020\x0062\x0079\x0020\x006E\x006F\x0072\x006D\x0061\x006C\x0069\x007A\x0061\x0074\x0069\x006F\x006E\x0020\x0069\x006E\x0020\x0061\x0020\x0073\x0074\x0061\x006E\x0064\x0061\x006C\x006F\x006E\x0065\x0020\x0064\x006F\x0063\x0075\x006D\x0065\x006E\x0074\x002E\x00" 16469 L"\x0057\x0068\x0069\x0074\x0065\x0020\x0073\x0070\x0061\x0063\x0065\x0020\x006D\x0075\x0073\x0074\x0020\x006E\x006F\x0074\x0020\x006F\x0063\x0063\x0075\x0072\x0020\x0062\x0065\x0074\x0077\x0065\x0065\x006E\x0020\x0065\x0078\x0074\x0065\x0072\x006E\x0061\x006C\x006C\x0079\x0020\x0064\x0065\x0063\x006C\x0061\x0072\x0065\x0064\x0020\x0065\x006C\x0065\x006D\x0065\x006E\x0074\x0073\x0020\x0077\x0069\x0074\x0068\x0020\x0065\x006C\x0065\x006D\x0065\x006E\x0074\x0020\x0063\x006F\x006E\x0074\x0065\x006E\x0074\x0020\x0069\x006E\x0020\x0061\x0020\x0073\x0074\x0061\x006E\x0064\x0061\x006C\x006F\x006E\x0065\x0020\x0064\x006F\x0063\x0075\x006D\x0065\x006E\x0074\x002E\x00" 16470 L"\x0045\x006E\x0074\x0069\x0074\x0079\x0020\x0027\x007B\x0030\x007D\x0027\x0020\x0077\x0061\x0073\x0020\x006E\x006F\x0074\x0020\x0066\x006F\x0075\x006E\x0064\x00" + 16471 L"\x0050\x0061\x0072\x0074\x0069\x0061\x006C\x0020\x006D\x0061\x0072\x006B\x0075\x0070\x0020\x0069\x006E\x0020\x0070\x0061\x0072\x0061\x006D\x0065\x0074\x0065\x0072\x0020\x0065\x006E\x0074\x0069\x0074\x0079\x0020\x0072\x0065\x0070\x006C\x0061\x0063\x0065\x006D\x0065\x006E\x0074\x0020\x0074\x0065\x0078\x0074\x002E\x00" END STRINGTABLE DISCARDABLE BEGIN diff --git a/src/validators/DTD/DTDScanner.cpp b/src/validators/DTD/DTDScanner.cpp index 17c46d534..83939703f 100644 --- a/src/validators/DTD/DTDScanner.cpp +++ b/src/validators/DTD/DTDScanner.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2001/07/09 13:42:20 tng + * Partial Markup in Parameter Entity is validity constraint and thus should be just error, not fatal error. + * * Revision 1.13 2001/07/05 14:05:29 tng * Encoding String must present for external entity text decl. * @@ -260,10 +263,19 @@ bool DTDScanner::expandPERef( const bool scanExternal // emit an error and continue. // XMLEntityDecl* decl = fPEntityDeclPool->getByKey(bbName.getRawBuffer()); - if (!decl && fScanner->getDoValidation()) + if (!decl) { // XML 1.0 Section 4.1 - fScanner->getValidator()->emitError(XMLValid::VC_EntityNotFound, bbName.getRawBuffer()); + if (fScanner->getStandalone()) { + // no need to check fScanner->fHasNoDTD which is for sure false + // since we are in expandPERef already + fScanner->emitError(XMLErrs::EntityNotFound, bbName.getRawBuffer()); + } + else { + if (fScanner->getDoValidation()) + fScanner->getValidator()->emitError(XMLValid::VC_EntityNotFound, bbName.getRawBuffer()); + } + return false; } @@ -1064,8 +1076,8 @@ DTDScanner::scanChildren(const DTDElementDecl& elemDecl, XMLBuffer& bufToUse) if (!curNode) return 0; - if (curReader != fReaderMgr->getCurrentReaderNum()) - fScanner->emitError(XMLErrs::PartialMarkupInEntity); + if (curReader != fReaderMgr->getCurrentReaderNum() && fScanner->getDoValidation()) + fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); } else { @@ -1218,8 +1230,8 @@ DTDScanner::scanChildren(const DTDElementDecl& elemDecl, XMLBuffer& bufToUse) return 0; } - if (curReader != fReaderMgr->getCurrentReaderNum()) - fScanner->emitError(XMLErrs::PartialMarkupInEntity); + if (curReader != fReaderMgr->getCurrentReaderNum() && fScanner->getDoValidation()) + fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); // Else patch it in and make it the new current ContentSpecNode* newCur = new ContentSpecNode @@ -1490,8 +1502,8 @@ bool DTDScanner::scanContentSpec(DTDElementDecl& toFill) } // Make sure we are on the same reader as where we started - if (curReader != fReaderMgr->getCurrentReaderNum()) - fScanner->emitError(XMLErrs::PartialMarkupInEntity); + if (curReader != fReaderMgr->getCurrentReaderNum() && fScanner->getDoValidation()) + fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); return status; } @@ -2103,10 +2115,17 @@ DTDScanner::scanEntityRef(XMLCh& firstCh, XMLCh& secondCh, bool& escaped) XMLEntityDecl* decl = fEntityDeclPool->getByKey(bbName.getRawBuffer()); // If it does not exist, then obviously an error - if (!decl && fScanner->getDoValidation()) + if (!decl) { // XML 1.0 Section 4.1 - fScanner->getValidator()->emitError(XMLValid::VC_EntityNotFound, bbName.getRawBuffer()); + if (fScanner->getStandalone() || fScanner->getHasNoDTD()) { + fScanner->emitError(XMLErrs::EntityNotFound, bbName.getRawBuffer()); + } + else { + if (fScanner->getDoValidation()) + fScanner->getValidator()->emitError(XMLValid::VC_EntityNotFound, bbName.getRawBuffer()); + } + return EntityExp_Failed; } @@ -2132,13 +2151,15 @@ DTDScanner::scanEntityRef(XMLCh& firstCh, XMLCh& secondCh, bool& escaped) if (decl->isExternal()) { // If its unparsed, then its not valid here + // XML 1.0 Section 4.4.4 the appearance of a reference to an unparsed entity is forbidden. if (decl->isUnparsed()) { fScanner->emitError(XMLErrs::NoUnparsedEntityRefs, bbName.getRawBuffer()); return EntityExp_Failed; } - // We are in an attribute value, so not valid. But keep going + // We are in an attribute value, so not valid. + // XML 1.0 Section 4.4.4 a reference to an external entity in an attribute value is forbidden. fScanner->emitError(XMLErrs::NoExtRefsInAttValue); // And now create a reader to read this entity @@ -2382,8 +2403,8 @@ bool DTDScanner::scanEntityLiteral(XMLBuffer& toFill, const bool isPE) // then we propogated some entity out of the literal, so issue an // error, but don't fail. // - if (fReaderMgr->getCurrentReaderNum() != orgReader) - fScanner->emitError(XMLErrs::PartialMarkupInEntity); + if (fReaderMgr->getCurrentReaderNum() != orgReader && fScanner->getDoValidation()) + fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); return true; } @@ -2641,8 +2662,9 @@ void DTDScanner::scanExtSubsetDecl(const bool inIncludeSect) // And see if we got back to the same level. If not, then its // a partial markup error. // - if (fReaderMgr->getCurrentReaderNum() != orgReader) - fScanner->emitError(XMLErrs::PartialMarkupInEntity); + if (fReaderMgr->getCurrentReaderNum() != orgReader && fScanner->getDoValidation()) + fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); + } else if (XMLReader::isWhitespace(nextCh)) { @@ -3013,8 +3035,8 @@ bool DTDScanner::scanInternalSubset() scanMarkupDecl(false); // If we did not get back to entry level, then partial markup - if (fReaderMgr->getCurrentReaderNum() != orgReader) - fScanner->emitError(XMLErrs::PartialMarkupInEntity); + if (fReaderMgr->getCurrentReaderNum() != orgReader && fScanner->getDoValidation()) + fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); } else if (XMLReader::isWhitespace(nextCh)) { -- GitLab