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

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 13 19:01:47 UTC 2020


 sc/source/ui/app/inputhdl.cxx |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

New commits:
commit 62ad8f6f42a5f8c0150770b3490988bac62178e9
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Jan 13 16:24:06 2020 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Jan 13 20:01:17 2020 +0100

    mobile: escape JSON for function wizard, and emit only on mobile.
    
    Otherwise typing "-> wa" into a cell gives JS exceptions.
    
    Change-Id: I5303186fe9f84e055d65cf1929ccf5a7a20cae35
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86706
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 52e2ee5bb546..acf924de9397 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -26,6 +26,7 @@
 #include <editeng/eeitem.hxx>
 
 #include <sfx2/app.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <editeng/acorrcfg.hxx>
 #include <formula/errorcodes.hxx>
 #include <editeng/adjustitem.hxx>
@@ -1281,9 +1282,21 @@ bool ScInputHandler::GetFuncName( OUString& aStart, OUString& aResult )
     return true;
 }
 
+namespace {
+    /// Rid ourselves of unwanted " quoted json characters.
+    OString escapeJSON(const OUString &aStr)
+    {
+        OUString aEscaped = aStr;
+        aEscaped = aEscaped.replaceAll("\n", " ");
+        aEscaped = aEscaped.replaceAll("\"", "'");
+        return OUStringToOString(aEscaped, RTL_TEXTENCODING_UTF8);
+    }
+}
+
 void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec )
 {
-    if (comphelper::LibreOfficeKit::isActive())
+    if (comphelper::LibreOfficeKit::isActive() &&
+        comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()))
     {
         SfxViewShell* pViewShell = SfxViewShell::Current();
         if (pViewShell && rFuncStrVec.size())
@@ -1315,12 +1328,10 @@ void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec
                     {
                         aPayload.append("{");
                         aPayload.append("\"signature\": \"");
-                        OUString aSignature = ppFDesc->getSignature();
-                        aPayload.append(OUStringToOString(aSignature, RTL_TEXTENCODING_UTF8));
+                        aPayload.append(escapeJSON(ppFDesc->getSignature()));
                         aPayload.append("\", ");
                         aPayload.append("\"description\": \"");
-                        OUString aFuncDescr = ppFDesc->getDescription();
-                        aPayload.append(OUStringToOString(aFuncDescr, RTL_TEXTENCODING_UTF8));
+                        aPayload.append(escapeJSON(ppFDesc->getDescription()));
                         aPayload.append("\"}, ");
                     }
                 }


More information about the Libreoffice-commits mailing list