Handle whitespace when removing -J* parameters in .bat
apksigner.bat contains special logic for -J* parameters. This logic
was not designed to handle parameters containing whitespace. This
commit fixes the issue. It is unclear whether this -J* logic is even
needed. So, if it keeps breaking stuff, we should probably simply
remove it.
Test: apksigner sign --ks "nonexistent.jks" --ks-pass pass:123123 --ks-key-alias "bug apksigner test" nonexistent.apk
Fails with FileNotFoundException instead of "a was unexpected at this time"
Bug: 38132450
Change-Id: Ice3294e9993b075533c77d94eb870cfd35a65bbc
diff --git a/etc/apksigner.bat b/etc/apksigner.bat
index 024f4e1..360e142 100755
--- a/etc/apksigner.bat
+++ b/etc/apksigner.bat
@@ -59,19 +59,19 @@
:firstArg
if [%1]==[] goto endArgs
-set a=%~1
+set "a=%~1"
if [%defaultXmx%]==[] goto notXmx
- if %a:~0,5% NEQ -JXmx goto notXmx
+ if "%a:~0,5%" NEQ "-JXmx" goto notXmx
set defaultXmx=
:notXmx
if [%defaultXss%]==[] goto notXss
- if %a:~0,5% NEQ -JXss goto notXss
+ if "%a:~0,5%" NEQ "-JXss" goto notXss
set defaultXss=
:notXss
- if %a:~0,2% NEQ -J goto notJ
+ if "%a:~0,2%" NEQ "-J" goto notJ
set javaOpts=%javaOpts% -%a:~2%
shift /1
goto firstArg