Pull request 1787: 5639-querylog-filter-fix

Fixes #5639.

Squashed commit of the following:

commit 1aa02c8fa2b858f9c9a41c5dd6746d4d2e3de654
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Sun Mar 26 13:39:29 2023 +0300

    querylog: fix filtered log filter
This commit is contained in:
Ainar Garipov 2023-03-26 14:19:19 +03:00
parent fb7b8bba6a
commit 0df32601bb
2 changed files with 10 additions and 9 deletions

View File

@ -123,6 +123,8 @@ In this release, the schema version has changed from 17 to 20.
### Fixed
- Query log not showing all filtered queries when the “Filtered” log filter is
selected ([#5639]).
- Panic in empty hostname in the filter's URL ([#5631]).
- Panic caused by empty top-level domain name label in `/etc/hosts` files
([#5584]).
@ -133,6 +135,7 @@ In this release, the schema version has changed from 17 to 20.
[#5567]: https://github.com/AdguardTeam/AdGuardHome/issues/5567
[#5584]: https://github.com/AdguardTeam/AdGuardHome/issues/5584
[#5631]: https://github.com/AdguardTeam/AdGuardHome/issues/5631
[#5639]: https://github.com/AdguardTeam/AdGuardHome/issues/5639
[rfc6761]: https://www.rfc-editor.org/rfc/rfc6761

View File

@ -150,12 +150,18 @@ func (c *searchCriterion) ctFilteringStatusCase(
switch c.value {
case filteringStatusAll:
return true
case filteringStatusFiltered:
return isFiltered || reason.In(
filtering.NotFilteredAllowList,
filtering.Rewritten,
filtering.RewrittenAutoHosts,
filtering.RewrittenRule,
)
case
filteringStatusBlocked,
filteringStatusBlockedParental,
filteringStatusBlockedSafebrowsing,
filteringStatusBlockedService,
filteringStatusFiltered,
filteringStatusSafeSearch:
return isFiltered && c.isFilteredWithReason(reason)
case filteringStatusWhitelisted:
@ -184,7 +190,6 @@ func (c *searchCriterion) ctFilteringStatusCase(
// - filteringStatusBlockedParental
// - filteringStatusBlockedSafebrowsing
// - filteringStatusBlockedService
// - filteringStatusFiltered
// - filteringStatusSafeSearch
func (c *searchCriterion) isFilteredWithReason(reason filtering.Reason) (matched bool) {
switch c.value {
@ -196,13 +201,6 @@ func (c *searchCriterion) isFilteredWithReason(reason filtering.Reason) (matched
return reason == filtering.FilteredSafeBrowsing
case filteringStatusBlockedService:
return reason == filtering.FilteredBlockedService
case filteringStatusFiltered:
return reason.In(
filtering.NotFilteredAllowList,
filtering.Rewritten,
filtering.RewrittenAutoHosts,
filtering.RewrittenRule,
)
case filteringStatusSafeSearch:
return reason == filtering.FilteredSafeSearch
default: