Fix conf parser hang on dangling quote

Signed-off-by: Waldemar Quevedo <wally@synadia.com>
This commit is contained in:
Waldemar Quevedo
2018-10-23 15:14:22 -07:00
parent 77548d493c
commit e8928b7eed
2 changed files with 96 additions and 0 deletions

View File

@@ -346,6 +346,12 @@ func lexDubQuotedKey(lx *lexer) stateFn {
lx.emit(itemKey)
lx.next()
return lexSkip(lx, lexKeyEnd)
} else if r == eof {
if lx.pos > lx.start {
return lx.errorf("Unexpected EOF.")
}
lx.emit(itemEOF)
return nil
}
lx.next()
return lexDubQuotedKey
@@ -358,6 +364,12 @@ func lexQuotedKey(lx *lexer) stateFn {
lx.emit(itemKey)
lx.next()
return lexSkip(lx, lexKeyEnd)
} else if r == eof {
if lx.pos > lx.start {
return lx.errorf("Unexpected EOF.")
}
lx.emit(itemEOF)
return nil
}
lx.next()
return lexQuotedKey
@@ -788,6 +800,12 @@ func lexQuotedString(lx *lexer) stateFn {
lx.next()
lx.ignore()
return lx.pop()
case r == eof:
if lx.pos > lx.start {
return lx.errorf("Unexpected EOF.")
}
lx.emit(itemEOF)
return nil
}
return lexQuotedString
}
@@ -807,6 +825,12 @@ func lexDubQuotedString(lx *lexer) stateFn {
lx.next()
lx.ignore()
return lx.pop()
case r == eof:
if lx.pos > lx.start {
return lx.errorf("Unexpected EOF.")
}
lx.emit(itemEOF)
return nil
}
return lexDubQuotedString
}