Skip to content

Commit

Permalink
Out of memory on missing quote fixes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Jan 9, 2018
1 parent 586a6d1 commit 7321efa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() == '"' {
Expand Down
9 changes: 9 additions & 0 deletions plush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down

0 comments on commit 7321efa

Please sign in to comment.