Skip to content

Commit d823415

Browse files
committed
Fix sanitizer skipping subdomains with underscore
1 parent 9d94e50 commit d823415

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Fixed
99
- Wildcard filtering not working when wildcard tests put the domain over the 253 character limit.
10+
- Sanitizer accepts subdomains with underscores in them.
1011

1112
## [2.1.1] - 2023-04-11
1213
### Fixed

internal/usecase/resolve/domainreader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestDomainReaderRead(t *testing.T) {
2929
{name: "wildcard", haveData: "www\nftp\nmail", haveDomains: []string{"www.*.example.com"}, want: "www.www.example.com\nwww.ftp.example.com\nwww.mail.example.com\n", wantErr: io.EOF},
3030
{name: "multiple wildcards", haveData: "word", haveDomains: []string{"www.*.*.example.com"}, want: "www.word.word.example.com\n", wantErr: io.EOF},
3131
{name: "words multiple domains", haveData: "www\nftp\nmail", haveDomains: []string{"example.com", "example.org"}, want: "www.example.com\nwww.example.org\nftp.example.com\nftp.example.org\nmail.example.com\nmail.example.org\n", wantErr: io.EOF},
32-
{name: "sanitize", haveData: "_", haveDomains: []string{"example.com"}, haveSanitizer: DefaultSanitizer, want: "\n", wantErr: io.EOF},
32+
{name: "sanitize", haveData: "+", haveDomains: []string{"example.com"}, haveSanitizer: DefaultSanitizer, want: "\n", wantErr: io.EOF},
3333
}
3434

3535
for _, test := range tests {

internal/usecase/resolve/sanitizer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func DefaultSanitizer(domain string) string {
1818
for i := 0; i < len(domain); i++ {
1919
char := domain[i]
2020

21-
if (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9') || (char == '-') || (char == '.') {
21+
if (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9') || (char == '-') || (char == '_') || (char == '.') {
2222
continue
2323
}
2424

0 commit comments

Comments
 (0)