Fix utf8-non-encoding in xml-escape
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 16 Feb 2015 19:35:57 +0000 (20:35 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 16 Feb 2015 19:37:42 +0000 (20:37 +0100)
libcitadel/lib/stringbuf.c

index baa9c69a79ea8a5df0e58e8e2096a93a567f8f0f..134ff47794a32e8790522a25d75a3e80b1bff960 100644 (file)
@@ -2006,32 +2006,13 @@ void StrBufXMLEscAppend(StrBuf *OutBuf,
                        *pt = *pch;
                        pt++; pch++;
                }
-               else if (*pch < 0x20) {
-                       /* we probably shouldn't be doing this */
-                       if (OverrideLowChars)
-                       {
-                               *pt = '_';
-                               pt ++;
-                               pch ++;
-                       }
-                       else
-                       {
-                               *pt = '&';
-                               pt++;
-                               *pt = HexList[*(unsigned char*)pch][0];
-                               pt ++;
-                               *pt = HexList[*(unsigned char*)pch][1];
-                               pt ++; pch ++;
-                               *pt = '&';
-                               pt++;
-                               pch ++;
-                       }
-               }
                else {
                        IsUtf8Sequence =  Ctdl_GetUtf8SequenceLength(pch, pche);
                        if (IsUtf8Sequence)
                        {
-                               while (IsUtf8Sequence > 0){
+                               while ((IsUtf8Sequence > 0) && 
+                                      (pch < pche))
+                               {
                                        *pt = *pch;
                                        pt ++;
                                        pch ++;