Scrub space separated ip addresses

The issue with ReplaceAllFunc is that it's capturing the leading and
trailing spaces in the regexp, so successive ips don't match.  From the
docstring,

> If 'All' is present, the routine matches successive non-overlapping
> matches of the entire expression.

For #40306
This commit is contained in:
Arlo Breault 2024-01-03 20:20:01 -05:00 committed by Cecylia Bocovich
parent 98db63ad01
commit e4c818be76
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90
2 changed files with 18 additions and 4 deletions

View file

@ -107,6 +107,11 @@ func TestLogScrubberMessages(t *testing.T) {
"error dialing relay: wss://snowflake.torproject.net/?client_ip=1%3A2%3A3%3A%3Ad%3Ae%3Af = dial tcp xxx",
"error dialing relay: wss://snowflake.torproject.net/?client_ip=[scrubbed] = dial tcp xxx\n",
},
{
// multiple space-separated IP addresses
"Allowed stations: [10.0.1.1 10.0.1.2 10.0.1.3 10.0.1.4]\n",
"Allowed stations: [[scrubbed] [scrubbed] [scrubbed] [scrubbed]]\n",
},
} {
var buff bytes.Buffer
log.SetFlags(0) //remove all extra log output for test comparisons