RFR: 8282008: Incorrect handling of quoted arguments in ProcessBuilder [v3]
Maxim Kartashev
duke at openjdk.java.net
Tue Mar 1 08:16:06 UTC 2022
On Mon, 28 Feb 2022 21:30:27 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Olga Mikhaltsova has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add a new line to the end of test file for JDK-8282008
>
> (I'm still working on a more nuanced fix that works with .exe, .cmd, and with allowAmbiguousCommands both true and false).
>
> The suggested workaround was to remove the application quotes and let ProcessBuilder do the quoting.
> That resulted in an extra backslash "\" at the end of a file path. In my investigation, the extra "\" doesn't prevent the
> string from being correctly used as a directory path in either VisualBasic or cmd.exe.
> So I'm curious, in the original application that uncovered this problem, what is/was reported as the error?
> Was the original application retested with the workaround?
>
> The case of the backslash at the end of an argument occurs mainly in a directory path.
> Yes, the argument is different, but does it make a difference that matters in the context in which it appears.
@RogerRiggs
Our use case was something like this `java -classpath "C:\Program Files\MySQL\JDBC\" ...`. More specifically, while this works after JDK-8250568 (the string ends with `"`)
ProcessBuilder("java.exe", "-classpath", ""C:\\New folder"", "Test", "test");
this doesn't and, as I understand, shouldn't (the string ends with `"`):
ProcessBuilder("java.exe", "-classpath", ""C:\\New folder\\"", "Test", "test");
and produces errors like these
Error: Could not find or load main class folder"" Test test
Caused by: java.lang.ClassNotFoundException: folder"" Test test
However, the following still doesn't work, but, I believe, should (the string ends with `\"`):
ProcessBuilder("java.exe", "-classpath", ""C:\\New folder\\\\"", "Test", "test");
-------------
PR: https://git.openjdk.java.net/jdk/pull/7504
More information about the core-libs-dev
mailing list