commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kalyan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLI-262) Util.stripLeadingAndTrailingQuotes strips quotes that are unmatched
Date Tue, 20 Dec 2016 10:41:58 GMT

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

Kalyan commented on CLI-262:
----------------------------

similar problem .. i am also having. can you please consider i suggestion also.

"\"aaaa\"" is given output aaaa, expecting "aaaa"
'"aaaa"' is given output aaaa, expecting "aaaa"

to solve this issue, i am writing like below

"\"\"aaaa\"\"" is given output "aaaa", expecting "aaaa"

reason for this  line

https://github.com/apache/commons-cli/blob/trunk/src/main/java/org/apache/commons/cli/Parser.java#L352



> 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.4#6332)

Mime
View raw message