You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When CSS selectors are very long or complex, the engine may run out of memory
Dynamically modify rule.selector in a loop: the array will grow dynamically, leading to an infinite loop;
Duplicate processing: even fixed rules will be reprocessed.
Double backslash \ is parsed as a single \ in CSS, resulting in an invalid class name .:hover
Steps to Reproduce
const generateKillerCSS = (length) => {
let selector = '';
for (let i = 0; i < length; i++) {
selector += .class-${i}:hover:not([data-${i % 100}="${'x'.repeat(50)}"]),;
}
return selector.slice(0, -1);
};
Preflight Checklist
What package is this bug report for?
rrweb-snapshot
Version
2.0.0-alpha.18
Expected Behavior
Correctly handle regular expressions that are too long
Actual Behavior
rule.selectors.forEach(function (selector) {
if (selector.includes(':hover')) {
rule.selector += ',\n' + selector.replace(/:hover/g, '.\:hover');
}
});
Duplicate processing: even fixed rules will be reprocessed.
Steps to Reproduce
const generateKillerCSS = (length) => {
let selector = '';
for (let i = 0; i < length; i++) {
selector +=
.class-${i}:hover:not([data-${i % 100}="${'x'.repeat(50)}"]),
;}
return selector.slice(0, -1);
};
const dangerousCSS = generateKillerCSS(50000);
try {
const regex = /:hover/g;
const result = dangerousCSS.replace(regex, '\:hover');
} catch (e) {
console.error( e.message);
}
Testcase Gist URL
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: