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

Escape query chars #72

Open
d-rivera-c-zz opened this issue Jun 2, 2015 · 4 comments
Open

Escape query chars #72

d-rivera-c-zz opened this issue Jun 2, 2015 · 4 comments
Labels

Comments

@d-rivera-c-zz
Copy link

I get a 400 error in Solr if any of this characters are around

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \ /

Sometimes it behaves well if the character is surrounded by letters instead of spaces, but should be better to escape them anyway. For example, searching for "Wellington/Petone" won't give an error, but "Wellington / Petone" will.
I've added a preg_replace as a workaround, might be worth a look to include it as a fix in the module.

SolrIndex.php (line 376, function search() )

foreach ($query->search as $search) {
    $text = $search['text'];
    $text = preg_replace('/([\+\-!\(\)\{\}\[\]\^"~\*\?:\\/\|]|&&|\|\|)/', '\\\${1}', $text);   <---
    preg_match_all('/"[^"]*"|\S+/', $text, $parts);
@robbieaverill
Copy link
Contributor

Needs revalidation

@dhensby
Copy link
Contributor

dhensby commented Oct 20, 2017

I've had this issue- it's a problem with the solr library we are using being old and not correctly escaping special chars even though it has the feature.

@micmania1
Copy link

@robbieaverill I haven't tried all chars but I can confirm it works with " so I assume others too. Likewise, AND and OR seem to trigger this too.

@maxime-rainville
Copy link

Need to validate if this is a problem with SS4.

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

No branches or pull requests

5 participants