You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2003/01/06 20:44:58 UTC
cvs commit: xml-xerces/c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner2.cpp ReaderMgr.cpp SGXMLScanner.cpp WFXMLScanner.cpp XMLScanner.cpp
tng 2003/01/06 11:44:58
Modified: c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner2.cpp
ReaderMgr.cpp SGXMLScanner.cpp WFXMLScanner.cpp
XMLScanner.cpp
Log:
New feature StandardUriConformant to force strict standard uri conformance.
Revision Changes Path
1.5 +6 -2 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DGXMLScanner.cpp 3 Jan 2003 20:08:39 -0000 1.4
+++ DGXMLScanner.cpp 6 Jan 2003 19:44:57 -0000 1.5
@@ -2270,7 +2270,11 @@
, XMLExcepts::URL_NoProtocolPresent
);
}
- srcToFill = new URLInputSource(urlTmp);
+ else {
+ if (fStandardUriConformant && urlTmp.hasInvalidChar())
+ ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
+ srcToFill = new URLInputSource(urlTmp);
+ }
}
catch(const MalformedURLException& e)
{
1.7 +11 -3 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- IGXMLScanner2.cpp 3 Jan 2003 20:08:39 -0000 1.6
+++ IGXMLScanner2.cpp 6 Jan 2003 19:44:57 -0000 1.7
@@ -1270,7 +1270,11 @@
, XMLExcepts::URL_NoProtocolPresent
);
}
- srcToFill = new URLInputSource(urlTmp);
+ else {
+ if (fStandardUriConformant && urlTmp.hasInvalidChar())
+ ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
+ srcToFill = new URLInputSource(urlTmp);
+ }
}
catch(const MalformedURLException& e)
@@ -1423,7 +1427,11 @@
, XMLExcepts::URL_NoProtocolPresent
);
}
- srcToFill = new URLInputSource(urlTmp);
+ else {
+ if (fStandardUriConformant && urlTmp.hasInvalidChar())
+ ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
+ srcToFill = new URLInputSource(urlTmp);
+ }
}
catch(const MalformedURLException& e)
{
1.11 +11 -3 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ReaderMgr.cpp 3 Jan 2003 20:08:39 -0000 1.10
+++ ReaderMgr.cpp 6 Jan 2003 19:44:57 -0000 1.11
@@ -547,7 +547,11 @@
, XMLExcepts::URL_NoProtocolPresent
);
}
- srcToFill = new URLInputSource(urlTmp);
+ else {
+ if (fStandardUriConformant && urlTmp.hasInvalidChar())
+ ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
+ srcToFill = new URLInputSource(urlTmp);
+ }
}
catch(const MalformedURLException& e)
@@ -653,7 +657,11 @@
, XMLExcepts::URL_NoProtocolPresent
);
}
- srcToFill = new URLInputSource(urlTmp);
+ else {
+ if (fStandardUriConformant && urlTmp.hasInvalidChar())
+ ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
+ srcToFill = new URLInputSource(urlTmp);
+ }
}
catch(const MalformedURLException& e)
1.7 +11 -3 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SGXMLScanner.cpp 3 Jan 2003 20:08:39 -0000 1.6
+++ SGXMLScanner.cpp 6 Jan 2003 19:44:57 -0000 1.7
@@ -2983,7 +2983,11 @@
, XMLExcepts::URL_NoProtocolPresent
);
}
- srcToFill = new URLInputSource(urlTmp);
+ else {
+ if (fStandardUriConformant && urlTmp.hasInvalidChar())
+ ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
+ srcToFill = new URLInputSource(urlTmp);
+ }
}
catch(const MalformedURLException& e)
@@ -3113,7 +3117,11 @@
, XMLExcepts::URL_NoProtocolPresent
);
}
- srcToFill = new URLInputSource(urlTmp);
+ else {
+ if (fStandardUriConformant && urlTmp.hasInvalidChar())
+ ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
+ srcToFill = new URLInputSource(urlTmp);
+ }
}
catch(const MalformedURLException& e)
{
1.6 +41 -13 xml-xerces/c/src/xercesc/internal/WFXMLScanner.cpp
Index: WFXMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/WFXMLScanner.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WFXMLScanner.cpp 2 Jan 2003 16:29:05 -0000 1.5
+++ WFXMLScanner.cpp 6 Jan 2003 19:44:57 -0000 1.6
@@ -1117,6 +1117,8 @@
XMLElementDecl* elemDecl = fElementLookup->get(qnameRawBuf);
if (!elemDecl) {
+ if (!XMLString::compareNString(qnameRawBuf, XMLUni::fgXMLNSColonString, 6))
+ emitError(XMLErrs::NoXMLNSAsElementPrefix, qnameRawBuf);
if (fElementIndex < fElements->size()) {
elemDecl = fElements->elementAt(fElementIndex);
@@ -1314,30 +1316,51 @@
}
// Make sure that the name is basically well formed for namespace
- //
- // Map prefix to namespace
- const XMLCh* attPrefix = curAtt->getPrefix();
- const XMLCh* attLocalName = curAtt->getName();
- if (attPrefix && *attPrefix) {
-
- int colonPos = XMLString::indexOf(attLocalName, chColon);
-
- if (colonPos != -1) {
+ // enabled rules. It either has no colons, or it has one which
+ // is neither the first or last char.
+ const int colonFirst = XMLString::indexOf(attNameRawBuf, chColon);
+ if (colonFirst != -1)
+ {
+ const int colonLast = XMLString::lastIndexOf(attNameRawBuf, chColon);
- curAttListSize = fAttrList->size();
+ if (colonFirst != colonLast)
+ {
emitError(XMLErrs::TooManyColonsInName);
continue;
}
+ else if ((colonFirst == 0)
+ || (colonLast == (int)fAttNameBuf.getLen() - 1))
+ {
+ emitError(XMLErrs::InvalidColonPos);
+ continue;
+ }
+ }
+
+ // Map prefix to namespace
+ const XMLCh* attPrefix = curAtt->getPrefix();
+ const XMLCh* attLocalName = curAtt->getName();
+ const XMLCh* namespaceURI = fAttValueBuf.getRawBuffer();
+ if (attPrefix && *attPrefix) {
if (XMLString::equals(attPrefix, XMLUni::fgXMLString)) {
curAtt->setURIId(fXMLNamespaceId);
}
else if (XMLString::equals(attPrefix, XMLUni::fgXMLNSString)) {
+ if (XMLString::equals(attLocalName, XMLUni::fgXMLNSString))
+ emitError(XMLErrs::NoUseOfxmlnsAsPrefix);
+ else if (XMLString::equals(attLocalName, XMLUni::fgXMLString)) {
+ if (!XMLString::equals(namespaceURI, XMLUni::fgXMLURIName))
+ emitError(XMLErrs::PrefixXMLNotMatchXMLURI);
+ }
+
+ if (!namespaceURI || !*namespaceURI)
+ emitError(XMLErrs::NoEmptyStrNamespace, attNameRawBuf);
+
fElemStack.addPrefix
(
attLocalName
- , fURIStringPool->addOrFind(fAttValueBuf.getRawBuffer())
+ , fURIStringPool->addOrFind(namespaceURI)
);
curAtt->setURIId(fXMLNSNamespaceId);
}
@@ -1348,10 +1371,15 @@
else {
if (XMLString::equals(XMLUni::fgXMLNSString, attLocalName)) {
+ if (XMLString::equals(namespaceURI, XMLUni::fgXMLNSURIName))
+ emitError(XMLErrs::NoUseOfxmlnsURI);
+ else if (XMLString::equals(namespaceURI, XMLUni::fgXMLURIName))
+ emitError(XMLErrs::XMLURINotMatchXMLPrefix);
+
fElemStack.addPrefix
(
XMLUni::fgZeroLenString
- , fURIStringPool->addOrFind(fAttValueBuf.getRawBuffer())
+ , fURIStringPool->addOrFind(namespaceURI)
);
}
}
1.36 +34 -1 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.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- XMLScanner.cpp 3 Jan 2003 20:08:39 -0000 1.35
+++ XMLScanner.cpp 6 Jan 2003 19:44:57 -0000 1.36
@@ -308,6 +308,17 @@
}
else
{
+ if (fStandardUriConformant && tmpURL.hasInvalidChar()) {
+ MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL);
+ fInException = true;
+ emitError
+ (
+ XMLErrs::XMLException_Fatal
+ , e.getType()
+ , e.getMessage()
+ );
+ return;
+ }
srcToUse = new URLInputSource(tmpURL);
}
@@ -414,6 +425,17 @@
}
else
{
+ if (fStandardUriConformant && tmpURL.hasInvalidChar()) {
+ MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL);
+ fInException = true;
+ emitError
+ (
+ XMLErrs::XMLException_Fatal
+ , e.getType()
+ , e.getMessage()
+ );
+ return false;
+ }
srcToUse = new URLInputSource(tmpURL);
}
}
@@ -1535,6 +1557,17 @@
}
else
{
+ if (fStandardUriConformant && tmpURL.hasInvalidChar()) {
+ MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL);
+ fInException = true;
+ emitError
+ (
+ XMLErrs::XMLException_Fatal
+ , e.getType()
+ , e.getMessage()
+ );
+ return 0;
+ }
srcToUse = new URLInputSource(tmpURL);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org