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

Josh Elser commented on ACCUMULO-4336:
--------------------------------------

bq. What do you think the patch should do?

Honestly, not sure :). I haven't looked at the issue with enough focus.

bq.  A defensive approach could minimally prevent compactions when an empty 
string is detected, throwing an exception.

Prevent compactions? I don't follow what you're suggesting here.

bq. The stripping of leading and trailing quotes within the commons-cli 
dependency would need to be disabled (which does not seem to be an existing 
capability within that API) or Accumulo would need to do its own 
parsing/validation. 

Given what you wrote, this seems to be the approach to take.

> Command line interpreter escaping issues
> ----------------------------------------
>
>                 Key: ACCUMULO-4336
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-4336
>             Project: Accumulo
>          Issue Type: Bug
>          Components: shell
>            Reporter: Matt Peterson
>            Priority: Minor
>
> To see the problem, add the following unit test.  It will fail.
> {code:title=ShellTest.java|borderStyle=solid}
> Test
> public void scanEscapedQuote() throws Exception {
>   exec("createtable test", true);
>   exec("insert \\\" f q v", true);
>   exec("scan", true, "\" f: q []    v"); // passes
>   exec("scan -e \\\"", true, "\" f: q []    v"); // fails
>   exec("deletetable test -f", true, "Table: [test] has been deleted");
> }
> {code}
> It appears that the commons-cli library that is used for parsing commands 
> will strip the leading \" from the option's value and return an empty string. 
>  
> {code:title=Parser.java, line 332|borderStyle=solid}
> opt.addValueForProcessing(Util.stripLeadingAndTrailingQuotes(str));
> {code}
> For scans, an empty string as an end row will cause the scan to do nothing, 
> which is a reasonable way to fail.  
> For compactions, an empty string as an end row will cause the end row to be 
> ignored, which can lead to accidentally initiating a compaction over much of 
> a table.  It is not possible to test the compaction issue with ShellTest 
> because MockTableOperationsImpl does not do anything with compactions.  But 
> the problem code can be seen in the constructor for CompactRange:
> {code:title=CompactRange.java|borderStyle=solid}
> this.endRow = endRow.length == 0 ? null : endRow;
> {code}
> This code will treat an end row of \" as though there was no end row at all.
> The workaround for this is to use the \x22 instead of \".
> Additionally, some characters are not possible to include as either begin or 
> end rows.  For example, a ! character cannot be escaped but without escaping 
> will crash the shell.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to