Skip to content

Commit

Permalink
Merge pull request #33 from gobuffalo/fix-missing-quote-memory-issue
Browse files Browse the repository at this point in the history
Out of memory on missing quote fixes #31
  • Loading branch information
markbates authored Jan 9, 2018
2 parents 586a6d1 + 7321efa commit 3d4efd2
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 3d4efd2

Please sign in to comment.