You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by jb...@apache.org on 2005/06/11 22:24:20 UTC
svn commit: r190171 - in /xerces/c/branches/xerces-2.7/src/xercesc/internal:
IGXMLScanner2.cpp SGXMLScanner.cpp
Author: jberry
Date: Sat Jun 11 13:24:20 2005
New Revision: 190171
URL: http://svn.apache.org/viewcvs?rev=190171&view=rev
Log:
Apply patch (commit 189580) from main trunk. Fix for Xercesc-1423
Modified:
xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner2.cpp
xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp
Modified: xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner2.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner2.cpp?rev=190171&r1=190170&r2=190171&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner2.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner2.cpp Sat Jun 11 13:24:20 2005
@@ -2051,119 +2051,111 @@
// Loop until we get the attribute value. Note that we use a double
// loop here to avoid the setup/teardown overhead of the exception
// handler on every round.
- XMLCh nextCh;
- XMLCh secondCh = 0;
- bool gotLeadingSurrogate = false;
- bool escaped;
while (true)
{
try
{
while(true)
{
- nextCh = fReaderMgr.getNextChar();
+ XMLCh nextCh = fReaderMgr.getNextChar();
- if (!nextCh)
- ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
-
- // Check for our ending quote. It has to be in the same entity
- // as where we started. Quotes in nested entities are ignored.
- if (nextCh == quoteCh)
+ if (nextCh != quoteCh)
{
- if (curReader == fReaderMgr.getCurrentReaderNum())
- return true;
-
- // Watch for spillover into a previous entity
- if (curReader > fReaderMgr.getCurrentReaderNum())
+ if (nextCh != chAmpersand)
{
- emitError(XMLErrs::PartialMarkupInEntity);
- return false;
- }
- }
+ if ((nextCh < 0xD800) || (nextCh > 0xDFFF))
+ {
+ // Its got to at least be a valid XML character
+ if (!fReaderMgr.getCurrentReader()->isXMLChar(nextCh))
+ {
+ if (nextCh == 0)
+ ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
+
+ XMLCh tmpBuf[9];
+ XMLString::binToText
+ (
+ nextCh
+ , tmpBuf
+ , 8
+ , 16
+ , fMemoryManager
+ );
+ emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf);
+ }
+ } else // its a surrogate
+ {
+ // Deal with surrogate pairs
- // Check for an entity ref . We ignore the empty flag in
- // this one.
- escaped = false;
- if (nextCh == chAmpersand)
- {
- // If it was not returned directly, then jump back up
- if (scanEntityRef(true, nextCh, secondCh, escaped) != EntityExp_Returned)
+ // we expect a a leading surrogate.
+ if (nextCh <= 0xDBFF)
+ {
+ toFill.append(nextCh);
+
+ // process the trailing surrogate
+ nextCh = fReaderMgr.getNextChar();
+
+ // it should be a trailing surrogate.
+ if ((nextCh < 0xDC00) || (nextCh > 0xDFFF))
+ {
+ emitError(XMLErrs::Expected2ndSurrogateChar);
+ }
+ } else
+ {
+ // Its a trailing surrogate, but we are not expecting it
+ emitError(XMLErrs::Unexpected2ndSurrogateChar);
+ }
+ }
+ } else // its a chAmpersand
{
- gotLeadingSurrogate = false;
+ // Check for an entity ref . We ignore the empty flag in
+ // this one.
+
+ bool escaped;
+ XMLCh firstCh;
+ XMLCh secondCh
+ ;
+ // If it was not returned directly, then jump back up
+ if (scanEntityRef(true, firstCh, secondCh, escaped) == EntityExp_Returned)
+ {
+ // If it was escaped, then put in a 0xFFFF value. This will
+ // be used later during validation and normalization of the
+ // value to know that the following character was via an
+ // escape char.
+ if (escaped)
+ toFill.append(0xFFFF);
+
+ toFill.append(firstCh);
+ if (secondCh)
+ toFill.append(secondCh);
+ }
continue;
}
- }
- else if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF))
- {
- // Deal with surrogate pairs
- // Its a leading surrogate. If we already got one, then
- // issue an error, else set leading flag to make sure that
- // we look for a trailing next time.
- if (gotLeadingSurrogate)
- {
- emitError(XMLErrs::Expected2ndSurrogateChar);
- }
- else
- gotLeadingSurrogate = true;
- }
- else
+ } else // its a quoteCh
{
- // If its a trailing surrogate, make sure that we are
- // prepared for that. Else, its just a regular char so make
- // sure that we were not expected a trailing surrogate.
- if ((nextCh >= 0xDC00) && (nextCh <= 0xDFFF))
+ // Check for our ending quote. It has to be in the same entity
+ // as where we started. Quotes in nested entities are ignored.
+
+ if (curReader == fReaderMgr.getCurrentReaderNum())
{
- // Its trailing, so make sure we were expecting it
- if (!gotLeadingSurrogate)
- emitError(XMLErrs::Unexpected2ndSurrogateChar);
+ return true;
}
- else
+
+ // Watch for spillover into a previous entity
+ if (curReader > fReaderMgr.getCurrentReaderNum())
{
- // Its just a char, so make sure we were not expecting a
- // trailing surrogate.
- if (gotLeadingSurrogate) {
- emitError(XMLErrs::Expected2ndSurrogateChar);
- }
- // Its got to at least be a valid XML character
- else if (!fReaderMgr.getCurrentReader()->isXMLChar(nextCh))
- {
- XMLCh tmpBuf[9];
- XMLString::binToText
- (
- nextCh
- , tmpBuf
- , 8
- , 16
- , fMemoryManager
- );
- emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf);
- }
+ emitError(XMLErrs::PartialMarkupInEntity);
+ return false;
}
- gotLeadingSurrogate = false;
}
- // If it was escaped, then put in a 0xFFFF value. This will
- // be used later during validation and normalization of the
- // value to know that the following character was via an
- // escape char.
- if (escaped)
- toFill.append(0xFFFF);
-
- // Else add it to the buffer
+ // add it to the buffer
toFill.append(nextCh);
- if (secondCh)
- {
- toFill.append(secondCh);
- secondCh=0;
- }
}
}
catch(const EndOfEntityException&)
{
// Just eat it and continue.
- gotLeadingSurrogate = false;
- escaped = false;
}
}
return true;
Modified: xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp?rev=190171&r1=190170&r2=190171&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp Sat Jun 11 13:24:20 2005
@@ -3884,119 +3884,111 @@
// Loop until we get the attribute value. Note that we use a double
// loop here to avoid the setup/teardown overhead of the exception
// handler on every round.
- XMLCh nextCh;
- XMLCh secondCh = 0;
- bool gotLeadingSurrogate = false;
- bool escaped;
while (true)
{
try
{
while(true)
{
- nextCh = fReaderMgr.getNextChar();
+ XMLCh nextCh = fReaderMgr.getNextChar();
- if (!nextCh)
- ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
-
- // Check for our ending quote. It has to be in the same entity
- // as where we started. Quotes in nested entities are ignored.
- if (nextCh == quoteCh)
+ if (nextCh != quoteCh)
{
- if (curReader == fReaderMgr.getCurrentReaderNum())
- return true;
-
- // Watch for spillover into a previous entity
- if (curReader > fReaderMgr.getCurrentReaderNum())
+ if (nextCh != chAmpersand)
{
- emitError(XMLErrs::PartialMarkupInEntity);
- return false;
- }
- }
+ if ((nextCh < 0xD800) || (nextCh > 0xDFFF))
+ {
+ // Its got to at least be a valid XML character
+ if (!fReaderMgr.getCurrentReader()->isXMLChar(nextCh))
+ {
+ if (nextCh == 0)
+ ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
+
+ XMLCh tmpBuf[9];
+ XMLString::binToText
+ (
+ nextCh
+ , tmpBuf
+ , 8
+ , 16
+ , fMemoryManager
+ );
+ emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf);
+ }
+ } else // its a surrogate
+ {
+ // Deal with surrogate pairs
- // Check for an entity ref . We ignore the empty flag in
- // this one.
- escaped = false;
- if (nextCh == chAmpersand)
- {
- // If it was not returned directly, then jump back up
- if (scanEntityRef(true, nextCh, secondCh, escaped) != EntityExp_Returned)
+ // we expect a a leading surrogate.
+ if (nextCh <= 0xDBFF)
+ {
+ toFill.append(nextCh);
+
+ // process the trailing surrogate
+ nextCh = fReaderMgr.getNextChar();
+
+ // it should be a trailing surrogate.
+ if ((nextCh < 0xDC00) || (nextCh > 0xDFFF))
+ {
+ emitError(XMLErrs::Expected2ndSurrogateChar);
+ }
+ } else
+ {
+ // Its a trailing surrogate, but we are not expecting it
+ emitError(XMLErrs::Unexpected2ndSurrogateChar);
+ }
+ }
+ } else // its a chAmpersand
{
- gotLeadingSurrogate = false;
+ // Check for an entity ref . We ignore the empty flag in
+ // this one.
+
+ bool escaped;
+ XMLCh firstCh;
+ XMLCh secondCh
+ ;
+ // If it was not returned directly, then jump back up
+ if (scanEntityRef(true, firstCh, secondCh, escaped) == EntityExp_Returned)
+ {
+ // If it was escaped, then put in a 0xFFFF value. This will
+ // be used later during validation and normalization of the
+ // value to know that the following character was via an
+ // escape char.
+ if (escaped)
+ toFill.append(0xFFFF);
+
+ toFill.append(firstCh);
+ if (secondCh)
+ toFill.append(secondCh);
+ }
continue;
}
- }
- else if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF))
- {
- // Deal with surrogate pairs
- // Its a leading surrogate. If we already got one, then
- // issue an error, else set leading flag to make sure that
- // we look for a trailing next time.
- if (gotLeadingSurrogate)
- {
- emitError(XMLErrs::Expected2ndSurrogateChar);
- }
- else
- gotLeadingSurrogate = true;
- }
- else
+ } else // its a quoteCh
{
- // If its a trailing surrogate, make sure that we are
- // prepared for that. Else, its just a regular char so make
- // sure that we were not expected a trailing surrogate.
- if ((nextCh >= 0xDC00) && (nextCh <= 0xDFFF))
+ // Check for our ending quote. It has to be in the same entity
+ // as where we started. Quotes in nested entities are ignored.
+
+ if (curReader == fReaderMgr.getCurrentReaderNum())
{
- // Its trailing, so make sure we were expecting it
- if (!gotLeadingSurrogate)
- emitError(XMLErrs::Unexpected2ndSurrogateChar);
+ return true;
}
- else
+
+ // Watch for spillover into a previous entity
+ if (curReader > fReaderMgr.getCurrentReaderNum())
{
- // Its just a char, so make sure we were not expecting a
- // trailing surrogate.
- if (gotLeadingSurrogate) {
- emitError(XMLErrs::Expected2ndSurrogateChar);
- }
- // Its got to at least be a valid XML character
- else if (!fReaderMgr.getCurrentReader()->isXMLChar(nextCh))
- {
- XMLCh tmpBuf[9];
- XMLString::binToText
- (
- nextCh
- , tmpBuf
- , 8
- , 16
- , fMemoryManager
- );
- emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf);
- }
+ emitError(XMLErrs::PartialMarkupInEntity);
+ return false;
}
- gotLeadingSurrogate = false;
}
- // If it was escaped, then put in a 0xFFFF value. This will
- // be used later during validation and normalization of the
- // value to know that the following character was via an
- // escape char.
- if (escaped)
- toFill.append(0xFFFF);
-
- // Else add it to the buffer
+ // add it to the buffer
toFill.append(nextCh);
- if (secondCh)
- {
- toFill.append(secondCh);
- secondCh=0;
- }
}
}
catch(const EndOfEntityException&)
{
// Just eat it and continue.
- gotLeadingSurrogate = false;
- escaped = false;
}
}
return true;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org