-
-
Notifications
You must be signed in to change notification settings - Fork 235
Allow escaping special single-character wildcard "_" when doing partial matching #2550
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
712edc1 to
2c101fa
Compare
|
Related documentation on the web interface: pi-hole/web#3578 |
rrobgill
left a comment
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.
All working correctly both via API, and through the web interface.
Escaped underscore now searches correctly, and unescaped underscore remains as single character wildcard.
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.
Pull Request Overview
This PR enables escaping of underscore characters in domain and client name searches to prevent unintended wildcard matching. By default, SQLite treats _ as a single-character wildcard, but users can now escape underscores with \_ to match literal underscore characters.
- Add
ESCAPE '\\'clause to SQL LIKE queries to enable backslash escaping - Increase buffer allocation for like_name to accommodate escaped characters
- Replace sprintf with snprintf for safer string formatting
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/database/gravity-db.c | Add ESCAPE clause to LIKE queries and improve memory allocation/string formatting |
| src/api/queries.c | Add ESCAPE clause to domain and client search queries |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…s/adlists/clients/gravity/domainlist matching Signed-off-by: DL6ER <[email protected]>
…ing for the Query Log table Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
76b19e0 to
e0037e6
Compare
|
Rebased onto latest |
What does this implement/fix?
See title. Discussion ongoing in that issue ticket, hence, opening in draft mode hereIf user use
_when matching domains or clients, this will not match a literal underscore but act as the SQLite3 default single-character wildcard. This PR allows users to escape underscores in domains/clients by escaping their underscore like\_. This was not possible before.Related issue or feature (if applicable): Fixes #2549
Pull request in docs with documentation (if applicable): N/A
By submitting this pull request, I confirm the following:
git rebase)Checklist:
developmentbranch.