sfx2/source/view/lokhelper.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
New commits: commit a434f5d2d4ff4991937b57e521782ad3594aa370 Author: mert <mert.tu...@collabora.com> AuthorDate: Mon Feb 22 11:17:27 2021 +0300 Commit: Mert Tumer <mert.tu...@collabora.com> CommitDate: Wed Mar 3 08:42:09 2021 +0100 Fix non-valid json generation on NotifyOtherViews Change-Id: I82aa0aefcd1de14b4c1bb2bbe3f087b60d691beb Signed-off-by: mert <mert.tu...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111299 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111515 Tested-by: Jenkins diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index cdd6030a7c8f..2a5ea882d92d 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -308,7 +308,11 @@ void SfxLokHelper::setDeviceFormFactor(std::u16string_view rDeviceFormFactor) g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN; } -static OString lcl_escapeQuotes(const OString &rStr) +/* +* Used for putting a whole JSON string into a string value +* e.g { key: "{JSON}" } +*/ +static OString lcl_sanitizeJSONAsValue(const OString &rStr) { if (rStr.getLength() < 1) return rStr; @@ -318,7 +322,9 @@ static OString lcl_escapeQuotes(const OString &rStr) { if (rStr[i] == '"' || rStr[i] == '\\') aBuf.append('\\'); - aBuf.append(rStr[i]); + + if (rStr[i] != '\n') + aBuf.append(rStr[i]); } return aBuf.makeStringAndClear(); } @@ -341,7 +347,7 @@ static inline OString lcl_generateJSON(const SfxViewShell* pView, std::string_vi assert(pView != nullptr && "pView must be valid"); return OStringLiteral("{ \"viewId\": \"") + OString::number(SfxLokHelper::getView(pView)) + "\", \"part\": \"" + OString::number(pView->getPart()) + "\", \"" + rKey + "\": \"" - + lcl_escapeQuotes(rPayload) + "\" }"; + + lcl_sanitizeJSONAsValue(rPayload) + "\" }"; } void SfxLokHelper::notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits