From ce553f3f5830fefc13aec919339b0796e516f7d1 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Wed, 29 Jun 2011 11:56:50 +0200 Subject: [PATCH] Fix K-Escaper; we wouldn't copy the whole UTF-8 sequence in some cases. --- libcitadel/lib/stringbuf.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 1408669b0..7a841df8f 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -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++; } -- 2.39.2