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
8 changes: 7 additions & 1 deletion pkg/dsl/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,13 @@ func (l *Lexer) lexString() string {
}
l.readChar()
}
str += l.input[position:l.position]
end := l.position
if end > len(l.input) {
end = len(l.input)
}
if position < end {
str += l.input[position:end]
}
if l.ch == '"' {
l.readChar()
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/dsl/lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,4 +1189,17 @@ rule test_rule(created_at time, started_at time) {
Expect(hasBoolean).Should(BeTrue())
Expect(hasComparison).Should(BeTrue())
})

It("Case 4 - should not panic on an unterminated string", func() {
for _, input := range []string{`"\`, `"`, `"abc\`, `"\\`} {
Expect(func() {
l := NewLexer(input)
for {
if l.NextToken().Type == token.EOF {
break
}
}
}).ShouldNot(Panic())
}
})
})
Loading