slachiewicz opened a new pull request, #434:
URL: https://github.com/apache/maven-shared-utils/pull/434

   `CmdShell` builds one `cmd.exe /X /C "<line>"` string and never quoted the 
items inside it, so an executable path with parentheses or an argument with `&` 
was parsed by `cmd.exe` as operators. This adds `CmdShell.quoteOneItem`: an 
item that contains whitespace or one of the characters `cmd.exe /?` lists as 
special (`& < > ( ) @ ^ |`) is wrapped in double quotes; an item already 
wrapped in double quotes is left alone; `setQuotedArgumentsEnabled(false)` and 
`setUnconditionalQuoting(true)` keep their meaning.
   
   Two things differ from the earlier attempts (#40, MSHARED-851). The quoting 
is conditional on the documented character set rather than unconditional, and 
it is confined to `CmdShell`, so `BourneShell` is untouched. It also restores 
something master lost in ef89c5a (#369): before that commit 
`Shell.quoteOneItem` double-quoted items containing a space through 
`quoteAndEscape`, and 3.4.2 still ships that behaviour. 
`Shell.getQuotingTriggerChars` was the dead remainder of that mechanism and is 
removed here.
   
   Two behaviour changes to be aware of:
   
   - The `^&` workaround from #268 stops working. `^&` contains `&`, so it is 
now quoted, and `^` is literal inside quotes, so the program receives `^&`. 
Users who applied it must drop it.
   - Under `-Djdk.lang.Process.allowAmbiguousCommands=false`, Java rejects a 
quoted argument that contains further quotes. Previously only caller-supplied 
inner quotes could trigger that; now any space or special character does. 
Default JVMs are unaffected.
   
   `CmdShellTest` pins the string shape on every platform. Two tests in 
`CommandLineUtilsTest` run only on Windows and execute a real `cmd.exe`: `echo 
a&b` must print `"a&b"` rather than run `b`, and a script under a `lol(1)` 
directory must run. The three windows-latest CI jobs are the evidence for those.
   
   Fixes #268, which also covers the parentheses case from #286.
   
   Verified: `mvn -B verify` on JDK 17 (macOS) -> Tests run: 800, Failures: 0, 
Errors: 0, Skipped: 19; spotless clean; the Windows execution tests are pending 
CI.
   
   *This change was created with AI assistance.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to