Skip to content

Commit

Permalink
storage/url: add nil check for URL.filterRegex in URL.Match (#511)
Browse files Browse the repository at this point in the history
URL.Match method assumes that URL.filterRegex is not nil and used it
without check. But if the URL was created with `raw` option or was
created with type literal then it might be nil. So if Match was called
for such URLs then it panics.

ps. It occured in an old variants of autocompletion PR. But that part of
the code was changed now, so we won't include this change there.
  • Loading branch information
kucukaslan authored Sep 16, 2022
1 parent d949fe0 commit 22592e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions storage/url/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ func (u *URL) SetRelative(base *URL) {

// Match reports whether if given key matches with the object.
func (u *URL) Match(key string) bool {
if u.filterRegex == nil {
return false
}

if !u.filterRegex.MatchString(key) {
return false
}
Expand Down

0 comments on commit 22592e5

Please sign in to comment.