Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 28E43104B3 for ; Thu, 17 Oct 2013 07:17:02 +0000 (UTC) Received: (qmail 41389 invoked by uid 500); 17 Oct 2013 07:16:52 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 41059 invoked by uid 500); 17 Oct 2013 07:16:48 -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 41031 invoked by uid 99); 17 Oct 2013 07:16:47 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Oct 2013 07:16:47 +0000 Date: Thu, 17 Oct 2013 07:16:47 +0000 (UTC) From: "Henri Yandell (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LANG-808) RandomStringUtils inefficient init of start and end for letters and numbers; misleading Javadoc 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/LANG-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13797679#comment-13797679 ] Henri Yandell commented on LANG-808: ------------------------------------ Originally I'm sure I thought of it as a password generator, so ASCII was an assumption I wasn't noticing. We should note this in the javadoc, see if we can clean any of it up and consider if there's a possible refactoring of the API that would be more valuable. > RandomStringUtils inefficient init of start and end for letters and numbers; misleading Javadoc > ----------------------------------------------------------------------------------------------- > > Key: LANG-808 > URL: https://issues.apache.org/jira/browse/LANG-808 > Project: Commons Lang > Issue Type: Bug > Components: lang.* > Affects Versions: 2.6, 3.1 > Reporter: Sebb > Fix For: Patch Needed > > > If either letters or numbers is true, RandomStringUtils(count, 0, 0, letters, numbers, ...) sets the default start index to space, intending to support the set of printable characters (according to the Javadoc). > However, the code later uses Character.isLetter and Character.isDigit, which exclude space and some other printable characters. > There is currently no direct support for generating printable characters; this would probably require another flag. > The current Javadoc is misleading, and the current code is inefficient because some characters cannot currently be used. > The lowest char which is either digit or letter is '0' (zero). > The lowest char which is a letter is 'A' (upper case a). > The Javadoc for the randomNumeric(int) method says: > bq. Characters will be chosen from the set of numeric characters. > This does not make clear that the numerics are restricted to the ASCII set (because of the way start=end=0 is handled). > Similarly for randomAlphabetic and randomAlphanumeric. > Is it the intention that randomAlphabetic etc. be restricted to ASCII? -- This message was sent by Atlassian JIRA (v6.1#6144)