Skip to content

Backport #12038: Fix ConditionParser to handle newlines before && operator#12259

Merged
gnodet merged 2 commits into
apache:maven-4.0.xfrom
gnodet:cherry-pick-12038-to-4.0.x
Jun 13, 2026
Merged

Backport #12038: Fix ConditionParser to handle newlines before && operator#12259
gnodet merged 2 commits into
apache:maven-4.0.xfrom
gnodet:cherry-pick-12038-to-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Backport of #12038 to 4.0.x branch.

blaspat and others added 2 commits June 13, 2026 10:02
* Fix ConditionParser to handle newlines before && operator

Fix for apache#11882

The tokenize() method only treated space as whitespace, so newlines
became standalone tokens. When a line break appeared before &&,
the operator was parsed as two separate & tokens instead of one &&.

Added \n, \r, \t to whitespace handling and properly tokenize &&
as a single operator token regardless of surrounding whitespace.

Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>

* Update impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>

* Update impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>

* Update impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>

* fix: handle || operator and remove & from X= lookahead

Address review feedback from gnodet on PR apache#12038:
- Remove c == '&' from the >=/<= /==/!= lookahead (&= is not valid)
- Add || tokenization symmetrically with &&
- Add regression tests for || with line breaks

Fixes apache#11882

Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>

---------

Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
@gnodet gnodet merged commit 9dfe909 into apache:maven-4.0.x Jun 13, 2026
22 checks passed
@github-actions github-actions Bot added this to the 4.0.0-rc-6 milestone Jun 13, 2026
@github-actions

Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants