Github user anujgandharv commented on a diff in the pull request:

    https://github.com/apache/jena/pull/406#discussion_r183642709
  
    --- Diff: 
jena-text-es/src/main/java/org/apache/jena/query/text/es/TextIndexES.java ---
    @@ -422,6 +422,27 @@ public EntityDefinition getDocDef() {
         }
     
         private String parse(String fieldName, String qs, String lang) {
    +        //Escape special characters if any in the query string
    +        qs = qs.replaceAll("\\:", "\\\\:")
    +                .replaceAll("\\+", "\\\\+")
    +                .replaceAll("\\-", "\\\\-")
    +                .replaceAll("\\=", "\\\\=")
    +                .replaceAll("\\&", "\\\\&")
    +                .replaceAll("\\|", "\\\\|")
    +                .replaceAll("\\>", "\\\\>")
    +                .replaceAll("\\<", "\\\\<")
    +                .replaceAll("\\!", "\\\\!")
    +                .replaceAll("\\(", "\\\\(")
    +                .replaceAll("\\)", "\\\\)")
    +                .replaceAll("\\{", "\\\\{")
    +                .replaceAll("\\}", "\\\\}")
    +                .replaceAll("\\]", "\\\\]")
    +                .replaceAll("\\[", "\\\\[")
    +                .replaceAll("\\^", "\\\\^")
    +                .replaceAll("\\~", "\\\\~")
    +                .replaceAll("\\?", "\\\\?");
    +
    --- End diff --
    
    So, what i understand is that backslashes need to be escaped even before 
they reach the Jena ES query method, just like double quotes. Therefore i 
haven't added the check for it. I can add a unit test depicting the escaping of 
backslash in the query string itself. Let me know if that would help.


---

Reply via email to