You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2004/12/11 06:02:04 UTC
cvs commit: xml-security/c/src/utils XSECDOMUtils.cpp
blautenb 2004/12/10 21:02:04
Modified: c/src/utils XSECDOMUtils.cpp
Log:
Fix counting of transcoded characters (count characters not bytes) reported by Milan Tomic
Revision Changes Path
1.25 +11 -3 xml-security/c/src/utils/XSECDOMUtils.cpp
Index: XSECDOMUtils.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECDOMUtils.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- XSECDOMUtils.cpp 10 Oct 2004 07:00:34 -0000 1.24
+++ XSECDOMUtils.cpp 11 Dec 2004 05:02:04 -0000 1.25
@@ -347,7 +347,8 @@
Janitor<XMLTranscoder> j_t(t);
// Need to loop through, 2K at a time
- unsigned int bytesEaten;
+ unsigned int bytesEaten, bytesEatenCounter;
+ unsigned int charactersEaten;
unsigned int totalBytesEaten = 0;
unsigned int bytesToEat = XMLString::stringLen((char *) src);
@@ -365,7 +366,14 @@
bytesEaten,
charSizes);
- outputBuf[bytesEaten] = chNull;
+ // Determine how many characters were used
+ bytesEatenCounter = 0;
+ charactersEaten = 0;
+ while (bytesEatenCounter < bytesEaten) {
+ bytesEatenCounter += charSizes[charactersEaten++];
+ }
+
+ outputBuf[charactersEaten] = chNull;
fullDest.sbXMLChCat(outputBuf);
totalBytesEaten += bytesEaten;
}