diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-17 15:19:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-17 22:11:46 +0200 |
commit | 99fa8d59f8cc3f06ce4fbe6b5ec834e9e30ae3b4 (patch) | |
tree | 3d49981b8e798de54eefd03afbf2d734a5c41d4a /sw | |
parent | 7e3ee1673c3e59f5e98158c4edd14a57df95e1cd (diff) |
Resolves: tdf#120003 missing prefix to link url in .doc import
regression from...
commit 9b77f8142bf665a47c3a179e3fe3f82623a99f8a
Author: Caolán McNamara <caolanm@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/61884
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index d06d1de741ed..d44c84ad14bd 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -253,7 +253,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 @@ -264,7 +272,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); @@ -275,7 +292,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 @@ -283,10 +301,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); } |