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 10, 2018
1 parent 3d4efd2 commit 66309e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ func (l *Lexer) nextInsideToken() token.Token {
}

func (l *Lexer) skipWhitespace() {
if l.readPosition >= len(l.input) {
l.readChar()
return
}
for l.ch == ' ' || l.ch == '\t' || l.ch == '\n' || l.ch == '\r' {
l.readChar()
}
Expand All @@ -226,6 +230,7 @@ func (l *Lexer) readChar() {
}

func (l *Lexer) peekChar() byte {

if l.readPosition >= len(l.input) {
return 0
}
Expand Down
9 changes: 9 additions & 0 deletions plush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,15 @@ func Test_MissingQuote(t *testing.T) {
r.Error(err)
}

func Test_MissingQuote_Variant(t *testing.T) {
r := require.New(t)
input := `<%= foo("test) %>".`
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 66309e4

Please sign in to comment.