Skip to content

Commit

Permalink
fix: QueryUtils#escape should handle nulls (resolves gh-452)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsbodden committed Jun 5, 2024
1 parent 09fdb2b commit 356bef3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public static String escape(String text) {
}

public static String escape(String text, boolean querying) {
if (text == null) {
return null;
}
var sb = new StringBuilder();
char[] chars = text.toCharArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ void testSearchIndexFieldAlliasFor() {
assertEquals(field.getName(), outputWhenPrefixBlank);
assertEquals("roger_green_redis", outputWhenPrefixValid);
}

@Test
void testEscapeWithNullValue() {
assertEquals(null, QueryUtils.escape(null));
}

@Test
void testEscapeWithBlankValue() {
assertEquals("", QueryUtils.escape(""));
}
}

0 comments on commit 356bef3

Please sign in to comment.