motlin opened a new issue, #14141:
URL: https://github.com/apache/maven/issues/14141
The `org.fusesource.jansi.Ansi` compatibility shim (in `maven-jline` for
3.10.0, `compat/maven-embedder` on master) does not respect `Ansi.isEnabled()`
in `render(...)`.
When color is disabled (for example `-B` / `--batch-mode` or
`-Dstyle.color=never`), `Ansi.ansi()` correctly returns `NoAnsi`, and `NoAnsi`
turns `fg`, `bg`, `reset`, and the rest into no-ops. But `NoAnsi` does not
override `render(String)` or `render(String, Object...)`, so it inherits:
```java
public Ansi render(final String text) {
a(new org.jline.jansi.Ansi().render(text).toString());
return this;
}
```
`new org.jline.jansi.Ansi()` bypasses any enabled check, so the ANSI escape
sequences are appended as literal text.
In Jansi 2.x, `render` went through `AnsiRenderer`, which used `Ansi.ansi()`
and therefore produced plain text when disabled.
## Reproduction
A plugin that logs `Ansi.ansi().render("@|red hello|@").toString()`, run
with `mvn -B`, prints `ESC[31mhelloESC[m` instead of `hello`.
Using `Ansi.ansi().fg(Color.RED).a("hello").reset()` prints `hello` as
expected.
## Suggested fix
Override both `render` methods in `NoAnsi` so they append the text with the
`@|code text|@` markup stripped (or delegate to `org.jline.jansi.AnsiRenderer`
with rendering disabled).
## Versions
Maven 3.10.0. The same code is present on master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]