Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-185

Commons CLI incorrectly stripping leading and trailing quotes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1, 1.2
    • Fix Version/s: 1.3
    • Component/s: Parser
    • Labels:
      None
    • Environment:

      Description

      org.apache.commons.cli.Parser.processArgs() calls Util.stripLeadingAndTrailingQuotes() for all argument values. IMHO this is incorrect and totally broken.

      It is trivial to create a simple test for this. Output:

      $ java -cp target/clitest.jar Clitest --balloo "this is a \"test\""
      Value of argument balloo is 'this is a "test'.

      The argument 'balloo' should indeed keep its trailing double quote. It is what the shell gives it, so don't try to do something clever to it.

      The offending code was committed here:
      http://svn.apache.org/viewvc?view=rev&revision=129874
      and has been there for more than 6 years . Why was this committed in the first place?

      The fix is trivial, just get rid of Util.stripLeadingAndTrailingQuotes(), and consequently avoid calling it from Parser.processArgs().

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                einarmr Einar M R Rosenvinge
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: