Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 92978 invoked from network); 22 Jun 2010 17:47:17 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Jun 2010 17:47:17 -0000 Received: (qmail 73184 invoked by uid 500); 22 Jun 2010 17:47:16 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 73074 invoked by uid 500); 22 Jun 2010 17:47:16 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 73066 invoked by uid 99); 22 Jun 2010 17:47:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jun 2010 17:47:16 +0000 X-ASF-Spam-Status: No, hits=-1537.0 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jun 2010 17:47:15 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o5MHksqG019357 for ; Tue, 22 Jun 2010 17:46:55 GMT Message-ID: <4859877.16981277228814950.JavaMail.jira@thor> Date: Tue, 22 Jun 2010 13:46:54 -0400 (EDT) From: "Chris Lee (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (CLI-193) StringIndexOutOfBoundsException in HelpFormatter.findWrapPos In-Reply-To: <1528495818.20601264211961544.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CLI-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12881262#action_12881262 ] Chris Lee commented on CLI-193: ------------------------------- Well, that would be easy enough to fix, but that's at odds with how the method is documented now. It currently says it will ONLY break on a newline or space ("The wrap point is the last postion before startPos+width having a whitespace character (space, \n, \r)."). In addition to that, it's currently looking for whitespace AFTER startPos+width (also at odds with documentation). How should it actually behave? I've attached another patch that will preserve the existing functionality (looking for spaces after startPos+width) but reverts back to returning startPos+width if none is found. If, instead, it should *never* allow for a string longer than startPos+width, then current lines 908-912 should probably just be removed. This will cause "wrap position 3" unit test to fail though. > StringIndexOutOfBoundsException in HelpFormatter.findWrapPos > ------------------------------------------------------------ > > Key: CLI-193 > URL: https://issues.apache.org/jira/browse/CLI-193 > Project: Commons CLI > Issue Type: Bug > Components: CLI-1.x > Affects Versions: 1.2 > Reporter: Travis McLeskey > Priority: Critical > Fix For: 1.3 > > Attachments: cli-helpformatter-stringIndexOOB-2.patch, cli-helpformatter-stringIndexOOB.patch > > Original Estimate: 0.08h > Remaining Estimate: 0.08h > > In the last while loop in HelpFormatter.findWrapPos, it can pass text.length() to text.charAt(int), which throws a StringIndexOutOfBoundsException. The first expression in that while loop condition should use a <, not a <=. > This is on line 908 in r779646: > http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli/HelpFormatter.java?revision=779646&view=markup -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.