summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Finkel <Matthew.Finkel@gmail.com>2018-03-20 22:45:55 +0000
committerArlo Breault <arlolra@gmail.com>2018-03-21 11:32:27 -0400
commitaa25675a220bc91104fd887216d09314ca26c822 (patch)
treeb0937813da760aa8bc3a9d74414649c888f44062
parent21b48f63d24a8ab2b900d158e06dd4bf979148f1 (diff)
Match Tor Browser and (new) Orfox UAS together
The two user agent strings are now nearly identical, we should try combining the patterns (again). There are also new unit test strings for this. This roughly combines the pattern matching introduced in 749fd988c32e764e7fc8dde1f59ab7f06a63f0cd and 644e1c21b682a911acbea567f55d156a084a8c5f. We can remove the old Orfox-specific pattern (Gecko/38) after users have a few weeks for upgrading to the new version.
-rw-r--r--utils.go2
-rw-r--r--utils_test.go2
2 files changed, 3 insertions, 1 deletions
diff --git a/utils.go b/utils.go
index 4d438d2..bbba5fe 100644
--- a/utils.go
+++ b/utils.go
@@ -55,7 +55,7 @@ func GetHost(r *http.Request) (host string, err error) {
return
}
-var TBBUserAgents = regexp.MustCompile(`^Mozilla/5\.0 \(Windows NT 6\.1; rv:[\d]+\.0\) Gecko/20100101 Firefox/[\d]+\.0$`)
+var TBBUserAgents = regexp.MustCompile(`^Mozilla/5\.0 \(((Windows NT 6\.1)|(Android; Mobile)); rv:[\d]+\.0\) Gecko/20100101 Firefox/[\d]+\.0$`)
var OrfoxUserAgents = regexp.MustCompile(`^Mozilla/5\.0 \(Android; Mobile; rv:38.0\) Gecko/38.0 Firefox/38.0$`)
func LikelyTBB(ua string) bool {
diff --git a/utils_test.go b/utils_test.go
index aa47df9..096a48c 100644
--- a/utils_test.go
+++ b/utils_test.go
@@ -12,6 +12,8 @@ var UserAgents = map[string]bool{
"Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0": true,
"Mozilla/5.0 (Android; Mobile; rv:31.0) Gecko/31.0 Firefox/31.0": false,
"Mozilla/5.0 (Android; Mobile; rv:38.0) Gecko/38.0 Firefox/38.0": true,
+ "Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0": true,
+ "Mozilla/5.0 (Android; Mobile; rv:52.0) Gecko/20100101 Firefox/52.0": true,
}
func TestLikelyTBB(t *testing.T) {