diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-01-13 16:24:06 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2020-01-13 18:58:59 +0100 |
commit | ff365eb193279bb9866b8fad7378f6068b207051 (patch) | |
tree | a20e77ca757f61b1f125f23184f58c9824c25dd5 /sc/source/ui/app | |
parent | 23e8e4521366aaf5831a3c1feaffdc41658ce7e7 (diff) |
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/+/86705
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 59f6d3c5e809..5c4d4de77f96 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -24,6 +24,7 @@ #include <editeng/eeitem.hxx> #include <sfx2/app.hxx> +#include <sfx2/lokhelper.hxx> #include <editeng/acorrcfg.hxx> #include <formula/errorcodes.hxx> #include <svx/algitem.hxx> @@ -1289,9 +1290,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()) @@ -1323,12 +1336,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("\"}, "); } } |