Skip to content

Commit

Permalink
querylog: imp docs, code
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Jun 29, 2021
1 parent 35757f7 commit 31292ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions internal/querylog/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ func (l *queryLog) parseSearchCriterion(q url.Values, name string, ct criterionT
var asciiVal string
switch ct {
case ctTerm:
// Decode lowercased value from punycode to make EqualFold and
// friends work properly with IDNAs.
loweredVal := strings.ToLower(val)
if asciiVal, err = idna.ToASCII(loweredVal); err != nil {
log.Debug("can't convert %q to ascii: %s", val, err)
Expand Down
14 changes: 6 additions & 8 deletions internal/querylog/searchcriterion.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type searchCriterion struct {
strict bool
}

func (c *searchCriterion) ctDomainOrClientCaseStrict(
func ctDomainOrClientCaseStrict(
term string,
asciiTerm string,
clientID string,
Expand Down Expand Up @@ -100,7 +100,7 @@ func containsFold(s, substr string) (ok bool) {
return false
}

func (c *searchCriterion) ctDomainOrClientCaseNonStrict(
func ctDomainOrClientCaseNonStrict(
term string,
asciiTerm string,
clientID string,
Expand Down Expand Up @@ -131,7 +131,7 @@ func (c *searchCriterion) quickMatch(line string, findClient quickMatchClientFun
}

if c.strict {
return c.ctDomainOrClientCaseStrict(
return ctDomainOrClientCaseStrict(
c.value,
c.asciiVal,
clientID,
Expand All @@ -141,7 +141,7 @@ func (c *searchCriterion) quickMatch(line string, findClient quickMatchClientFun
)
}

return c.ctDomainOrClientCaseNonStrict(
return ctDomainOrClientCaseNonStrict(
c.value,
c.asciiVal,
clientID,
Expand Down Expand Up @@ -180,13 +180,11 @@ func (c *searchCriterion) ctDomainOrClientCase(e *logEntry) bool {
}

ip := e.IP.String()
term := strings.ToLower(c.value)
asciiTerm := strings.ToLower(c.asciiVal)
if c.strict {
return c.ctDomainOrClientCaseStrict(term, asciiTerm, clientID, name, host, ip)
return ctDomainOrClientCaseStrict(c.value, c.asciiVal, clientID, name, host, ip)
}

return c.ctDomainOrClientCaseNonStrict(term, asciiTerm, clientID, name, host, ip)
return ctDomainOrClientCaseNonStrict(c.value, c.asciiVal, clientID, name, host, ip)
}

func (c *searchCriterion) ctFilteringStatusCase(res filtering.Result) bool {
Expand Down

0 comments on commit 31292ba

Please sign in to comment.