On Windows, in basic macros, the shell() function does not work when executing a .bat file and when the path contains spaces. The usual ConvertToURL() trick does not work when executing .bat files. To reproduce the bug: 1. Create a directory C:\Temp\Temp Folder 2. Create a test.bat file with the following content: echo Test pause and copy that file to C:\Temp and C:\Temp\Temp Folder 3. Copy C:\Windows\write.exe to C:\Temp and C:\Temp Folder to get an .exe test case 4. Create the following basic macro: Sub Test ' Works 'Shell(ConvertToURL("C:\Temp\test.bat"), 1) 'Works 'Shell(ConvertToURL("C:\Temp\write.exe"), 1) ' Works 'Shell(ConvertToURL("C:\Temp\Test Folder\write.exe"), 1) ' Does not work Shell(ConvertToURL("C:\Temp\Test Folder\test.bat"), 1) ' Works 'Shell("cmd.exe", 1, "/c " & "C:\Temp\write.exe") ' Does not work 'Shell("cmd.exe /c", 1, "C:\Temp\test.bat") ' Works 'Shell("cmd.exe /c", 1, """C:\Temp\Test Folder\write.exe""") ' Does not work 'Shell("cmd.exe /c", 1, """C:\Temp\Test Folder\test.bat""") End Sub 5. Execute the macro and check that it's only possible to execute test.bat when the path does not contain space. On the contrary, executing write.exe is possible whatever the path contains spaces or not.
Reproduced. Win 7 Pro 64-bit, Version: 5.0.3.2 (x64) Build ID: e5f16313668ac592c1bfb310f4390624e3dbfb75 Locale: fi-FI (fi_FI) LibreOffice 3.5.0rc3 Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735
** Please read this message in its entirety before responding ** To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present on a currently supported version of LibreOffice (5.1.6 or 5.2.3 https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the version of LibreOffice and your operating system, and any changes you see in the bug behavior If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a short comment that includes your version of LibreOffice and Operating System Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) http://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to "inherited from OOo"; 4b. If the bug was not present in 3.3 - add "regression" to keyword Feel free to come ask questions or to say hello in our QA chat: http://webchat.freenode.net/?channels=libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug-20170103
(In reply to QA Administrators from comment #2) I tested with LibreOffice 5.2.4 under Windows 7 64 bits SP1 and the bug is still there (100% reproducible).
** Please read this message in its entirety before responding ** To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from http://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug
I tested with LO Version: 5.4.4.2 (x64) Build ID: 2524958677847fb3bb44820e40380acbe820f960 Threads CPU : 2; OS : Windows 6.1; UI Render : par défaut; Locale : fr-FR (fr_FR); Calc: group The bug is still there. 100% reproducible!
Note: this issue is problematic for the TexMaths extension, where I used a dirty workaround to bypass the issue. Please fix!
Would also like to get this fixed... :-) Thanks in advance!
Users of TexMaths still complain about this bug. Please fix...
Created attachment 149926 [details] Patch for LibreOffice 6.2.1
Looking at the LibreOffice source code, I finally found the cause of the issue and I attach a proposed patch to this bug report. Here is the explanation: in the Windows version of LibreOffice, when calling the basic Shell(...) function (located in basic/source/runtime/methods.cxx), a function is_batch_file() is called in turn, to check if the program file path to execute is a batch or an executable. The function is_batch_file() is located in sal/osl/w32/procimpl.cxx and simply checks if the file extension is equal to bat (or cmd or btm). This works as expected, except when the file path contains space characters. In that case, the file path is *quoted* before the call to is_batch_file() and for a batch file the file extension becomes bat" (note the quote) instead of bat, and thus the call to is_batch_file() wrongly returns false in that case. I fixed this by simply adding a comparison to bat", cmd" and btm". The proposed patch is for LibreOffice 6.2.1. I built the patched version in Windows and checked that the issue has gone.
Great, can you submit your patch to gerrit for review? https://wiki.documentfoundation.org/Development/gerrit Please use the master branch for your submission.
(In reply to Buovjaga from comment #11) > Great, can you submit your patch to gerrit for review? > https://wiki.documentfoundation.org/Development/gerrit > > Please use the master branch for your submission. I submitted the patch (in master branch) using gerrit. I hope I did it well because it was much more complicated than fixing the bug!
(In reply to Roland Baudin from comment #12) > (In reply to Buovjaga from comment #11) > > Great, can you submit your patch to gerrit for review? > > https://wiki.documentfoundation.org/Development/gerrit > > > > Please use the master branch for your submission. > > I submitted the patch (in master branch) using gerrit. I hope I did it well > because it was much more complicated than fixing the bug! Yeah, it is a bit of a hurdle :) About your patch, I hope you won't get frustrated, but it would be best, if you changed the first line of the commit message to: tdf#96038 Make shell function work with paths containing spaces You can do it by giving the command git commit --amend and then editing the old message and saving. Then you can just submit the patch again and it will become a new version of the same patch. It matches it up with the help of the "Change-Id" line.
(In reply to Buovjaga from comment #13) > Then you can just submit the patch again and it will become a new version of > the same patch. It matches it up with the help of the "Change-Id" line. Done! I hope I did it the right way now...
(In reply to Roland Baudin from comment #14) > (In reply to Buovjaga from comment #13) > > Then you can just submit the patch again and it will become a new version of > > the same patch. It matches it up with the help of the "Change-Id" line. > > Done! I hope I did it the right way now... Yep! I see Stephan had a wish: "While this works, it feels a bit hackish ;) I'd prefer to instead change get_file_extension to return the extension of the unquoted pathname." If you look into that and edit the file you can do the git add <file>, git commit --amend and submit to gerrit again.
(In reply to Buovjaga from comment #15) > (In reply to Roland Baudin from comment #14) > > (In reply to Buovjaga from comment #13) > > > Then you can just submit the patch again and it will become a new version of > > > the same patch. It matches it up with the help of the "Change-Id" line. > > > > Done! I hope I did it the right way now... > > Yep! I see Stephan had a wish: "While this works, it feels a bit hackish ;) > I'd prefer to instead change get_file_extension to return the extension of > the unquoted pathname." > > If you look into that and edit the file you can do the git add <file>, git > commit --amend and submit to gerrit again. OK, I submitted a new version of the patch that does (hopefully) what Stephan requested.
Roland Baudin committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/+/cf89d6dbfd72e60e459b2ffef313a6d8b477857b%5E%21 tdf#96038 Make shell function work with paths containing spaces It will be available in 6.3.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Roland Baudin committed a patch related to this issue. It has been pushed to "libreoffice-6-2": https://git.libreoffice.org/core/+/8ecd161ac9c36bcabd98c6d5e22c72fbb8d03502%5E%21 tdf#96038 Make shell function work with paths containing spaces It will be available in 6.2.3. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.