Re: apache commons cli 1.10.0: infinite loop in HelpFormatter.printHelp()

Gary Gregory <[email protected]> Mon, 29 Sep 2025 14:38:24 -0400
Newsgroups gmane.comp.jakarta.commons.user
Message-ID <CACZkXPzEJkU4S8POsJEoQQJ+dSogCsHw1KaettkxCCcbmsDozg@mail.gmail.com>
I can reproduce this. Any thoughts on a fix, Claude?

Gary

On Mon, Sep 29, 2025 at 12:40=E2=80=AFPM Damien Carbonne
<[email protected]> wrote:
>
> Hi,
>
> Starting with commons-cli-1.10.0, HelpFormatter enters an infinite loop
> when its is passed a header or footer that contains 2 or more new line
> (\n) characters.
>
> The following code shows this behaviour:
>
>          final HelpFormatter formatter =3D HelpFormatter.builder().get();
>
>          // OK
>          formatter.printHelp("CL syntax",
>                              "Header",
>                              Collections.emptyList(),
>                              "Footer",
>                              true);
>
>          // KO Header (same behaviour with footer)
>          formatter.printHelp("CL syntax",
>                              "Header\n\n", // This makes printHelp enter
> into an infinite loop
>                              Collections.emptyList(),
>                              "Footer",
>                              true);
>
> It looks like a regression. Using several new line characters with
> previous versions of CLI was working.
> Even if using new line character in header or footer was forbidden, this
> should not end in an infinite loop.
>
> Regards,
>
> Damien Carbonne
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>