diff --git a/lexer/lexer.go b/lexer/lexer.go index 5c33cde..b900f6f 100644 --- a/lexer/lexer.go +++ b/lexer/lexer.go @@ -250,7 +250,7 @@ func (l *Lexer) readNumber() string { func (l *Lexer) readString() string { position := l.position + 1 - for { + for l.ch != 0 { l.readChar() // check for quote escapes if l.ch == '\\' && l.peekChar() == '"' { diff --git a/plush_test.go b/plush_test.go index 0ab8f01..9c9356f 100644 --- a/plush_test.go +++ b/plush_test.go @@ -448,6 +448,15 @@ func Test_LineNumberErrors_InsideForLoop(t *testing.T) { r.Contains(err.Error(), "line 3:") } +func Test_MissingQuote(t *testing.T) { + r := require.New(t) + input := `<%= foo("asdf) %>` + ctx := NewContext() + ctx.Set("foo", func(string) {}) + _, err := Render(input, ctx) + r.Error(err) +} + func Test_RunScript(t *testing.T) { r := require.New(t) bb := &bytes.Buffer{}