apache / apache/maven

[MNG-7194] PluginParameterExpressionEvaluator incorrectly interpolates unknown subexpression

Open
#8,255 9 comments 0 reactions 0 assignees View on GitHub
bug priority:minor
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 40m
Merged PRs (30d)
275

Description

**[Robert Scholte](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=rfscholte)** opened **[MNG-7194](https://issues.apache.org/jira/browse/MNG-7194?redirect=false)** and commented

The PluginParameterExpressionEvaluator evaluate(String,Class)-method ends like this:

```java
if ( value instanceof String )
{
// TODO: without #, this could just be an evaluate call...
String val = (String) value;
int exprStartDelimiter = val.indexOf( "${" );
if ( exprStartDelimiter >= 0 )
{
if ( exprStartDelimiter > 0 )
{
value = val.substring( 0, exprStartDelimiter ) + evaluate( val.substring( exprStartDelimiter ) );
}
else
{
value = evaluate( val.substring( exprStartDelimiter ) );
}
}
}
```

Assume that pre${unknown} needs to be evaluated and `unknown` does not exist, the result well be "`prenull`"

Just ${unknown} evaluates to null, but because there's no String concat it will be a real null.

---

**Issue Links:**
- [MENFORCER-363](https://issues.apache.org/jira/browse/MENFORCER-363) Unexpected result from requireProperty with regex when the property is not fully resolved
(_**"causes"**_)

**Remote Links:**
- [GitHub Pull Request #1570
](https://github.com/apache/maven/pull/1570)
- [GitHub Pull Request #1571
](https://github.com/apache/maven/pull/1571)
- [GitHub Pull Request #1573
](https://github.com/apache/maven/pull/1573)
- [GitHub Pull Request #1574
](https://github.com/apache/maven/pull/1574)

0 votes, 6 watchers

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.