[Libreoffice-commits] .: svtools/source

Caolán McNamara caolan at kemper.freedesktop.org
Tue Jul 19 06:47:10 PDT 2011


 svtools/source/svrtf/parrtf.cxx |   22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

New commits:
commit ba5b1f1d2c5c1a0fa0295fb0b3114731037d7fd5
Author: Troy Rollo <libreoffice at troy.rollo.name>
Date:   Tue Jul 19 14:47:02 2011 +0100

    Preserve RTF \'00 sequences (NULL) in strings

diff --git a/svtools/source/svrtf/parrtf.cxx b/svtools/source/svrtf/parrtf.cxx
index 0b722d8..0c60834 100644
--- a/svtools/source/svrtf/parrtf.cxx
+++ b/svtools/source/svrtf/parrtf.cxx
@@ -341,7 +341,27 @@ void SvRTFParser::ScanText( const sal_Unicode cBreak )
                         ByteString aByteString;
                         while (1)
                         {
-                            aByteString.Append((char)GetHexValue());
+                            char c = (char)GetHexValue();
+
+                            if (c)
+                            {
+                                aByteString.Append(c);
+                            }
+                            else
+                            {
+                                /* \'00 is a valid internal character in  a
+                                * string in RTF, however ByteString::Append
+                                * does nothing if '\0' is passed in. It is
+                                * otherwise capable of handling strings with
+                                * embedded NULs, so add a '\1' and then
+                                * change it, as ByteString::SetChar does not
+                                * care if the character is '\0'.
+                                */
+                                int nLen = aByteString.Len();
+
+                                aByteString.Append('\001');
+                                aByteString.SetChar(nLen, '\0');
+                            }
 
                             bool bBreak = false;
                             sal_Char nSlash = '\\';


More information about the Libreoffice-commits mailing list