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

Commit

Permalink
Avoid another stack overflow with certain input
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Mar 27, 2021
1 parent 5d75fbc commit 5b366f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/generateRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function* candidatePermutations(candidate, lastIndex = Infinity) {

let dashIdx

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

// If character before `[` isn't a dash, this isn't a dynamic class
Expand Down
2 changes: 2 additions & 0 deletions tests/00-kitchen-sink.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
},
setup: () => {
const count = ref(0)
// Weird regex-looking stuff that once caused a stack overflow in candidatePermutations
const pattern = ' ]-[] '
return {
count,
stuff: [] /* string[] | undefined */,
Expand Down

0 comments on commit 5b366f2

Please sign in to comment.