Skip to content
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

Fix NetBeans launch failure on unix shell for arguments with quotes et al #7908

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sid-srini
Copy link
Contributor

Issue

When NetBeans is launched on *nix shell with arguments that contain special characters like quotes, spaces, $ and backticks, then it may fail or not receive the arguments correctly.

The launcher scripts are:

  • java/java.lsp.server/script/bin/nbcode
  • platform/o.n.bootstrap/launcher/unix/nbexec

The cause is due to incomplete escaping of the special characters before quoting the argument.
Examples:

  • --jdkhome "$HOME/openjdk's jdkhome"
  • --jdkhome '/home/user/tools/jdk "23"'
  • --jdkhome /c/Program\ Files/Java/jdk
  • --userdir "/mnt/user's macbook pro/Users/user/Library/Application Support/NetBeans"
  • -Dnetbeans.extra.dirs="nb-dev\$old/extras/plugin1:nb-dev\$old/extras/plugin2:ext/My Plugins/quo\"'d"

Further, a discrepancy is created between the argument strings passed on a Windows host (using the launcher exe/dll) and *nix hosts.

Fix

  1. Ensure that all arguments are quoted before passing forward to the executable launch.
    • This is implemented similar to other open-source build tools.
    • Example: ant
  2. Ensure that the special characters ' " $ ` in the argument are escaped according to the quoting being performed.
  3. Consistently use eval with arguments single-quoted and parameter substitution within it being double-quoted.
    • This makes nbexec similar to the nbcode script
  4. Updated the unit test for nbexec.

…t al

**Issue**

When NetBeans is launched on *nix shell with arguments that contain
special characters like quotes, spaces, $ and backticks, then it may
fail or not receive the arguments correctly.

The launcher scripts are:
- java/java.lsp.server/script/bin/nbcode
- platform/o.n.bootstrap/launcher/unix/nbexec

The cause is due to incomplete escaping of the special characters before
quoting the argument.

**Fix**

1. Ensure that all arguments are quoted before passing forward to the
   executable launch.
    - This is implemented similar to other open-source build tools.
    - Example: [ant](https://github.com/apache/ant/blob/master/src/script/ant#L63)
2. Ensure that the special characters ' " $ ` in the argument are
   escaped according to the quoting being performed.
3. Consistently use `eval` with arguments single-quoted and parameter
   substitution within it being double-quoted.
    - This makes `nbexec` similar to the `nbcode` script
4. Updated the unit test for `nbexec`

Signed-off-by: Siddharth Srinivasan <siddharth.srinivasan@oracle.com>
@mbien mbien added LSP [ci] enable Language Server Protocol tests Platform [ci] enable platform tests (platform/*) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Oct 24, 2024
@sid-srini
Copy link
Contributor Author

@neilcsmith-net - Please review this PR whenever its possible for you, and provide any suggestions for it. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) LSP [ci] enable Language Server Protocol tests Platform [ci] enable platform tests (platform/*)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants