* Update filter.go

* Upsert filter options

Insert or update filter options.

* Indent.

* Updated CHANGELOG.md

fix for: Option -ac overwriting other existing filters #231
This commit is contained in:
bjhulst 2020-10-03 11:20:21 +03:00 committed by GitHub
parent 19937c4929
commit 2abc72018d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -11,6 +11,7 @@
- Pre-flight errors are now displayed also after the usage text to prevent the need to scroll through backlog. - Pre-flight errors are now displayed also after the usage text to prevent the need to scroll through backlog.
- Cancelling via SIGINT (Ctrl-C) is now more responsive - Cancelling via SIGINT (Ctrl-C) is now more responsive
- Fixed issue where a thread would hang due to TCP errors - Fixed issue where a thread would hang due to TCP errors
- Fixed the issue where the option -ac was overwriting existing filters. Now auto-calibration will add them where needed.
- The `-w` flag now accepts comma delimited values in the form of `file1:W1,file2:W2`. - The `-w` flag now accepts comma delimited values in the form of `file1:W1,file2:W2`.
- v1.1.0 - v1.1.0

View File

@ -32,7 +32,17 @@ func NewFilterByName(name string, value string) (ffuf.FilterProvider, error) {
func AddFilter(conf *ffuf.Config, name string, option string) error { func AddFilter(conf *ffuf.Config, name string, option string) error {
newf, err := NewFilterByName(name, option) newf, err := NewFilterByName(name, option)
if err == nil { if err == nil {
// valid filter create or append
if conf.Filters[name] == nil {
conf.Filters[name] = newf conf.Filters[name] = newf
} else {
currentfilter := conf.Filters[name].Repr()
newoption := strings.TrimSpace(strings.Split(currentfilter, ":")[1]) + "," + option
newerf, err := NewFilterByName(name, newoption)
if err == nil {
conf.Filters[name] = newerf
}
}
} }
return err return err
} }