diff --git a/elemhide_inject.go b/elemhide_inject.go index 1e90b2f..611ad04 100644 --- a/elemhide_inject.go +++ b/elemhide_inject.go @@ -151,7 +151,7 @@ func (p *proxyHandler) applyElementHiding(resp *http.Response, host, clientIP st safeCSS := styleCloseRe.ReplaceAllString(css, `<\/style`) styleTag := []byte("") modified = injectStyleTag(modified, styleTag) - rule := strings.Join(selectors, ", ") + rule := truncateRule(strings.Join(selectors, ", "), 80) p.logActivity(ActivityElementHidden, host, "", rule, clientIP, credID) logElementHidden(host, rule, clientIP, credID) } diff --git a/log.go b/log.go index cb328f9..b36ac95 100644 --- a/log.go +++ b/log.go @@ -44,6 +44,14 @@ func shortUserID(credentialID string) string { return credentialID } +// truncateRule shortens a rule string to maxLen, appending "..." if truncated. +func truncateRule(rule string, maxLen int) string { + if len(rule) <= maxLen { + return rule + } + return rule[:maxLen] + "..." +} + // logRequest logs a completed HTTP request at Debug level. // Only visible when --log-level=debug. func logRequest(method, url string, status int, duration time.Duration, clientIP, credentialID string) {