diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-02-16 09:30:09 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-05-10 23:31:54 +0200 |
commit | 70acef544db618ded97e9550a2519930d30e3fba (patch) | |
tree | 99b2cdf56190fe0d8a1b508e7bbaead5c3027fc9 | |
parent | af34e2c563a1535e25c4ca9a933cb90299b8eef2 (diff) |
Improve checkExtension
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110970
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
(cherry picked from commit f456c4dacf700e064e112ef068ff7edb04239754)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110922
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit f19d95986756412e5d72047656eec17a720c5e57)
Change-Id: Iff416a9c5930ad5903f7ee51a2abbc94d5f40800
-rw-r--r-- | shell/source/win32/SysShExec.cxx | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx index 1d0932e5db8d..19e0223f37d0 100644 --- a/shell/source/win32/SysShExec.cxx +++ b/shell/source/win32/SysShExec.cxx @@ -389,21 +389,28 @@ void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aPa } } pathname = OUString(SAL_U(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); + } } } } |