Fix "Maximum call stack size exceeded" bug (#8636)

* Fix potential call stack size issue

* Update defaultExtractor.js

* add test to verify "Maximum call stack size exceeded" is fixed

* update changelog

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
This commit is contained in:
Adam Wathan 2022-06-14 08:17:40 -04:00 • committed by GitHub
parent 47327f4efa
commit 22eaad17c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View file

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608))
- Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615))
- Detect alpha value in CSS `theme()` function when using quotes ([#8625](https://github.com/tailwindlabs/tailwindcss/pull/8625))
- Fix "Maximum call stack size exceeded" bug ([#8636](https://github.com/tailwindlabs/tailwindcss/pull/8636))
## [3.1.2] - 2022-06-10

View file

@ -12,7 +12,7 @@ export function defaultExtractor(context) {
let results = []
for (let pattern of patterns) {
results.push(...(content.match(pattern) ?? []))
results = [...results, ...(content.match(pattern) ?? [])]
}
return results.filter((v) => v !== undefined).map(clipAtBalancedParens)

View file

@ -476,3 +476,9 @@ test('multi-word + arbitrary values + quotes', async () => {
expect(extractions).toContain(`grid-cols-['repeat(2)']`)
})
test('a lot of data', () => {
let extractions = defaultExtractor('underline '.repeat(2 ** 17))
expect(extractions).toContain(`underline`)
})