commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ajay Kidave (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CLI-185) Commons CLI incorrectly stripping leading and trailing quotes
Date Mon, 28 Sep 2009 19:38:16 GMT

    [ https://issues.apache.org/jira/browse/CLI-185?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760358#action_12760358
] 

Ajay Kidave commented on CLI-185:
---------------------------------

In my case, removing the quotes for an argument is fine, I don't think this behavior should
be changed. The issue is, for an argument like "abc"test"" (nested double quotes), the removal
of quotes removes the last two quotes, the argument becomes abc"test  instead of being abc"test"
.

Looking at the original patch, this could happen if stripLeadingAndTrailingQuotes function
gets called two times, first one will do the proper stripping, second stripping will incorrectly
 remove the last quote. A possible fix would be to check if first and last char are both quotes.
If both are, then do the stripping. This change should not break the API compatibility, unless
someone depends on the incorrect behavior.


> Commons CLI incorrectly stripping leading and trailing quotes
> -------------------------------------------------------------
>
>                 Key: CLI-185
>                 URL: https://issues.apache.org/jira/browse/CLI-185
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.1, 1.2
>         Environment: Darwin dator 9.7.0 Darwin Kernel Version 9.7.0: Tue Mar 31 22:52:17
PDT 2009; root:xnu-1228.12.14~1/RELEASE_I386 i386
> GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0)
> and
> Linux build-einarmr 2.6.9-023stab048.4-smp #1 SMP Fri Jul 11 18:50:44 MSD 2008 x86_64
x86_64 x86_64 GNU/Linux
> GNU bash, version 3.00.15(1)-release (x86_64-redhat-linux-gnu)
>            Reporter: Einar M R Rosenvinge
>             Fix For: 1.3
>
>
> 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().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message