From 01df38aad6719f84d8a8a94638d2748666766ebc Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 9 Nov 2023 12:59:13 -0500 Subject: [PATCH] [Refactor] Use iterative approach to evaluate Regex.simpleMatch (#11060) * Remove adjacent duplicates to optimize regex before processing Signed-off-by: Craig Perkins * Add tests Signed-off-by: Craig Perkins * Rename to removeAdjacentDuplicates Signed-off-by: Craig Perkins * Add additional test case Signed-off-by: Craig Perkins * Add CHANGELOG entry Signed-off-by: Craig Perkins * Throw IllegalArgumentException if input is invalid Signed-off-by: Craig Perkins * Add a space Signed-off-by: Craig Perkins * Change error message Signed-off-by: Craig Perkins * Use iterative solution with 2 pointers Signed-off-by: Craig Perkins * Remove unused method Signed-off-by: Craig Perkins * add tests and changelog Signed-off-by: Stephen Crawford * remove bad push Signed-off-by: Stephen Crawford * Update CHANGELOG.md Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> * Update CHANGELOG.md Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> * spotless Signed-off-by: Stephen Crawford * Update comment Signed-off-by: Craig Perkins * re-run CI Signed-off-by: Craig Perkins --------- Signed-off-by: Craig Perkins Signed-off-by: Craig Perkins Signed-off-by: Stephen Crawford Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Co-authored-by: Stephen Crawford Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> (cherry picked from commit 61a598bad7ce095219790e78196b1ae5b7428316) --- CHANGELOG.md | 1 - server/src/test/java/org/opensearch/common/regex/RegexTests.java | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7626f489057a..36d5dd6cd49e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,4 +15,3 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Fixed ### Security -[Unreleased]: https://github.com/opensearch-project/OpenSearch/compare/1.3.12...HEAD diff --git a/server/src/test/java/org/opensearch/common/regex/RegexTests.java b/server/src/test/java/org/opensearch/common/regex/RegexTests.java index 4a3772b77fde7..b94bb16cbc4b2 100644 --- a/server/src/test/java/org/opensearch/common/regex/RegexTests.java +++ b/server/src/test/java/org/opensearch/common/regex/RegexTests.java @@ -96,6 +96,7 @@ public void testDoubleWildcardMatch() { assertFalse(Regex.simpleMatch("fff**ddd", "fffabcdd")); assertTrue(Regex.simpleMatch("fff*******ddd", "fffabcddd")); assertTrue(Regex.simpleMatch("fff*******ddd", "FffAbcdDd", true)); + assertFalse(Regex.simpleMatch("fff*******ddd", "FffAbcdDd", false)); assertFalse(Regex.simpleMatch("fff******ddd", "fffabcdd")); assertFalse(Regex.simpleMatch("fff*******ddd", "FffAbcdDd", false)); assertTrue(Regex.simpleMatch("abCDefGH******ddd", "abCDefGHddd", false));