-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1460 from andersk/inline-text-quadratic
Improve worst-case performance of inline.text regex
- Loading branch information
Showing
5 changed files
with
36 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
markdown: `a${' '.repeat(50000)}`, | ||
html: `<p>a${' '.repeat(50000)}</p>` | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
markdown: 'a'.repeat(50000), | ||
html: `<p>${'a'.repeat(50000)}</p>` | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const redosDir = path.resolve(__dirname, '../redos'); | ||
|
||
describe('ReDOS tests', () => { | ||
const files = fs.readdirSync(redosDir); | ||
files.forEach(file => { | ||
if (!file.match(/\.js$/)) { | ||
return; | ||
} | ||
|
||
it(file, () => { | ||
const spec = require(path.resolve(redosDir, file)); | ||
const before = process.hrtime(); | ||
expect(spec).toRender(spec.html); | ||
const elapsed = process.hrtime(before); | ||
if (elapsed[0] > 0) { | ||
const s = (elapsed[0] + elapsed[1] * 1e-9).toFixed(3); | ||
fail(`took too long: ${s}s`); | ||
} | ||
}); | ||
}); | ||
}); |