Skip to content

Commit

Permalink
Merge pull request #106 from internetstaff/utf8
Browse files Browse the repository at this point in the history
isParseable should reject chars > 256 instead of throwing ArrayIndexOutOfBoundsException
  • Loading branch information
fabiolimace authored Mar 1, 2025
2 parents dac7204 + 93c6219 commit d71bde2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public static void validate(final char[] uuid, int version) {
protected static boolean isParseable(final char[] chars) {
int dashCount = 0;
for (int i = 0; i < chars.length; i++) {
if (MAP.get(chars[i]) == -1) {
if (chars[i] > MAP.length() || MAP.get(chars[i]) == -1) {
if (chars[i] == '-') {
dashCount++;
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public void testIsValidString() {
uuid = "01234567-89ab-4def-!@#$-ef0123456789"; // String with non alphanumeric chars
assertFalse("UUID string non alphanumeric chars should be invalid.", UuidValidator.isValid(uuid));


uuid = "01234567-89ab-4def-😊🤖-ef0123456789"; // String with UTF8 chars
assertFalse("UUID string UTF8 chars should be invalid.", UuidValidator.isValid(uuid));

try {
uuid = null;
UuidValidator.validate(uuid);
Expand Down

0 comments on commit d71bde2

Please sign in to comment.