svx/source/unodraw/UnoGraphicExporter.cxx |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 20b16048236598880dc94bac146079426ae8f309
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Aug 20 15:01:02 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Aug 20 16:21:54 2024 +0200

    tdf#162528: handle exceptions from JSON parser in GraphicExporter
    
    Similar to commit 218695f947dfecaa92209adf0c5572b99f0c021f "tdf#150846:
    FilterOptions in descriptor could come from import filter", 2022-09-21
    
    Change-Id: I3123bb2c136d1bc5545d0412eb1db5e5fd9c91b6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172105
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx 
b/svx/source/unodraw/UnoGraphicExporter.cxx
index 72ae293ee4e2..0ea662b61a1c 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/task/XInteractionContinuation.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
+#include <boost/property_tree/json_parser/error.hpp>
 #include <tools/debug.hxx>
 #include <comphelper/diagnose_ex.hxx>
 #include <tools/urlobj.hxx>
@@ -388,9 +389,16 @@ void GraphicExporter::ParseSettings(const 
Sequence<PropertyValue>& rDescriptor,
         if (!aFilterData.hasElements() && !aFilterOptions.isEmpty())
         {
             // Allow setting filter data keys from the cmdline.
-            std::vector<PropertyValue> aData
-                = comphelper::JsonToPropertyValues(aFilterOptions.toUtf8());
-            aFilterData = comphelper::containerToSequence(aData);
+            try
+            {
+                std::vector<PropertyValue> aData
+                    = 
comphelper::JsonToPropertyValues(aFilterOptions.toUtf8());
+                aFilterData = comphelper::containerToSequence(aData);
+            }
+            catch (const boost::property_tree::json_parser::json_parser_error&)
+            {
+                // This wasn't a valid json; maybe came from import filter 
(tdf#162528)
+            }
             if (aFilterData.hasElements())
             {
                 aMap[u"FilterData"_ustr] <<= aFilterData;

Reply via email to