diff options
author | Michael Henriksen <mchnrksn@gmail.com> | 2022-02-19 15:12:42 +0100 |
---|---|---|
committer | Michael Henriksen <mchnrksn@gmail.com> | 2022-02-19 15:12:42 +0100 |
commit | b333364cf3e8cfb13c9803d718f56291d7520fbb (patch) | |
tree | 8f0d889133ea726c663be670c293659f786fb531 /internal/revision/parser.go | |
parent | 935af59cf64fbe49eb8baba9fe80e6b236daf593 (diff) | |
download | go-git-b333364cf3e8cfb13c9803d718f56291d7520fbb.tar.gz |
revision: fix endless looping in revision parser
Fixes a bug in the revision parser which caused an endless loop when
parsing revisions with opening braces "{" but no closing braces "}".
Example bad revisions:
- ^{/
- ~@{
- @@{{0
Diffstat (limited to 'internal/revision/parser.go')
-rw-r--r-- | internal/revision/parser.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/revision/parser.go b/internal/revision/parser.go index 8facf17..8a2a719 100644 --- a/internal/revision/parser.go +++ b/internal/revision/parser.go @@ -322,6 +322,8 @@ func (p *Parser) parseAt() (Revisioner, error) { } return AtDate{t}, nil + case tok == eof: + return nil, &ErrInvalidRevision{s: `missing "}" in @{<data>} structure`} default: date += lit } @@ -424,6 +426,8 @@ func (p *Parser) parseCaretBraces() (Revisioner, error) { p.unscan() case tok != slash && start: return nil, &ErrInvalidRevision{fmt.Sprintf(`"%s" is not a valid revision suffix brace component`, lit)} + case tok == eof: + return nil, &ErrInvalidRevision{s: `missing "}" in ^{<data>} structure`} case tok != cbrace: p.unscan() re += lit |