Below command:
C:\users\xxx\jasypt-1.9.3\bin> ./encrypt.bat password=password input=test.com/test?v=v&w=w
complains questions mark ("&") is not allowed. So I tried escaping it as "&"
or ^&
but Jasypt seemed to strip &
and what comes after it.
C:\users\xxx\jasypt-1.9.3\bin> ./encrypt.bat password=password input=test.com/test?v=v^&w=w
...
----ARGUMENTS-------------------
input: test.com/test?v=v
password: password
...
'w' is not recognized as an internal or external command,
operable program or batch file.
How would I make it so that Jasypt reads it as literal ampersand or is this a windows thing?
PowerShell's escape character is `
(backtick), not ^
, which is specific to cmd.exe.
However, an unquoted &
is a metacharacter (a character with special syntactic meaning) in both shells.
Therefore, to ensure that PowerShell passes &
through as-is to ./encrypt.bat
, all of the following variations work (since your argument contains no references to PowerShell variables ($...
), "..."
(expandable (interpolating) string) and '...'
(literal string) can be used interchangeably):
./encrypt.bat password=password input=test.com/test?v=v`&w=w
./encrypt.bat password=password input=test.com/test?v=v"&"w=w
./encrypt.bat password=password input=test.com/test?v=v'&'w=w
./encrypt.bat password=password "input=test.com/test?v=v&w=w"
./encrypt.bat password=password 'input=test.com/test?v=v&w=w'
Since you say that it is ./encryp.bat
that complained, the implication is that ./encrypt.bat
is poorly implemented and doesn't use "..."
to further process the arguments it receives, causing cmd.exe
metacharacters such as &
to break processing.
To counteract that, you must additionally anticipate cmd.exe
's escaping needs and include a literal ^
in the argument passed from PowerShell:
./encrypt.bat password=password 'input=test.com/test?v=v^&w=w'