From 56dcb86538afa27a0c379cbcab7dd02cd8277cf8 Mon Sep 17 00:00:00 2001 From: Akron Date: Wed, 13 Sep 2023 07:43:32 +0200 Subject: [PATCH] Disallow empty regex in PQ+ Change-Id: Ifcda331007866616e6bd079e8d331dec9d1f880a Reviewed-on: https://korap.ids-mannheim.de/gerrit/c/KorAP/Koral/+/7512 Reviewed-by: Nils Diewald --- Changes | 3 +++ pom.xml | 2 +- src/main/antlr/poliqarpplus/Regex.g4 | 2 +- .../korap/query/test/poliqarpplus/PQGrammarTest.java | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index ecd5b3d5..3e98baaa 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +0.41 2023-09-13 + - [bugfix] Disallow empty regex in PQ+ (diewald) + 0.40 2023-07-26 - [feature] Initial support for CQP (irimia, margaretha, diewald) diff --git a/pom.xml b/pom.xml index 8e38774a..6bdd5574 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ de.ids_mannheim.korap Koral - 0.40.0 + 0.41.0 jar Koral https://korap.ids-mannheim.de diff --git a/src/main/antlr/poliqarpplus/Regex.g4 b/src/main/antlr/poliqarpplus/Regex.g4 index f83b3955..48c98082 100644 --- a/src/main/antlr/poliqarpplus/Regex.g4 +++ b/src/main/antlr/poliqarpplus/Regex.g4 @@ -15,4 +15,4 @@ fragment RE_chgroup : '[' '^'? RE_char+ ']'; fragment RE_quant : ('.' | RE_char | RE_chgroup | ( '(' RE_expr ')')) ('?' | '*' | '+' | RE_focc) '?'?; fragment RE_group : '(' RE_expr ')'; fragment RE_expr : ('.' | RE_char | RE_alter | RE_chgroup | RE_quant | RE_group | '^' )+; -fragment RE_dquote : ('"'|'„'|'“') (RE_expr | '\'' | ':' )* ('"'|'“'|'”'); \ No newline at end of file +fragment RE_dquote : ('"'|'„'|'“') (RE_expr | '\'' | ':' )+ ('"'|'“'|'”'); \ No newline at end of file diff --git a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PQGrammarTest.java b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PQGrammarTest.java index 536ae0c2..2b45c6a7 100644 --- a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PQGrammarTest.java +++ b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PQGrammarTest.java @@ -59,7 +59,7 @@ public void dquoutes () { // how it behaves assertEquals( - "(request (query (segment (token (key (regex \"\"))))) )", + "(request query )", // see different behaviour of " and '; for ", the query is parsed and an empty regex is generated treeString("\"\"\"") ); // how it should behave @@ -68,7 +68,7 @@ public void dquoutes () { treeString("\"\"\"") ); assertEquals( - "(request (query (sequence (segment (token (key (regex \"\")))) (segment (token (key -key))))) )", // see different behaviour of " and '; for ", the query is parsed and an empty regex is generated + "(request (query (segment (token (key -key)))) )", // see different behaviour of " and '; for ", the query is parsed and an empty regex is generated treeString("\"\"-key\"") ); assertEquals(