-
Notifications
You must be signed in to change notification settings - Fork 51
PM-690 - assets library management #1609
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
…fixes PM-803 wm regression fixes
/** | ||
* regex for url validation | ||
*/ | ||
const urlRegex = /((https?):\/\/)?(www.)?[a-z0-9]+(\.[a-z]{2,}){1,3}(#?\/?(?:[a-zA-Z0-9#]+))*\/?(\?[a-zA-Z0-9-_]+=[a-zA-Z0-9-%]+&?)?$/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. Specifically, we should replace the sub-expression [a-zA-Z0-9#]+
with a more precise pattern that avoids ambiguity.
- We can replace
[a-zA-Z0-9#]+
with(?:[a-zA-Z0-9]+|#+)+
, which ensures that the#
characters are matched in a non-ambiguous way. - This change will be made in the file
src/util/validation.js
on line 61.
-
Copy modified line R61
@@ -60,3 +60,3 @@ | ||
*/ | ||
const urlRegex = /((https?):\/\/)?(www.)?[a-z0-9]+(\.[a-z]{2,}){1,3}(#?\/?(?:[a-zA-Z0-9#]+))*\/?(\?[a-zA-Z0-9-_]+=[a-zA-Z0-9-%]+&?)?$/ | ||
const urlRegex = /((https?):\/\/)?(www.)?[a-z0-9]+(\.[a-z]{2,}){1,3}(#?\/?(?:[a-zA-Z0-9]+|#+)+)*\/?(\?[a-zA-Z0-9-_]+=[a-zA-Z0-9-%]+&?)?$/ | ||
|
https://topcoder.atlassian.net/browse/PM-690
Applied and updated the challenge results from the assets library.