[
https://issues.apache.org/jira/browse/CLI-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15852112#comment-15852112
]
Dustin Cote commented on CLI-262:
---------------------------------
[~sashivit01] I don't know, I opened this a year ago and maybe things have
changed. The code you are showing isn't checking for unmatched quotes either so
I doubt it. The description in the JIRA is pretty clear I think in terms of
outlining a test case for you. For your specific question:
{code}
-option 'command "suboption"'
{code}
actually returned
{code}
command "suboption
{code}
which is unexpected from a user standpoint. Maybe simple code inspection isn't
the answer and I might suggest trying the test case out on the latest version
in case someone has since fixed it? Because I've opened this a year ago (and
got no traction) I've lost a bit of interest in fixing it but if you want to
start it back up, please let me know and I'll try to look into how I ran into
this in the first place.
> Util.stripLeadingAndTrailingQuotes strips quotes that are unmatched
> -------------------------------------------------------------------
>
> Key: CLI-262
> URL: https://issues.apache.org/jira/browse/CLI-262
> Project: Commons CLI
> Issue Type: Bug
> Components: Parser
> Reporter: Dustin Cote
> Priority: Minor
>
> Util.stripLeadingAndTrailingQuotes is described as:
> {code}
> /**
> * Remove the leading and trailing quotes from <code>str</code>.
> * E.g. if str is '"one two"', then 'one two' is returned.
> *
> * @param str The string from which the leading and trailing quotes
> * should be removed.
> *
> * @return The string without the leading and trailing quotes.
> */
> {code}
> However, in cases where you have
> {code}
> "'one two'
> {code}
> the returned result is:
> {code}
> 'one two'
> {code}
> This leads to unexpected results. For example, an option like:
> {code}
> -option 'command "suboption"'
> {code}
> ends up being parsed as:
> {code}
> command "suboption
> {code}
> The method should be modified to only strip unmatched quotes or a new method
> should be made and added to the API.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)