@@ -568,6 +568,22 @@ private static long[] parseUuid(String uuid) {
568568 } else if (uuid .endsWith ("}" )) {
569569 throw new IllegalArgumentException ("Invalid UUID string: " + originalUuid );
570570 }
571+ if (uuid .length () != 36
572+ || uuid .charAt (8 ) != '-'
573+ || uuid .charAt (13 ) != '-'
574+ || uuid .charAt (18 ) != '-'
575+ || uuid .charAt (23 ) != '-' ) {
576+ throw new IllegalArgumentException ("Invalid UUID string: " + originalUuid );
577+ }
578+ for (int i = 0 ; i < uuid .length (); i ++) {
579+ if (i == 8 || i == 13 || i == 18 || i == 23 ) {
580+ continue ;
581+ }
582+ char c = uuid .charAt (i );
583+ if (!isHexChar (c )) {
584+ throw new IllegalArgumentException ("Invalid UUID string: " + originalUuid );
585+ }
586+ }
571587 try {
572588 UUID parsed = UUID .fromString (uuid );
573589 return new long [] {parsed .getMostSignificantBits (), parsed .getLeastSignificantBits ()};
@@ -576,6 +592,12 @@ private static long[] parseUuid(String uuid) {
576592 }
577593 }
578594
595+ private static boolean isHexChar (char c ) {
596+ return (c >= '0' && c <= '9' )
597+ || (c >= 'a' && c <= 'f' )
598+ || (c >= 'A' && c <= 'F' );
599+ }
600+
579601 private TargetRange encodeKeyInternal (
580602 BiFunction <Integer , String , Value > valueFinder , KeyType keyType ) {
581603 UnsynchronizedByteArrayOutputStream ssKey = new UnsynchronizedByteArrayOutputStream ();
0 commit comments