Closed OhmSpectator closed 11 months ago
The update to regionController.js
addresses a crash issue when special characters, like a URL-encoded '?', are included in search queries. By incorporating lodash to escape regex patterns, the code now safely handles special characters in search terms, mitigating potential crashes and security vulnerabilities related to SQL query execution.
File Path | Change Summary |
---|---|
.../src/controllers/regionController.js |
Added lodash dependency and updated searchRegions function to escape regex patterns for search queries. |
Objective | Addressed | Explanation |
---|---|---|
Prevent backend crash with special characters in search queries (#160) | ✅ | |
Correct handling of URL-encoded characters to prevent crashes (#160) | ✅ | |
Address SQL query invalid regex errors with special characters (#160) | ✅ | |
Sanitize URL-encoded characters in query parameters for security (#160) | ✅ | |
Modify SQL query construction to prevent regex errors (#160) | ✅ |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?
Fixes #<Issue Number>
<Type>: <Topic>.
Description
This PR introduces an enhancement to the search functionality in the backend. By integrating lodash's
escapeRegExp
function, we now ensure that special characters in search terms are properly escaped, thereby avoiding errors and server crashes when users input characters like '?' in the search field. This update aims to improve the robustness and reliability of the search feature in our application.Related Issues
Closes: #160
How Was This Tested?
Tests were conducted with various search queries containing special characters, including but not limited to %, ', *, ?, and (. Each character was tested in isolation and in combination with alphanumeric characters to simulate real-world search queries. The tests were performed via the UI by inputting these characters into the search field. The backend handled all cases gracefully, properly escaping special characters and preventing any crashes or malformed SQL queries. No errors were encountered, and search functionality remained consistent and reliable across all tested scenarios.
Checklist
Before submitting your PR, please review the following:
Summary by CodeRabbit
Enhancements
New Features
Dependencies