Fix 'index out of range' panic when adding a filter URL that has empty line in contents

This commit is contained in:
Eugene Bujak 2018-09-25 18:23:02 +03:00
parent b0549a8e5b
commit bd0fa4cc4f
1 changed files with 1 additions and 1 deletions

View File

@ -1148,7 +1148,7 @@ func (filter *filter) update(now time.Time) (bool, error) {
d := dnsfilter.New()
for _, line := range lines {
line = strings.TrimSpace(line)
if line[0] == '!' {
if len(line) > 0 && line[0] == '!' {
if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle {
log.Printf("Setting filter title to %s\n", m[0][1])
filter.Name = m[0][1]