shell/source/win32/SysShExec.cxx |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

New commits:
commit 289d22c83b5568f54fab94e8a02a20b8ea904841
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Tue Feb 16 09:30:09 2021 +0100
Commit:     Gabor Kelemen <kelemen.gab...@nisz.hu>
CommitDate: Thu Apr 22 20:15:37 2021 +0200

    Improve checkExtension
    
    Change-Id: Iff416a9c5930ad5903f7ee51a2abbc94d5f40800
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110970
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit f456c4dacf700e064e112ef068ff7edb04239754)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110922
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit f19d95986756412e5d72047656eec17a720c5e57)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114501
    Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu>

diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx
index c98940be64a1..837b1b8b9a80 100644
--- a/shell/source/win32/SysShExec.cxx
+++ b/shell/source/win32/SysShExec.cxx
@@ -321,21 +321,28 @@ void SAL_CALL CSysShExec::execute( const OUString& 
aCommand, const OUString& aPa
                 }
             }
             pathname = o3tl::toU(path);
+            // ShellExecuteExW appears to ignore trailing dots, so remove them:
+            while (pathname.endsWith(".", &pathname)) {}
             auto const n = pathname.lastIndexOf('.');
             if (n > pathname.lastIndexOf('\\')) {
                 auto const ext = pathname.copy(n + 1);
-                OUString env;
-                if (osl_getEnvironment(OUString("PATHEXT").pData, &env.pData) 
!= osl_Process_E_None)
-                {
-                    SAL_INFO("shell", "osl_getEnvironment(PATHEXT) failed");
-                }
-                if (!(checkExtension(ext, env)
-                      && checkExtension(
-                          ext,
-                          
".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.CLASS;.JAR")))
-                {
-                    throw css::lang::IllegalArgumentException(
-                        "XSystemShellExecute.execute, cannot process <" + 
aCommand + ">", {}, 0);
+                if (!ext.isEmpty()) {
+                    OUString env;
+                    if (osl_getEnvironment(OUString("PATHEXT").pData, 
&env.pData)
+                        != osl_Process_E_None)
+                    {
+                        SAL_INFO("shell", "osl_getEnvironment(PATHEXT) 
failed");
+                    }
+                    if (!(checkExtension(ext, env)
+                          && checkExtension(
+                              ext,
+                              
".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.CLASS;"
+                                  ".JAR;.APPLICATION;.LNK;.SCR")))
+                    {
+                        throw css::lang::IllegalArgumentException(
+                            "XSystemShellExecute.execute, cannot process <" + 
aCommand + ">", {},
+                            0);
+                    }
                 }
             }
         }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to