[Libreoffice-commits] core.git: sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 30 08:50:37 UTC 2019


 sw/source/core/unocore/unocrsrhelper.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit 9b1e3e9bfdc0639630a367e45e4bdc2e9f22e503
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Oct 29 15:52:34 2019 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Wed Oct 30 09:49:22 2019 +0100

    sw: UNO API: do not allow inserting control characters into nodes
    
    Refuse invalid input in DocInsertStringSplitCR().
    
    Change-Id: I097c1b3a1f70b0cf1fa3fc33fc1d965ee6c96280
    Reviewed-on: https://gerrit.libreoffice.org/81696
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 05bab4a0c344..5e973c2b7c99 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -68,6 +68,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,6 +1106,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)


More information about the Libreoffice-commits mailing list