[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - desktop/qa desktop/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Sat Apr 20 10:38:30 UTC 2019


 desktop/qa/desktop_app/test_desktop_app.cxx |   23 +++++++++++++++++++++++
 desktop/source/app/cmdlineargs.cxx          |   10 +++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit a8e019f021b5b1aa51deca704657758944511a8e
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Apr 17 12:33:13 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Apr 20 12:38:03 2019 +0200

    SharePoint connection: Better handling of encoded URLs
    
    Handle %7c with small letters.
    Make sure that the output parameter's content is not
    affected by decoding.
    
    Change-Id: Ie3faad2461815497c0edfb04a589fc57aeb7d66b
    Reviewed-on: https://gerrit.libreoffice.org/70873
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit f6dc5636c1eda8aebeac3f7b85dd61499523d6a3)
    Reviewed-on: https://gerrit.libreoffice.org/70984
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/desktop/qa/desktop_app/test_desktop_app.cxx b/desktop/qa/desktop_app/test_desktop_app.cxx
index 055c8cf5434e..1a027dfade78 100644
--- a/desktop/qa/desktop_app/test_desktop_app.cxx
+++ b/desktop/qa/desktop_app/test_desktop_app.cxx
@@ -113,7 +113,7 @@ void Test::testTdf100837() {
 
     {
         // 3. Test enocded URLs
-        TestSupplier supplier{ "foo", "ms-word:ofe%7Cu%7Cbar1", "ms-word:ofv%7Cu%7Cbar2", "ms-word:nft%7Cu%7Cbar3", "baz" };
+        TestSupplier supplier{ "foo", "ms-word:ofe%7Cu%7cbar1", "ms-word:ofv%7cu%7Cbar2", "ms-word:nft%7Cu%7cbar3", "baz" };
         desktop::CommandLineArgs args(supplier);
         auto vOpenList = args.GetOpenList();
         auto vForceOpenList = args.GetForceOpenList();
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx
old mode 100755
new mode 100644
index f117040e6261..54ee1ae98231
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -129,25 +129,25 @@ CommandLineEvent CheckOfficeURI(/* in,out */ OUString& arg, CommandLineEvent cur
     long nURIlen = -1;
 
     // URL might be encoded
-    rest1 = rest1.replaceAll("%7C", "|");
+    OUString decoded_rest = rest1.replaceAll("%7C", "|").replaceAll("%7c", "|");
 
     // 2. Discriminate by command name (incl. 1st command argument descriptor)
     //    Extract URI: everything up to possible next argument
-    if (rest1.startsWith("ofv|u|", &rest2))
+    if (decoded_rest.startsWith("ofv|u|", &rest2))
     {
         // Open for view - override only in default mode
         if (curEvt == CommandLineEvent::Open)
             curEvt = CommandLineEvent::View;
         nURIlen = rest2.indexOf("|");
     }
-    else if (rest1.startsWith("ofe|u|", &rest2))
+    else if (decoded_rest.startsWith("ofe|u|", &rest2))
     {
         // Open for editing - override only in default mode
         if (curEvt == CommandLineEvent::Open)
             curEvt = CommandLineEvent::ForceOpen;
         nURIlen = rest2.indexOf("|");
     }
-    else if (rest1.startsWith("nft|u|", &rest2))
+    else if (decoded_rest.startsWith("nft|u|", &rest2))
     {
         // New from template - override only in default mode
         if (curEvt == CommandLineEvent::Open)
commit f0cdc4d1aba2ca3ef4d83f323d6e60e760df31ce
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Apr 16 10:45:12 2019 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Apr 20 12:37:46 2019 +0200

    SharePoint connection: Handle encoded URL passed as command line argument
    
    Change-Id: I3352bf9ade88bd86f7ca3d53238364216547d52b
    Reviewed-on: https://gerrit.libreoffice.org/70830
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 2317ad572cc330c4c2de95065ef275f58a9c83a1)
    Reviewed-on: https://gerrit.libreoffice.org/70983
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/desktop/qa/desktop_app/test_desktop_app.cxx b/desktop/qa/desktop_app/test_desktop_app.cxx
index ef588a580266..055c8cf5434e 100644
--- a/desktop/qa/desktop_app/test_desktop_app.cxx
+++ b/desktop/qa/desktop_app/test_desktop_app.cxx
@@ -110,6 +110,29 @@ void Test::testTdf100837() {
         CPPUNIT_ASSERT_EQUAL(OUString("bar"),  vForceOpenList[0]);
         CPPUNIT_ASSERT_EQUAL(OUString("baz"), vForceOpenList[1]);
     }
+
+    {
+        // 3. Test enocded URLs
+        TestSupplier supplier{ "foo", "ms-word:ofe%7Cu%7Cbar1", "ms-word:ofv%7Cu%7Cbar2", "ms-word:nft%7Cu%7Cbar3", "baz" };
+        desktop::CommandLineArgs args(supplier);
+        auto vOpenList = args.GetOpenList();
+        auto vForceOpenList = args.GetForceOpenList();
+        auto vViewList = args.GetViewList();
+        auto vForceNewList = args.GetForceNewList();
+        // 2 documents go to Open list: foo; baz
+        CPPUNIT_ASSERT_EQUAL(decltype(vOpenList.size())(2), vOpenList.size());
+        CPPUNIT_ASSERT_EQUAL(OUString("foo"), vOpenList[0]);
+        CPPUNIT_ASSERT_EQUAL(OUString("baz"), vOpenList[1]);
+        // 1 document goes to ForceOpen list: bar1
+        CPPUNIT_ASSERT_EQUAL(decltype(vForceOpenList.size())(1), vForceOpenList.size());
+        CPPUNIT_ASSERT_EQUAL(OUString("bar1"), vForceOpenList[0]);
+        // 1 document goes to View list: bar2
+        CPPUNIT_ASSERT_EQUAL(decltype(vViewList.size())(1), vViewList.size());
+        CPPUNIT_ASSERT_EQUAL(OUString("bar2"), vViewList[0]);
+        // 1 document goes to ForceNew list: bar3
+        CPPUNIT_ASSERT_EQUAL(decltype(vForceNewList.size())(1), vForceNewList.size());
+        CPPUNIT_ASSERT_EQUAL(OUString("bar3"), vForceNewList[0]);
+    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx
old mode 100644
new mode 100755
index f65f2fad9ebb..f117040e6261
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -127,6 +127,10 @@ CommandLineEvent CheckOfficeURI(/* in,out */ OUString& arg, CommandLineEvent cur
 
     OUString rest2;
     long nURIlen = -1;
+
+    // URL might be encoded
+    rest1 = rest1.replaceAll("%7C", "|");
+
     // 2. Discriminate by command name (incl. 1st command argument descriptor)
     //    Extract URI: everything up to possible next argument
     if (rest1.startsWith("ofv|u|", &rest2))


More information about the Libreoffice-commits mailing list