mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-16 15:11:50 +03:00
Remove unsafe regex in trim() function
`trim()` function contains a regular expression that is vulnerable to ReDoS but was uncaught by `safe-regex` module.
This commit is contained in:
@@ -93,7 +93,7 @@
|
|||||||
},
|
},
|
||||||
trim = function (str, len) {
|
trim = function (str, len) {
|
||||||
if (typeof(str) === STR_TYPE) {
|
if (typeof(str) === STR_TYPE) {
|
||||||
str = str.replace(/^\s\s*/, EMPTY).replace(/\s\s*$/, EMPTY);
|
str = str.replace(/^\s\s*/, EMPTY);
|
||||||
return typeof(len) === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
|
return typeof(len) === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user