diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-01-13 16:24:06 +0000 |
---|---|---|
committer | Dennis Francis <dennisfrancis.in@gmail.com> | 2020-05-26 23:17:27 +0530 |
commit | a365fc8bc997a9b607d9a58511418c7bfaa5df8a (patch) | |
tree | a06cc07cf724fb2e6e1c45d62e1dc333363685c7 /sc | |
parent | e57341318cc4e38ea4c2aa7e73f20663c4cdcd5f (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>
(cherry picked from commit ff365eb193279bb9866b8fad7378f6068b207051)
Diffstat (limited to 'sc')
-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 bf88e234ddc9..f50d41e029ae 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> @@ -1286,9 +1287,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::isMobilePhone(SfxLokHelper::getView())) { SfxViewShell* pViewShell = SfxViewShell::Current(); if (pViewShell && rFuncStrVec.size()) @@ -1320,12 +1333,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("\"}, "); } } |