The GitHub Actions job "Java CI" on commons-lang.git has succeeded.
Run started by GitHub user fabrice102 (triggered by garydgregory).

Head commit for run:
9646ceba6368bad58438ba49bfd58f3bff10407f / Fabrice Benhamouda 
<[email protected]>
Fix handling of non-ASCII letters & numbers in RandomStringUtils

An optimization introduced in commit
f382d61a03778ccf838c6c051bd8692e4834dec2
incorrectly assumed that letters and numbers/digits are ASCII.

For example, `RandomStringUtils.random(1, 0x4e00, 0x4e01, true, false)`
would take too long to terminate and would not output the correct
answer, that is the string with a single character `0x4e00`.
The issue is that `end` would be replaced by `'z' + 1 = 123` (the latest
ASCII letter + 1) there: 
https://github.com/apache/commons-lang/blob/f382d61a03778ccf838c6c051bd8692e4834dec2/src/main/java/org/apache/commons/lang3/RandomStringUtils.java#L266-L270
 Thus, we would have `end < start` and `gap = end - start < 0`.

This PR fixes this issue by restricting the optimization to cases
where only ASCII characters are requested, that is `end < 0x7f`.
This PR also slightly clarifies the code, using constant variables
instead of '0', '9', 'A', and 'z'.

The PR also includes two regression tests.

Report URL: https://github.com/apache/commons-lang/actions/runs/10745725967

With regards,
GitHub Actions via GitBox

Reply via email to