Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Escaping special characters in searches #28

Closed
lguariento opened this issue Jan 29, 2022 · 8 comments
Closed

[BUG] Escaping special characters in searches #28

lguariento opened this issue Jan 29, 2022 · 8 comments

Comments

@lguariento
Copy link
Contributor

lguariento commented Jan 29, 2022

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
Copy link
Member

line-o commented Jan 29, 2022

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

  • double quotes for phrase searches: "this is my search term"
  • asterisk for fuzzy searches: *
  • how about question marks: ?

@lguariento
Copy link
Contributor Author

lguariento commented Jan 29, 2022

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
Copy link
Member

line-o commented Jan 30, 2022

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

@line-o
Copy link
Member

line-o commented Jan 31, 2022

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

@lguariento
Copy link
Contributor Author

Here it is.

@lguariento
Copy link
Contributor Author

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

@line-o
Copy link
Member

line-o commented Jan 31, 2022

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

@lguariento
Copy link
Contributor Author

Closing this and opening this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants