From 5b457116e31db0e88fede6c428e969e87f290929 Mon Sep 17 00:00:00 2001 From: ready-research <72916209+ready-research@users.noreply.github.com> Date: Mon, 30 Aug 2021 18:03:43 +0530 Subject: [PATCH] Security fix for ReDoS (#3980) --- lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 28ccfff3c0..5d966f4448 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -185,7 +185,7 @@ function isURLSearchParams(val) { * @returns {String} The String freed of excess whitespace */ function trim(str) { - return str.replace(/^\s*/, '').replace(/\s*$/, ''); + return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); } /**