Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-parents-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/compiler': patch
---

Fixes an edge case that caused a difficult-to-reproduce panic
27 changes: 14 additions & 13 deletions internal/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -1248,13 +1248,14 @@ func (z *Tokenizer) readUnclosedTag() bool {
var close int
if z.fm == FrontmatterOpen {
close = strings.Index(string(buf), "---")
if close != -1 {
if close != -1 && len(buf) < close {
buf = buf[0:close]
}
} else {
close = bytes.Index(buf, []byte{'>'})
if close != -1 && len(buf) < close {
buf = buf[0:close]
}
}
close = bytes.Index(buf, []byte{'>'})
if close != -1 {
buf = buf[0:close]
}
if close == -1 {
// We can't find a closing tag...
Expand Down Expand Up @@ -1878,6 +1879,14 @@ frontmatter_loop:
return z.tt
}

// handle string
if c == '\'' || c == '"' || c == '`' {
z.readString(c)
z.tt = TextToken
z.data.End = z.raw.End
return z.tt
}

s := z.buf[z.raw.Start : z.raw.Start+1][0]

if s == '<' || s == '{' || s == '}' || c == '<' || c == '{' || c == '}' {
Expand All @@ -1891,14 +1900,6 @@ frontmatter_loop:
}
}

// handle string
if c == '\'' || c == '"' || c == '`' {
z.readString(c)
z.tt = TextToken
z.data.End = z.raw.End
return z.tt
}

z.dashCount = 0
continue frontmatter_loop
}
Expand Down