- #6128 [feature] Graceful handling of undefined locale name
- #5554 [bugfix] Handle invalid mutations
- #6193 [bugfix] weekyear setter handle dow
- #5592 [bugfix] Stricter single digit date parsing
- #5827 [bugfix] ts: toISOString function also return null
- #5607 [bugfix] unify duration.valueOf and asMilliseconds
Last active
January 18, 2024 11:31
-
-
Save ichernev/e277bcd1f0eeabb834f60a777237925a to your computer and use it in GitHub Desktop.
Can we do this fix in our project?
function unescapeFormat(s) {
return regexEscape(
s
.replace(/\\/g, '')
.replace(
/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result message: This replaces only the first occurrence of '\'.
Snippet:
Rule name: js/incomplete-sanitization
Rule short description: Incomplete string escaping or encoding
Rule full description: A string transformer that does not replace or escape all occurrences of a meta-character may be ineffective.
Hello, can I ask you about this regular expression in your function?
The vulnerability in this case is that the unescapeFormat() function removes only the first occurrence of the backslash character (). This means that other occurrences of the character may be left unescaped, which could lead to unexpected consequences when interpreting the string.
Possible consequences of the vulnerability:
Injection attacks (eg, SQL injection, cross-site scripting) if user input is used in queries or HTML without proper escaping.
Misinterpretation of string literals or regular expressions due to unescaped backslashes.
How critical is this? If yes, will there be a fix in the next version? If not, please help me understand why.