Author: amassari
Date: Tue Dec 27 10:08:43 2011
New Revision: 1224886

URL: http://svn.apache.org/viewvc?rev=1224886&view=rev
Log:
Don't report a transcoding error is the invalid character is not at the start 
of the buffer, it could be an incomplete buffer (XERCESC-1936)

Modified:
    xerces/c/trunk/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp
    
xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp

Modified: xerces/c/trunk/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp?rev=1224886&r1=1224885&r2=1224886&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp 
(original)
+++ xerces/c/trunk/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp Tue Dec 
27 10:08:43 2011
@@ -666,7 +666,7 @@ ICUTranscoder::transcodeTo( const   XMLC
     );
 
     // Rememember the status before we possibly overite the error code
-    const bool res = (err == U_ZERO_ERROR);
+    const bool res = ((err == U_ZERO_ERROR) || (err == U_BUFFER_OVERFLOW_ERROR 
&& startSrc > srcPtr));
 
     // Put the old handler back
     err = U_ZERO_ERROR;
@@ -738,7 +738,7 @@ bool ICUTranscoder::canTranscodeTo(const
          , &err
          );
 
-    // Set upa temp buffer to format into. Make it more than big enough
+    // Set up a temp buffer to format into. Make it more than big enough
     char            tmpBuf[64];
     char*           startTarget = tmpBuf;
     const UChar*    startSrc = srcBuf;

Modified: 
xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp?rev=1224886&r1=1224885&r2=1224886&view=diff
==============================================================================
--- 
xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp 
(original)
+++ 
xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp 
Tue Dec 27 10:08:43 2011
@@ -1041,7 +1041,7 @@ XMLSize_t    IconvGNUTranscoder::transco
     char    *orgTarget = startTarget;
     size_t    srcLen = srcCount;
     size_t    prevSrcLen = srcLen;
-    unsigned int toReturn = 0;
+    XMLSize_t toReturn = 0;
     bytesEaten = 0;
 
     XMLMutexLock lockConverter(&fMutex);
@@ -1049,6 +1049,8 @@ XMLSize_t    IconvGNUTranscoder::transco
     for (size_t cnt = 0; cnt < maxChars && srcLen; cnt++) {
         size_t    rc = iconvFrom(startSrc, &srcLen, &orgTarget, uChSize());
         if (rc == (size_t)-1) {
+            if (errno == EINVAL && cnt > 0)
+                break;
             if (errno != E2BIG || prevSrcLen == srcLen) {
                 ThrowXMLwithMemMgr(TranscodingException, 
XMLExcepts::Trans_BadSrcSeq, getMemoryManager());
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to