Skip to content

Commit e2398e9

Browse files
authored
escape dots and add firefox regexp (#70)
1 parent f3935f7 commit e2398e9

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

attributioncode/sourcewhitelist.go

+8-11
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ func isWhitelisted(source string) bool {
1616
}
1717

1818
var sourceWhitelistRegexps = []*regexp.Regexp{
19-
regexp.MustCompile(`^[\w-]*.allizom.org$`),
20-
regexp.MustCompile(`^www.google(.com?)?.\w+$`),
21-
regexp.MustCompile(`^\w+.google.com$`),
22-
regexp.MustCompile(`^\w+.search.yahoo.com$`),
23-
regexp.MustCompile(`^\w+.facebook.com$`),
24-
regexp.MustCompile(`^[\w-]+.wikipedia.org$`),
19+
regexp.MustCompile(`^[\w-]*\.allizom\.org$`),
20+
regexp.MustCompile(`^www\.google(\.com?)?\.\w+$`),
21+
regexp.MustCompile(`^\w+\.google\.com$`),
22+
regexp.MustCompile(`^\w+\.search\.yahoo\.com$`),
23+
regexp.MustCompile(`^\w+\.facebook\.com$`),
24+
regexp.MustCompile(`^[\w-]+\.wikipedia\.org$`),
25+
regexp.MustCompile(`^(\w+\.)*firefox\.com$`),
2526
}
2627

2728
var sourceWhitelist = map[string]bool{
@@ -38,9 +39,7 @@ var sourceWhitelist = map[string]bool{
3839
"yahoo": true,
3940
"yandex": true,
4041

41-
"firefox-com": true,
42-
"firefox.com": true,
43-
"www.firefox.com": true,
42+
"firefox-com": true,
4443

4544
"getfirefox-com": true,
4645
"getfirefox.com": true,
@@ -99,7 +98,6 @@ var sourceWhitelist = map[string]bool{
9998
"gr.search.yahoo.com": true,
10099
"hacks.mozilla.org": true,
101100
"hangouts.google.com": true,
102-
"hello.firefox.com": true,
103101
"help.ea.com": true,
104102
"help.mail.ru": true,
105103
"hk.messenger.yahoo.com": true,
@@ -180,7 +178,6 @@ var sourceWhitelist = map[string]bool{
180178
"talkgadget.google.com": true,
181179
"tanks.mail.ru": true,
182180
"taobao.com": true,
183-
"testpilot.firefox.com": true,
184181
"th.search.yahoo.com": true,
185182
"thunderbird.mozilla.cz": true,
186183
"toshiba.com": true,

attributioncode/sourcewhitelist_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ func TestIsWhitelisted(t *testing.T) {
77
Domain string
88
Valid bool
99
}{
10+
{"firefox.com", true},
11+
{"www.firefox.com", true},
12+
{"screenshots.firefox.com", true},
13+
{"testpilot.firefox.com", true},
1014
{"www-demo4.allizom.org", true},
1115
{"google", true},
1216
{"foo.search.yahoo.com", true},

0 commit comments

Comments
 (0)