Merge: - filter: fix rules count when data doesn't end with a newline
Close #1694 * commit '286eb43c5622b2f35d7fe2b5f445da2ed2663658': - filter: fix rules count when data doesn't end with a newline
This commit is contained in:
commit
2d1cba67dc
|
@ -461,28 +461,29 @@ func (f *Filtering) parseFilterContents(file io.Reader) (int, uint32, string) {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
line, err := r.ReadString('\n')
|
line, err := r.ReadString('\n')
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
checksum = crc32.Update(checksum, crc32.IEEETable, []byte(line))
|
checksum = crc32.Update(checksum, crc32.IEEETable, []byte(line))
|
||||||
|
|
||||||
line = strings.TrimSpace(line)
|
line = strings.TrimSpace(line)
|
||||||
if len(line) == 0 {
|
if len(line) == 0 {
|
||||||
continue
|
//
|
||||||
}
|
|
||||||
|
|
||||||
if line[0] == '!' {
|
} else if line[0] == '!' {
|
||||||
m := f.filterTitleRegexp.FindAllStringSubmatch(line, -1)
|
m := f.filterTitleRegexp.FindAllStringSubmatch(line, -1)
|
||||||
if len(m) > 0 && len(m[0]) >= 2 && !seenTitle {
|
if len(m) > 0 && len(m[0]) >= 2 && !seenTitle {
|
||||||
name = m[0][1]
|
name = m[0][1]
|
||||||
seenTitle = true
|
seenTitle = true
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if line[0] == '#' {
|
} else if line[0] == '#' {
|
||||||
continue
|
//
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rulesCount++
|
rulesCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rulesCount, checksum, name
|
return rulesCount, checksum, name
|
||||||
|
|
Loading…
Reference in New Issue