fix: PowerShell quoting for special chars and -D property spacing in app install#2585
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| static Pattern cmdSafeChars = Pattern.compile("[a-zA-Z0-9.,_+=:;@()-\\\\]*"); | ||
| // TODO: Figure out what the real list of safe characters is for PowerShell | ||
| static Pattern pwrSafeChars = Pattern.compile("[a-zA-Z0-9.,_+=:@()\\\\-]*"); | ||
| static Pattern pwrSafeChars = Pattern.compile("[a-zA-Z0-9_+=@\\\\-]*"); |
There was a problem hiding this comment.
what is tricky is that
jbang com.h2database:h2:1.4.200
is fine, but
jbang -Dsdff=sdfd.df com.h2database:h2:1.4.200
is not. the kicker is - needs more quoting than regular arguments.
for now let them be quoted (meaning on windows installed scripts will quote the arguments with GAV.
might want to refine it in future .
turns out we had "bad" quoting rules on windows since 2020 :)
-Dwhatever.period=true breaks on powershell, works on cmd.exe
and since 2024 our install scripts generated
-D x=yinstead of-Dx=ycausing issues too.This fixes both.
1. PowerShell safe chars too permissive (#2584)
pwrSafeCharsincluded.,;:()as safe characters, inherited from original best-guess allowlist (47b9f34, 2020). These characters cause issues in PowerShell — args like-Djavafx.preview=truewere passed through unquoted and got mangled.Fix: Remove
.,;:()frompwrSafeChars. Args containing these chars now get single-quoted in PowerShell (e.g.'-Djavafx.preview=true'). CMD is unchanged — these chars are safe there.2.
app install -Dkey=valuesplits-Dfrom property (#2564)DependencyInfoMixin.opts()emitted-Dandkey=valueas two separate list elements. The generated wrapper script ended up with-D camel.jbang.version=4.21.0(space-separated), whichjbang runthen rejects with "Option -D, must be part of a property".Fix: Join them:
opts.add("-D" + key + "=" + value).Tests added
TestCommandBuffer— PowerShell escapes.,;:(), CMD does notTestApp.testAppInstallWithSystemProperty— verifies generated scripts contain-Dkey=value(no space)AppIT.shouldKeepSystemPropertyAttached— end-to-end:app install -Djavafx.preview=trueruns and JVM receives the property intactFixes #2584
Fixes #2564