-
-
Notifications
You must be signed in to change notification settings - Fork 405
Escape LIKE queries #11
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! It's definitely an interesting one. I'd prefer to see this fixed in core but as that might take a couple more weeks I'll pull this in here for now 👍
src/Filters/FiltersPartial.php
Outdated
->addBinding("%{$this->escapeLike($value)}%"); | ||
} | ||
|
||
private function escapeLike(string $value): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this one protected
? This way it's a bit easier for people to extend if they'd want to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course!
Hi @ntzm After merging this in we still ran into some problems. In tests using sqlite everything seems to work perfectly fine. select * from `media` where `name` LIKE %test% ESCAPE \"\\\" Any ideas for a quick fix? |
Damn sorry, should have tested. I'm at work now, I'll figure something out later. Probably worth reverting if you have more stuff to release. My bad |
This reverts commit 5cfece7.
This reverts commit 5cfece7.
Don't worry about it! Reverted it for now but I'll keep an eye on laravel/framework#22864 for any updates as well 👍 |
Thanks, and sorry again! |
I can't for the life of me figure out how to prevent that from happening |
I've made a PR to deal with this in core: laravel/framework#22864
Basically there was inconsistency between some DB servers, and also %, _ and \ weren't being escaped.