Content-Length: 303388 | pFad | https://github.com/jonschlinkert/word-wrap/commit/9f626935f3fac6ec0f3c4b26baea4eb9740d9645

05 fix: cve 2023-26115 · jonschlinkert/word-wrap@9f62693 · GitHub
Skip to content

Commit 9f62693

Browse files
committed
fix: cve 2023-26115
1 parent d6e8514 commit 9f62693

File tree

2 files changed

+3092
-1
lines changed

2 files changed

+3092
-1
lines changed

index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
* Released under the MIT License.
66
*/
77

8+
function trimEnd(str) {
9+
let lastCharPos = str.length - 1;
10+
let lastChar = str[lastCharPos];
11+
while(lastChar === ' ' || lastChar === '\t') {
12+
lastChar = str[--lastCharPos];
13+
}
14+
return str.substring(0, lastCharPos + 1);
15+
}
16+
17+
function trimTabAndSpaces(str) {
18+
const lines = str.split('\n');
19+
const trimmedLines = lines.map((line) => trimEnd(line));
20+
return trimmedLines.join('\n');
21+
}
22+
823
module.exports = function(str, options) {
924
options = options || {};
1025
if (str == null) {
@@ -36,7 +51,7 @@ module.exports = function(str, options) {
3651
}).join(newline);
3752

3853
if (options.trim === true) {
39-
result = result.replace(/\s+$/g, '');
54+
result = trimTabAndSpaces(result);
4055
}
4156
return result;
4257
};

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/jonschlinkert/word-wrap/commit/9f626935f3fac6ec0f3c4b26baea4eb9740d9645

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy