[Libreoffice-commits] core.git: Branch 'libreoffice-6-1-3' - include/tools sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Oct 27 18:23:54 UTC 2018


 include/tools/stream.hxx        |    8 --------
 sw/source/filter/ww8/ww8par.cxx |   34 ++++++++++++++++++++++++++++++----
 2 files changed, 30 insertions(+), 12 deletions(-)

New commits:
commit e40c944e8e654228e1893fc1bded8e1bded41ee7
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 17 15:19:52 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Oct 27 20:23:34 2018 +0200

    Resolves: tdf#120003 missing prefix to link url in .doc import
    
    regression from...
    
    commit 9b77f8142bf665a47c3a179e3fe3f82623a99f8a
    Author: Caolán McNamara <caolanm at redhat.com>
    Date:   Thu Apr 6 15:08:45 2017 +0100
    
        ditch ReadRawUniString
    
    three argument lclGetString32 variant mistaken for two argument lclGetString32
    variant
    
    Change-Id: I163aad0de7873487d9f9c8b6c28d162159fe7ad4
    Reviewed-on: https://gerrit.libreoffice.org/61887
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
    (cherry picked from commit faf048080124a4e1c9fcb4637fa9541921c758bd)
    Reviewed-on: https://gerrit.libreoffice.org/61923
    Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index bcc22137174a..f940b742a738 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -528,14 +528,6 @@ inline OString read_uInt8_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
     return read_uInt8s_ToOString(rStrm, nUnits);
 }
 
-/// Attempt to read a pascal-style length (of type prefix) prefixed sequence of
-/// 8bit units to an OUString
-inline OUString read_uInt32_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm,
-                                                          rtl_TextEncoding eEnc)
-{
-    return OStringToOUString(read_uInt32_lenPrefixed_uInt8s_ToOString(rStrm), eEnc);
-}
-
 inline OUString read_uInt16_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm,
                                                           rtl_TextEncoding eEnc)
 {
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index c4fd1cd33125..e2a18452cf90 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -252,7 +252,15 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS
         // UNC path
     if( ::get_flag( nFlags, WW8_HLINK_UNC ) )
     {
-        xLongName.reset(new OUString(read_uInt32_lenPrefixed_uInt16s_ToOUString(rStrm)));
+        // MS-OSHARED: An unsigned integer that specifies the number of Unicode characters in the
+        // string field, including the null-terminating character.
+        sal_uInt32 nStrLen(0);
+        rStrm.ReadUInt32(nStrLen);
+        if (nStrLen)
+        {
+            xLongName.reset(new OUString(read_uInt16s_ToOUString(rStrm, nStrLen - 1)));
+            rStrm.SeekRel(sizeof(sal_Unicode)); // skip null-byte at end
+        }
         lclGetAbsPath( *xLongName, 0 , pDocShell);
     }
     // file link or URL
@@ -263,7 +271,16 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS
         if( memcmp(aGuid, aGuidFileMoniker, 16) == 0 )
         {
             rStrm.ReadUInt16( nLevel );
-            xShortName.reset(new OUString(read_uInt32_lenPrefixed_uInt8s_ToOUString(rStrm, GetCharSetFromLanguage())));
+            // MS-OSHARED: An unsigned integer that specifies the number of
+            // ANSI characters in ansiPath, including the terminating NULL character
+            sal_uInt32 nUnits = 0;
+            rStrm.ReadUInt32(nUnits);
+            if (nUnits)
+            {
+                OString sStr(read_uInt8s_ToOString(rStrm, nUnits - 1));
+                rStrm.SeekRel(sizeof(sal_uInt8)); // skip null-byte at end
+                xShortName.reset(new OUString(sStr.getStr(), sStr.getLength(), GetCharSetFromLanguage()));
+            }
             rStrm.SeekRel( 24 );
 
             sal_uInt32 nStrLen(0);
@@ -274,7 +291,8 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS
                 rStrm.ReadUInt32( nStrLen );
                 nStrLen /= 2;
                 rStrm.SeekRel( 2 );
-                xLongName.reset(new OUString(read_uInt32_lenPrefixed_uInt16s_ToOUString(rStrm)));
+                // MS-OSHARED: This array MUST not include a terminating NULL character.
+                xLongName.reset(new OUString(read_uInt16s_ToOUString(rStrm, nStrLen)));
                 lclGetAbsPath( *xLongName, nLevel, pDocShell);
             }
             else
@@ -282,10 +300,18 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS
         }
         else if( memcmp(aGuid, aGuidUrlMoniker, 16) == 0 )
         {
+            // MS-OSHARED: An unsigned integer that specifies the size of this
+            // structure in bytes, excluding the size of the length field. The
+            // value of this field MUST be ... the byte size of the url
+            // field (including the terminating NULL character)
             sal_uInt32 nStrLen(0);
             rStrm.ReadUInt32( nStrLen );
             nStrLen /= 2;
-            xLongName.reset(new OUString(read_uInt32_lenPrefixed_uInt16s_ToOUString(rStrm)));
+            if (nStrLen)
+            {
+                xLongName.reset(new OUString(read_uInt16s_ToOUString(rStrm, nStrLen - 1)));
+                rStrm.SeekRel(sizeof(sal_Unicode)); // skip null-byte at end
+            }
             if( !::get_flag( nFlags, WW8_HLINK_ABS ) )
                 lclGetAbsPath( *xLongName, 0 ,pDocShell);
         }


More information about the Libreoffice-commits mailing list