diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2019-10-29 15:52:34 +0100 |
---|---|---|
committer | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2021-04-13 15:27:26 +0300 |
commit | a9a79503ff58471c03433df53a24e93510b5d205 (patch) | |
tree | f15c386445025cc744c59c0c7c7bec4f26c7e1c5 | |
parent | c8e04eb4455eb412466b65a085464a81bd2519fa (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.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index da1facfad0ab..dd5122379dab 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> @@ -1105,7 +1106,18 @@ bool DocInsertStringSplitCR( { bool bOK = true; - const SwInsertFlags nInsertFlags = + 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) : SwInsertFlags::EMPTYEXPAND; |