Skip to content

Commit 235cfd4

Browse files
🔒 fix: CVE-2023-26115
1 parent 786ebf1 commit 235cfd4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

index.js

Lines changed: 8 additions & 2 deletions
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)