summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-10-29 15:52:34 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-01-25 14:42:02 +0100
commitfc032ed3eb05bfba1dcd07bce566346b3f6f2fb9 (patch)
treebd82ac896be58162bb06b9f542b92450976bc001
parent85f3d259b4621decf7c4287ecfcbd6df61f7f13b (diff)
sw: UNO API: do not allow inserting control characters into nodes
Refuse invalid input in DocInsertStringSplitCR(). Reviewed-on: https://gerrit.libreoffice.org/81696 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 9b1e3e9bfdc0639630a367e45e4bdc2e9f22e503) Change-Id: I097c1b3a1f70b0cf1fa3fc33fc1d965ee6c96280
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 227c08f131bc..f0bca8cf4903 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -65,6 +65,7 @@
#include <cntfrm.hxx>
#include <pagefrm.hxx>
#include <svl/eitem.hxx>
+#include <svl/lngmisc.hxx>
#include <docary.hxx>
#include <swtable.hxx>
#include <tox.hxx>
@@ -1107,6 +1108,17 @@ bool DocInsertStringSplitCR(
{
bool bOK = true;
+ for (sal_Int32 i = 0; i < rText.getLength(); ++i)
+ {
+ sal_Unicode const ch(rText[i]);
+ if (linguistic::IsControlChar(ch)
+ && ch != '\r' && ch != '\n' && ch != '\t')
+ {
+ SAL_WARN("sw.uno", "DocInsertStringSplitCR: refusing to insert control character " << int(ch));
+ return false;
+ }
+ }
+
const SwInsertFlags nInsertFlags =
bForceExpandHints
? ( SwInsertFlags::FORCEHINTEXPAND | SwInsertFlags::EMPTYEXPAND)