Re: apache commons cli 1.10.0: infinite loop in HelpFormatter.printHelp()
Claude Warren <[email protected]> Tue, 30 Sep 2025 09:40:27 +0100
| Newsgroups | gmane.comp.jakarta.commons.user |
|---|---|
| Message-ID | <CAOQrJk7ib=gpDfVDCxut=VrF6jjEQ8w8xfDov5wWUvu2e=9swA@mail.gmail.com> |
--000000000000d80403064000b4f8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Opened ticket: https://issues.apache.org/jira/browse/CLI-351 to track. I have found the issue and a fix. On Mon, Sep 29, 2025 at 7:38=E2=80=AFPM Gary Gregory <[email protected]= m> 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 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 ente= r > > 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, thi= s > > 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] > > --=20 LinkedIn: http://www.linkedin.com/in/claudewarren --000000000000d80403064000b4f8--