You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The backend crashes when using the character '?' as a search query parameter in the /api/regions/search API endpoint. The issue is triggered by passing %3F (URL-encoded representation of '?') as the value for the query parameter. This leads to a failure in the SQL query execution, causing a SequelizeDatabaseError due to an invalid regular expression.
Steps to Reproduce
Make an API call to /api/regions/search with the query parameter set to %3F (e.g., /api/regions/search?query=%3F).
Observe the backend crash.
The error log indicates a "SequelizeDatabaseError: invalid regular expression: quantifier operand invalid".
Expected Behavior
The API should correctly handle URL-encoded special characters in search queries, including '?'. It should either process the character as part of the search criteria or manage it gracefully to avoid crashing.
Actual Behavior
On receiving the URL-encoded '?' character as a search parameter, the backend crashes. The error message "invalid regular expression: quantifier operand invalid" suggests a failure in processing the special character within the SQL query.
Added lodash to the project dependencies and utilized its escapeRegExp function
to escape special characters in the search query. This update is to ensure that
when special characters are included in search terms, they are treated as
literal characters in the regex used in the searchRegions function. These
changes aim to prevent errors and crashes in the backend when users input
special characters like '?' in the search field.
Issue: #160
Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Added lodash to the project dependencies and utilized its escapeRegExp function
to escape special characters in the search query. This update is to ensure that
when special characters are included in search terms, they are treated as
literal characters in the regex used in the searchRegions function. These
changes aim to prevent errors and crashes in the backend when users input
special characters like '?' in the search field.
Issue: #160
Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Description
The backend crashes when using the character '?' as a search query parameter in the
/api/regions/search
API endpoint. The issue is triggered by passing%3F
(URL-encoded representation of '?') as the value for thequery
parameter. This leads to a failure in the SQL query execution, causing a SequelizeDatabaseError due to an invalid regular expression.Steps to Reproduce
/api/regions/search
with the query parameter set to%3F
(e.g.,/api/regions/search?query=%3F
).Expected Behavior
The API should correctly handle URL-encoded special characters in search queries, including '?'. It should either process the character as part of the search criteria or manage it gracefully to avoid crashing.
Actual Behavior
On receiving the URL-encoded '?' character as a search parameter, the backend crashes. The error message "invalid regular expression: quantifier operand invalid" suggests a failure in processing the special character within the SQL query.
Commit Version
The issue is identified in commit 1ad6540.
Environment
Additional Context
regionController.js
.Possible Solution
regionController.js
to avoid regular expression errors with special characters.The text was updated successfully, but these errors were encountered: