You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/11/20 07:09:00 UTC

[jira] [Work logged] (LANG-1533) RandomStringUtils.random() should not include \u0000

     [ https://issues.apache.org/jira/browse/LANG-1533?focusedWorklogId=514484&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-514484 ]

ASF GitHub Bot logged work on LANG-1533:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Nov/20 07:08
            Start Date: 20/Nov/20 07:08
    Worklog Time Spent: 10m 
      Work Description: arturobernalg opened a new pull request #654:
URL: https://github.com/apache/commons-lang/pull/654


   Add Character.CONTROL 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 514484)
    Remaining Estimate: 0h
            Time Spent: 10m

> RandomStringUtils.random() should not include \u0000 
> -----------------------------------------------------
>
>                 Key: LANG-1533
>                 URL: https://issues.apache.org/jira/browse/LANG-1533
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.8.1
>            Reporter: Daniel Vega
>            Priority: Minor
>         Attachments: 0001-xxx.patch
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When generating random strings we should not include char 0x00 by default. This is problematic for many tools and libraries. For example, if we try to save this value in a PosgreSQL database we'll get:
>  
> {quote}PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00
> {quote}
>  
> Currently we are avoiding some code code-point ranges. We should also skip {{codePoint=0}}
> {code:none}
> --- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
> +++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
> @@ -400,6 +400,12 @@ public static String random(int count, int start, int end, final boolean letters
>              if (chars == null) {
>                  codePoint = random.nextInt(gap) + start;
>  
> +                // Skip codePoint \u0000 because is problematic for some tools/libraries
> +                if (codePoint==0) {
> +                    count++;
> +                    continue;
> +                }
> +
>                  switch (Character.getType(codePoint)) {
>                  case Character.UNASSIGNED:
>                  case Character.PRIVATE_USE:
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)