From a221ccce94564232e5b8672dfcfe0d4f7105ff04 Mon Sep 17 00:00:00 2001 From: Anders Jensen-Urstad Date: Thu, 28 Nov 2024 17:29:47 +0100 Subject: [PATCH] fix(rest/search2): index of out bounds if query is whitespace or ends with double whitespace --- whelk-core/src/main/groovy/whelk/search2/parse/Lex.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/whelk-core/src/main/groovy/whelk/search2/parse/Lex.java b/whelk-core/src/main/groovy/whelk/search2/parse/Lex.java index 76e9744cfd..8b7eee5192 100644 --- a/whelk-core/src/main/groovy/whelk/search2/parse/Lex.java +++ b/whelk-core/src/main/groovy/whelk/search2/parse/Lex.java @@ -38,9 +38,7 @@ public static LinkedList lexQuery(String queryString) throws InvalidQuer } private static void consumeWhiteSpace(StringBuilder query, MutableInteger offset) { - if (query.isEmpty()) - return; - while (Character.isWhitespace(query.charAt(0))) { + while (!query.isEmpty() && Character.isWhitespace(query.charAt(0))) { query.deleteCharAt(0); offset.increase(1); }