eXist-db / website

the eXist-db.org website
GNU General Public License v3.0
2 stars 5 forks source link

[BUG] Escaping special characters in searches #28

Closed lguariento closed 2 years ago

lguariento commented 2 years ago

When the input search string contains a parenthesis Lucene interprets it as an unescaped special character. For instance, searching for test) or httpclient() .

line-o commented 2 years ago

I assume you propose that we escape any special character from searches. Followign exceptions could be useful (even used)

lguariento commented 2 years ago

Do you know of a way of escaping them other than JavaScript? How I'd do it is by adding something like 'on submit, look for these characters and add a \ before them'.

document.getElementById("search_button").addEventListener('click', function () {
  let text = document.getElementById('search_field_id').value;
  let regex = /:/gi; <- the regex. In this case I am escaping the semicolon
  let new_text = text.replaceAll(regex, "\\:");
  document.getElementById('search_field_id').value =  new_text;
});
line-o commented 2 years ago

The special characters in the search term should be escaped on the server (in xquery).

line-o commented 2 years ago

Can you dig up where is the search query is being sent to?

lguariento commented 2 years ago

Here it is.

lguariento commented 2 years ago

Actually this issue is about the /documentation repository rather than this, I think.

line-o commented 2 years ago

Yep, I agree. And it will then also be fixed for both.

lguariento commented 2 years ago

Closing this and opening this.