-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
appclient can't pass arguments with double-quote properly. #21863
Labels
Comments
@amykang2020 Commented |
|
st24
added a commit
to st24/glassfish
that referenced
this issue
Nov 19, 2019
…n client arguments (eclipse-ee4j#21863) Signed-off-by: st24 <sato-tsuyoshi@fujitsu.com>
This issue has been marked as inactive and old and will be closed in 7 days if there is no further activity. If you want the issue to remain open please add a comment |
arjantijms
added a commit
that referenced
this issue
Oct 20, 2021
Fix #21863 appclient can't pass arguments with double-quote properly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
appclient can't pass arguments with double-quote properly.
There are multiple problems for only Windows, for only Linux, and for both Windows and Linux.
Environment Details
Problem Description
appclient can't pass arguments with double-quote properly.
Using this sample appclient program to check passed arguments.
Sample appclient program is attached as EchoAppclient.zip
Whitespace is trimmed when argument length <= 2 (Windows, Linux)
Expected is
but was (args[2] is not passed)
Multiple whitespaces become single whitespace (Linux)
Expected is
but was
Escape-sequence don't work in double-quote (Windows)
Expected is
but was
Expected is
but was
Escape-sequence is evaluated twice (Linux)
Expected is
but was
Expected is
but was
Expected is
but was
Expected is
but was
Steps to reproduce
appclient -client /path/to/client/EchoAppclientClient.jar "a " " b" " " "a b" "a\"b\"c" "a \" b \" c" "\\\""
Fix
appclient calls CLIBootstrap class to generate java command line string, then appclient calls that command line string to execute appclient main program.
In Windows, environment variable is used to pass arguments to CLIBootstrap. So parsing environment variables is required in CLIBootstrap.
In Linux, eval command is used to execute java command line string generated by CLIBootstrap.
Whitespace is trimmed when argument length <= 2 (Windows, Linux)
CLIBootstrap.quote(String) method quotes argument with double-quote if argument length > 2. As argument with length <=2 is not quoted, whitespace is trimmed when executing command line string generated by CLIBootstrap.
CLIBootstrap.quote(String) is used other than quoting arguments, so create new inner class CommandLineArgument (which extends CommandLineElement) to fix quoting command line arguments only.
Multiple whitespaces become single whitespace (Linux)
Escape-sequence is evaluated twice (Linux)
These two problems have same cause: command line arguments are evaluated twice.
To avoid evaluating command line arguments twice, double-quoted single argument must be passed to eval command.
So adding double-quote to whole eval command arguments fixes these problems.
Escape-sequence don't work in double-quote (Windows)
CLIBootstrap parses environment variables using RegExp. But this RegExp pattern doesn't consider escape-sequence in double-quote. So fix RegExp pattern to consider escape-sequence in double-quote.
The text was updated successfully, but these errors were encountered: