sw/source/filter/ww8/ww8par.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+)
New commits: commit ec5acd6c289446ffb0e07fa1887f5a306e03b4f2 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Thu Dec 5 12:56:34 2024 +0000 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Dec 6 11:20:50 2024 +0100 crashtesting: HLINK embedded null import from ooo98294-1.doc which causes problems on export to docx. Sanitize at the original import. Change-Id: I3b5521dac6a2b6926db6362d33500b11f0a69098 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177871 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 624fdc2f9b6d..cc50f8d76c17 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -216,6 +216,15 @@ namespace } } +// returns true if an embedded null was found +static bool clipToFirstNull(OUString& rStr) +{ + sal_Int32 nEmbeddedNullIdx = rStr.indexOf(0); + if (nEmbeddedNullIdx != -1) + rStr = rStr.copy(0, nEmbeddedNullIdx); + return nEmbeddedNullIdx != -1; +} + void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocShell, struct HyperLinksTable& hlStr) { // (0x01B8) HLINK @@ -347,6 +356,8 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS if (xLongName) { + if (clipToFirstNull(*xLongName)) + SAL_WARN("sw.ww8", "HLINK with embedded null, truncating to: " << *xLongName); if (xTextMark) { if (xLongName->isEmpty())