Skip to content

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

Open
gnodet wants to merge 2 commits into
apache:maven-4.0.xfrom
gnodet:cherry-pick-12038-to-4.0.x
Open

Backport #12038: Fix ConditionParser to handle newlines before && operator#12259
gnodet wants to merge 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants