[maven-4.0.x] Avoid parsing MAVEN_OPTS (master/4.x) (#10970) by gnodet · Pull Request #10993 · apache/maven (original) (raw)

@BobVul

Fixes apache#10937 by introducing an additional INTERNAL_MAVEN_OPTS for any arguments that need to be inserted by the script. Parsing the externally-defined MAVEN_OPTS variable can lead to incorrect processing of quotes and special characters, so use the separate variable to avoid doing so.

Additionally JVM_CONFIG_MAVEN_OPTS is introduced as its own variable to preserve the append behaviour.

Remove quotes from the new JVM_CONFIG_MAVEN_OPTS to also allow quoted pipes to work from jvm.config This is a follow-up to apache#10937, where the extra layer of quotes causes parsing issues in Windows cmd

Test that adding pipes to either MAVEN_OPTS or jvm.config does not break anything Note: it is important that a jvm.config exists for the MAVEN_OPTS portion of the test to work

By default xargs handles quotes specially. To avoid this behaviour, -0 must be used instead, but first we need to convert LF to NUL. Since quotes are no longer being stripped by xargs, we should also stop trying to add them back in otherwise nested quotes cause further issues


Co-authored-by: Bob BobVul@users.noreply.github.com (cherry picked from commit aeff353)

@gnodet mentioned this pull request

Jul 24, 2025

8 tasks

@gnodet gnodet deleted the backport/maven-4.0.x/pr-10970 branch

September 2, 2025 05:27

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})