Skip to content

Commit 4db7cc0

Browse files
Merge pull request jonschlinkert#1 from aashutoshrathi/fix/CVE-2023-26115
🔒 fix: CVE-2023-26115
2 parents 786ebf1 + 235cfd4 commit 4db7cc0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
/*!
22
* word-wrap <https://github.com/jonschlinkert/word-wrap>
33
*
4-
* Copyright (c) 2014-2017, Jon Schlinkert.
4+
* Copyright (c) 2014-2023, Jon Schlinkert.
55
* Released under the MIT License.
66
*/
77

8+
function trimTabAndSpaces(str) {
9+
const lines = str.split('\n');
10+
const trimmedLines = lines.map((line) => line.trimEnd());
11+
return trimmedLines.join('\n');
12+
}
13+
814
module.exports = function(str, options) {
915
options = options || {};
1016
if (str == null) {
@@ -36,7 +42,7 @@ module.exports = function(str, options) {
3642
}).join(newline);
3743

3844
if (options.trim === true) {
39-
result = result.replace(/[ \t]*$/gm, '');
45+
result = trimTabAndSpaces(result);
4046
}
4147
return result;
4248
};

0 commit comments

Comments
 (0)