Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c47a89

Browse files
1 parent d8f7781 commit 2c47a89

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/ng/compile.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,15 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20992099
// first check if there are spaces because it's not the same pattern
21002100
var trimmedSrcset = trim(value);
21012101
// ( 999x ,| 999w ,| ,|, )
2102-
var srcPattern = /(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/;
2102+
/*
2103+
* CVE-2024-21490
2104+
* Used to be /(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/
2105+
* We factorize the common parts of the first patterns (with spaces before the comma).
2106+
* The additional '\s*' after ',' changes the length of resulting strings wich are trimmed anyway,
2107+
* but it helps not matching both combinations when candidates have spaces before and after the comma.
2108+
* This reduces the split complexity to linear and avoid the ReDoS.
2109+
*/
2110+
var srcPattern = /(\s+(?:\d+(?:x\s*|w\s*))?,\s*|,\s+)/;
21032111
var pattern = /\s/.test(trimmedSrcset) ? srcPattern : /(,)/;
21042112

21052113
// split srcset into tuple of uri and descriptor except for the last item

src/ng/filter/filters.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,21 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
348348
formattedText += 'e+' + exponent;
349349
}
350350
}
351+
/*
352+
* CVE-2022-25844
353+
*/
354+
const maxLength = 100;
355+
356+
if (pattern.posPre && pattern.posPre.length > maxLength) {
357+
pattern.posPre = pattern.posPre.substring(0, maxLength);
358+
console.warn('Value of posPre is too long, it has been truncated to the maximum allowed length.');
359+
}
360+
361+
if (pattern.posSuf && pattern.posSuf.length > maxLength) {
362+
pattern.posSuf = pattern.posSuf.substring(0, maxLength);
363+
console.warn('Value of posSuf is too long, it has been truncated to the maximum allowed length.');
364+
}
365+
351366
if (number < 0 && !isZero) {
352367
return pattern.negPre + formattedText + pattern.negSuf;
353368
} else {

0 commit comments

Comments
 (0)