This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 3f07b29fb9 Fix #12052: tokenize arithmetic operators as delimiters in 
ConditionParser (#12053)
3f07b29fb9 is described below

commit 3f07b29fb965c48b65582f8434a667d37687909f
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Jun 16 18:45:14 2026 +0200

    Fix #12052: tokenize arithmetic operators as delimiters in ConditionParser 
(#12053)
    
    The tokenizer did not recognize `-`, `*`, `/` as delimiter characters,
    so expressions like `5-3` or `6*4` (without spaces) were tokenized as
    single tokens and failed to parse.
    
    Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
 .../org/apache/maven/impl/model/profile/ConditionParser.java |  3 +++
 .../apache/maven/impl/model/profile/ConditionParserTest.java | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git 
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
 
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
index 2f6a075f87..4b73b5217e 100644
--- 
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
+++ 
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
@@ -134,6 +134,9 @@ private List<String> tokenize(String expression) {
                     || c == ')'
                     || c == ','
                     || c == '+'
+                    || c == '-'
+                    || c == '*'
+                    || c == '/'
                     || c == '>'
                     || c == '<'
                     || c == '='
diff --git 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
index 990af0d7e3..be1da09919 100644
--- 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
+++ 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
@@ -242,6 +242,18 @@ void testArithmeticFunctions() {
         assertEquals(2.5, parser.parse("5 / 2"));
     }
 
+    @Test
+    void testArithmeticWithoutSpaces() {
+        assertEquals(5.0, parser.parse("2+3"));
+        assertEquals(10.0, parser.parse("15-5"));
+        assertEquals(24.0, parser.parse("6*4"));
+        assertEquals(3.0, parser.parse("9/3"));
+        assertEquals(14.0, parser.parse("2+3*4"));
+        assertEquals(20.0, parser.parse("(2+3)*4"));
+        assertEquals(-5.0, parser.parse("-5"));
+        assertEquals(-5.0, parser.parse("-(2+3)"));
+    }
+
     @Test
     void testCombinedArithmeticAndLogic() {
         assertTrue((Boolean) parser.parse("(5 > 3) && (10 / 2 == 5)"));

Reply via email to