Author: scantor Date: Tue Feb 13 00:54:01 2018 New Revision: 1824086 URL: http://svn.apache.org/viewvc?rev=1824086&view=rev Log: XERCESC-2130 - UTF16 Surrogate values failing
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp?rev=1824086&r1=1824085&r2=1824086&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp (original) +++ xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp Tue Feb 13 00:54:01 2018 @@ -1737,13 +1737,29 @@ bool DOMLSSerializerImpl::isNamespaceBin void DOMLSSerializerImpl::ensureValidString(const DOMNode* nodeToWrite, const XMLCh* string) { // XERCESC-1854: prevent illegal characters from being written + // XERCESC-2130: allow surrogates if(string==0) return; const XMLCh* cursor=string; while(*cursor!=0) { if((fIsXml11 && !XMLChar1_1::isXMLChar(*cursor)) || (!fIsXml11 && !XMLChar1_0::isXMLChar(*cursor))) - reportError(nodeToWrite, DOMError::DOM_SEVERITY_FATAL_ERROR, XMLDOMMsg::INVALID_CHARACTER_ERR); + { + if((*cursor >= 0xD800) && (*cursor <= 0xDBFF)) + { + XMLCh leadingSurrogate = *cursor; + cursor++; + if(0==*cursor || (fIsXml11 && !XMLChar1_1::isXMLChar(leadingSurrogate, *cursor)) || (!fIsXml11 && !XMLChar1_0::isXMLChar(leadingSurrogate, *cursor))) + { + reportError(nodeToWrite, DOMError::DOM_SEVERITY_FATAL_ERROR, XMLDOMMsg::INVALID_CHARACTER_ERR); + return; // leave if reportError does not throw + } + } + else + { + reportError(nodeToWrite, DOMError::DOM_SEVERITY_FATAL_ERROR, XMLDOMMsg::INVALID_CHARACTER_ERR); + } + } cursor++; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org