Fix K-Escaper; we wouldn't copy the whole UTF-8 sequence in some cases.
authorWilfried Goesgens <dothebart@citadel.org>
Wed, 29 Jun 2011 09:56:50 +0000 (11:56 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Wed, 29 Jun 2011 09:58:28 +0000 (11:58 +0200)
libcitadel/lib/stringbuf.c

index 1408669b0bf90810e78a1ac819f95fa60526e7ba..7a841df8f255fcdbfd5c20348639aa2387348a18 100644 (file)
@@ -2153,20 +2153,20 @@ long StrHtmlEcmaEscAppend(StrBuf *Target, const StrBuf *Source, const char *Plai
                        if (((unsigned char)*aptr) >= 0x20)
                        {
                                IsUtf8Sequence =  Ctdl_GetUtf8SequenceLength(aptr, eiptr);
-                               
+
                                *bptr = *aptr;
                                Target->BufUsed ++;
-                               while (IsUtf8Sequence > 1){
-                                       if(bptr + IsUtf8Sequence >= eptr) {
-                                               IncreaseBuf(Target, 1, -1);
-                                               eptr = Target->buf + Target->BufSize - 11; /* our biggest unit to put in...  */
-                                               bptr = Target->buf + Target->BufUsed - 1;
-                                       }
+                               if (IsUtf8Sequence > 1) while (IsUtf8Sequence > 0){
+                                               if(bptr + IsUtf8Sequence >= eptr) {
+                                                       IncreaseBuf(Target, 1, -1);
+                                                       eptr = Target->buf + Target->BufSize - 11; /* our biggest unit to put in...  */
+                                                       bptr = Target->buf + Target->BufUsed - 1;
+                                               }
                                        bptr++; aptr++;
-                                       IsUtf8Sequence --;
-                                       *bptr = *aptr;
-                                       Target->BufUsed ++;
-                               }
+                                               IsUtf8Sequence --;
+                                               *bptr = *aptr;
+                                               Target->BufUsed ++;
+                                       }
                                bptr++;
                        }