Re: apache commons cli 1.10.0: infinite loop in HelpFormatter.printHelp()
Gary Gregory <[email protected]> Tue, 30 Sep 2025 06:57:02 -0400
| Newsgroups | gmane.comp.jakarta.commons.user |
|---|---|
| Message-ID | <CACZkXPwZ3KNX8xZuLY7sgqO97T9ESLb1fMN6VKbJ9euU6=36Yw@mail.gmail.com> |
On Tue, Sep 30, 2025 at 5:04=E2=80=AFAM Claude Warren <[email protected]> wr= ote: > > Opened ticket: https://issues.apache.org/jira/browse/CLI-351 to track. > I have found the issue and a fix. TY Claude! PR merged. This is now fixed in git master and snapshot builds https://repository.apache.org/content/repositories/snapshots/commons= -cli/commons-cli/1.10.1-SNAPSHOT Gary > > On Mon, Sep 29, 2025 at 7:38=E2=80=AFPM Gary Gregory <garydgregory@gmail.= com> wrote: > > > 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 lo= op > > > when its is passed a header or footer that contains 2 or more new lin= e > > > (\n) characters. > > > > > > The following code shows this behaviour: > > > > > > final HelpFormatter formatter =3D HelpFormatter.builder().ge= t(); > > > > > > // 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 en= ter > > > 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, t= his > > > should not end in an infinite loop. > > > > > > Regards, > > > > > > Damien Carbonne > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [email protected] > > > For additional commands, e-mail: [email protected] > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > -- > LinkedIn: http://www.linkedin.com/in/claudewarren