From b034e25b26ec01c8b2607726646c55777ba66a1d Mon Sep 17 00:00:00 2001 From: DannyHinshaw Date: Thu, 30 Apr 2020 10:19:10 -0400 Subject: [PATCH] * filter: skip comment lines starting with '#' Fix #771, filter skips comment lines starting with '#'. Handle exclamation inline comments. Refactor for correct logic flow. Split out hashtag comment logic from exclamation. Remove trailing whitespace. --- home/filter.go | 2 ++ home/filter_test.go | 1 + 2 files changed, 3 insertions(+) diff --git a/home/filter.go b/home/filter.go index ca5e4add..4b1a75ef 100644 --- a/home/filter.go +++ b/home/filter.go @@ -478,6 +478,8 @@ func (f *Filtering) parseFilterContents(file io.Reader) (int, uint32, string) { name = m[0][1] seenTitle = true } + } else if line[0] == '#' { + continue } else { rulesCount++ } diff --git a/home/filter_test.go b/home/filter_test.go index e4f10f1f..317741d8 100644 --- a/home/filter_test.go +++ b/home/filter_test.go @@ -14,6 +14,7 @@ import ( func testStartFilterListener() net.Listener { http.HandleFunc("/filters/1.txt", func(w http.ResponseWriter, r *http.Request) { content := `||example.org^$third-party +# Inline comment example ||example.com^$third-party 0.0.0.0 example.com `