You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Robert Muir (Jira)" <ji...@apache.org> on 2022/02/26 21:53:00 UTC

[jira] [Resolved] (LUCENE-10430) Literal double quotes cause exception in class RegExp

     [ https://issues.apache.org/jira/browse/LUCENE-10430?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Muir resolved LUCENE-10430.
----------------------------------
    Resolution: Not A Problem

You aren't escaping the quote. You're sending a java string of length 1 ("). You need to create the string as "\\\"" in java so that it is of length 2 (\").

> Literal double quotes cause exception in class RegExp
> -----------------------------------------------------
>
>                 Key: LUCENE-10430
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10430
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/other
>    Affects Versions: 9.0
>            Reporter: Holger Rehn
>            Priority: Major
>
> Class org.apache.lucene.util.automaton.RegExp fails to parse valid regular expressions that contain double quotes (except in character classes). This of course affects corresponding RegexpQuerys, as well.
> Example: 
> {code:java}
> Query  q = new RegexpQuery( new Term( "field", "a\"b" ) );
> RegExp r = new RegExp( "a\"b" );{code}
> Both fail with:
> {code:java}
> java.lang.IllegalArgumentException: expected '"' at position 3
>     at org.apache.lucene.util.automaton.RegExp.parseSimpleExp(RegExp.java:1299)
>     at org.apache.lucene.util.automaton.RegExp.parseCharClassExp(RegExp.java:1229)
>     at org.apache.lucene.util.automaton.RegExp.parseComplExp(RegExp.java:1218)
>     at org.apache.lucene.util.automaton.RegExp.parseRepeatExp(RegExp.java:1192)
>     at org.apache.lucene.util.automaton.RegExp.parseConcatExp(RegExp.java:1185)
>     at org.apache.lucene.util.automaton.RegExp.parseConcatExp(RegExp.java:1187)
>     at org.apache.lucene.util.automaton.RegExp.parseInterExp(RegExp.java:1179)
>     at org.apache.lucene.util.automaton.RegExp.parseUnionExp(RegExp.java:1173)
>     at org.apache.lucene.util.automaton.RegExp.<init>(RegExp.java:496)
>     ...{code}
> As a workaround we currently replace all double quotes with a dot.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org