From 57ff3cdf6ae186218983df6bd3a79e4a3f8bcd55 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Mon, 6 Nov 2023 12:46:53 -0500 Subject: [PATCH] Throw IllegalArgumentException if input is invalid Signed-off-by: Craig Perkins --- server/src/main/java/org/opensearch/common/regex/Regex.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/common/regex/Regex.java b/server/src/main/java/org/opensearch/common/regex/Regex.java index 4aac8961e7eec..867a9b58497d4 100644 --- a/server/src/main/java/org/opensearch/common/regex/Regex.java +++ b/server/src/main/java/org/opensearch/common/regex/Regex.java @@ -160,8 +160,7 @@ private static boolean simpleMatchWithNormalizedStrings(String pattern, String s // str.endsWith(pattern.substring(1)), but avoiding the construction of pattern.substring(1): return str.regionMatches(str.length() - pattern.length() + 1, pattern, 1, pattern.length() - 1); } else if (nextIndex == 1) { - // Double wildcard "**" - skipping the first "*" - return simpleMatchWithNormalizedStrings(pattern.substring(1), str); + throw new IllegalArgumentException("Input pattern " + pattern + "contains duplicate adjacent wildcards (*)."); } final String part = pattern.substring(1, nextIndex); int partIndex = str.indexOf(part);