[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - shell/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 15 11:49:46 UTC 2019


 shell/source/unix/exec/shellexec.cxx |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit a0505af64fb7a6b40546b4c6b205e6828cb04564
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Nov 15 08:45:20 2019 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Nov 15 12:48:36 2019 +0100

    tdf#128538: Open filesystem directories in Finder after all
    
    Where option "-R" means, according to the open(1) man page: "Reveals the file(s)
    in the Finder instead of opening them."  This appears to always reveal in
    Finder, even for *.app "application directories", so should not affect
    CVE-2019-9847.)
    
    Change-Id: I775db7bf71c09adc6570931a977b82dfee8dc95a
    Reviewed-on: https://gerrit.libreoffice.org/82749
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    (cherry picked from commit 1ff1466b055890b2ca0ff3a47262bc048ad78542)
    Reviewed-on: https://gerrit.libreoffice.org/82757
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/shell/source/unix/exec/shellexec.cxx b/shell/source/unix/exec/shellexec.cxx
index 7355eaea0db6..313007787489 100644
--- a/shell/source/unix/exec/shellexec.cxx
+++ b/shell/source/unix/exec/shellexec.cxx
@@ -117,6 +117,7 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
         }
 
 #ifdef MACOSX
+        bool dir = false;
         if (uri->getScheme().equalsIgnoreAsciiCase("file")) {
             OUString pathname;
             auto const e1 = osl::FileBase::getSystemPathFromFileURL(aCommand, pathname);
@@ -142,8 +143,10 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
                 auto const e3 = errno;
                 SAL_INFO("shell", "stat(" << pathname8 << ") failed with errno " << e3);
             }
-            if (e2 != 0 || !S_ISREG(st.st_mode)
-                || (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0)
+            if (e2 == 0 && S_ISDIR(st.st_mode)) {
+                dir = true;
+            } else if (e2 != 0 || !S_ISREG(st.st_mode)
+                       || (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0)
             {
                 throw css::lang::IllegalArgumentException(
                     "XSystemShellExecute.execute, cannot process <" + aCommand + ">", {}, 0);
@@ -172,7 +175,11 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
         // 2.4  If it does not match an exitsting pathname (relative to CWD):
         //  Results in "The file /.../foo:bar does not exits." (where "/..." is
         //  the CWD) on stderr and SystemShellExecuteException.
-        aBuffer.append("open --");
+        aBuffer.append("open");
+        if (dir) {
+            aBuffer.append(" -R");
+        }
+        aBuffer.append(" --");
 #else
         // Just use xdg-open on non-Mac
         aBuffer.append("/usr/bin/xdg-open");


More information about the Libreoffice-commits mailing list