summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-12-05 12:56:34 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-12-05 16:18:42 +0100
commitacd9e2165c42f0d6977e1ffd883983fe33c5d073 (patch)
tree34962073aa5ad5b961c3f70f74aebbf9d35cae8d
parentbce744550d80b66a6889ebb9dc2814f9644f978e (diff)
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/+/177869 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r--sw/source/filter/ww8/ww8par.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 0ed8fcac0ca7..d3118ce913c7 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -217,6 +217,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
@@ -348,6 +357,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())