From 6d44508c4d3b5aba8925d7cc4f0943ecd9447bb2 Mon Sep 17 00:00:00 2001 From: si-chakraborty Date: Wed, 17 Jul 2024 11:56:49 +0200 Subject: [PATCH 1/2] fix(search): Search not returning result if query text contains forward slash --- .../com/linkedin/datahub/graphql/resolvers/ResolverUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java index f2682ad050c86..54b6eb60133a7 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java @@ -71,7 +71,7 @@ public static T bindArgument(Object argument, Class clazz) { @Nonnull public static String escapeForwardSlash(@Nonnull String input) { if (input.contains("/")) { - input = input.replace("/", "\\\\/"); + input = input.replace("/", "\\/"); } return input; } From 9bd1b414db5699136c19ca16c3fca91253f1865f Mon Sep 17 00:00:00 2001 From: si-chakraborty Date: Wed, 17 Jul 2024 15:35:33 +0200 Subject: [PATCH 2/2] updated test cases --- datahub-frontend/app/utils/SearchUtil.java | 2 +- datahub-frontend/test/utils/SearchUtilTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/datahub-frontend/app/utils/SearchUtil.java b/datahub-frontend/app/utils/SearchUtil.java index 803c70a63646a..cfbf11c2ffa85 100644 --- a/datahub-frontend/app/utils/SearchUtil.java +++ b/datahub-frontend/app/utils/SearchUtil.java @@ -20,7 +20,7 @@ private SearchUtil() { @Nonnull public static String escapeForwardSlash(@Nonnull String input) { if (input.contains("/")) { - input = input.replace("/", "\\\\/"); + input = input.replace("/", "\\/"); } return input; } diff --git a/datahub-frontend/test/utils/SearchUtilTest.java b/datahub-frontend/test/utils/SearchUtilTest.java index 6767fa5637469..2efc4420c7f76 100644 --- a/datahub-frontend/test/utils/SearchUtilTest.java +++ b/datahub-frontend/test/utils/SearchUtilTest.java @@ -8,10 +8,10 @@ public class SearchUtilTest { @Test public void testEscapeForwardSlash() { // escape "/" - assertEquals("\\\\/foo\\\\/bar", SearchUtil.escapeForwardSlash("/foo/bar")); + assertEquals("\\/foo\\/bar", SearchUtil.escapeForwardSlash("/foo/bar")); // "/" is escaped but "*" is not escaped and is treated as regex. Since currently we want to // retain the regex behaviour with "*" - assertEquals("\\\\/foo\\\\/bar\\\\/*", SearchUtil.escapeForwardSlash("/foo/bar/*")); + assertEquals("\\/foo\\/bar\\/*", SearchUtil.escapeForwardSlash("/foo/bar/*")); assertEquals("", ""); assertEquals("foo", "foo"); }