Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 5b366f2

Browse files
committed
Avoid another stack overflow with certain input
1 parent 5d75fbc commit 5b366f2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/lib/generateRules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function* candidatePermutations(candidate, lastIndex = Infinity) {
2323

2424
let dashIdx
2525

26-
if (candidate.endsWith(']', lastIndex + 1)) {
26+
if (lastIndex === Infinity && candidate.endsWith(']')) {
2727
let bracketIdx = candidate.lastIndexOf('[')
2828

2929
// If character before `[` isn't a dash, this isn't a dynamic class

tests/00-kitchen-sink.test.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
},
6666
setup: () => {
6767
const count = ref(0)
68+
// Weird regex-looking stuff that once caused a stack overflow in candidatePermutations
69+
const pattern = ' ]-[] '
6870
return {
6971
count,
7072
stuff: [] /* string[] | undefined */,

0 commit comments

Comments
 (0)