Fix bracket escaping for null string

Change-Id: I2e3f7554477876ce983c49ba0a8989a5ec7459d1
diff --git a/src/main/java/de/ids_mannheim/korap/util/KrillString.java b/src/main/java/de/ids_mannheim/korap/util/KrillString.java
index 8d0da5a..f6eb3f3 100644
--- a/src/main/java/de/ids_mannheim/korap/util/KrillString.java
+++ b/src/main/java/de/ids_mannheim/korap/util/KrillString.java
@@ -74,6 +74,8 @@
      * @return The secured string.
      */
     public static String escapeBrackets (String text) {
+        if (text == null)
+            return "";
         return text.replaceAll("([\\{\\}\\[\\]\\\\])", "\\\\$1");
     };
 
diff --git a/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java b/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
index d03f331..8829670 100644
--- a/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
+++ b/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
@@ -32,6 +32,16 @@
     };
 
     @Test
+    public void testBrackets () {
+        assertEquals("hu\\[hu", escapeBrackets("hu[hu"));
+        assertEquals("hu\\]hu", escapeBrackets("hu]hu"));
+        assertEquals("hu\\}hu", escapeBrackets("hu}hu"));
+        assertEquals("hu\\{hu", escapeBrackets("hu{hu"));
+        assertEquals("", escapeBrackets(null));
+    };
+
+    
+    @Test
     public void testSurrogateSubstrings () {
 
         // Follows https://stackoverflow.com/questions/55663213/java-substring-by-code-point-indices-treating-pairs-of-surrogate-code-units-as