Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit d05a8b6

Browse files
jeffkaufmancrowell
authored andcommitted
dns-prefetch: whitelist Safari 6+
Fixes #1348
1 parent d462e41 commit d05a8b6

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

pagespeed/kernel/http/user_agent_matcher.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,10 @@ const char* kWebpAnimatedBlacklist[] = {
207207
"*CriOS/31.*",
208208
};
209209

210-
// TODO(rahulbansal): We haven't added Safari here since it supports dns
211-
// prefetch only from 5.0.1 which causes the wildcard to be a bit messy.
212210
const char* kInsertDnsPrefetchWhitelist[] = {
213211
"*Chrome/*",
214212
"*Firefox/*",
213+
"*Safari/*",
215214
// Plus IE, see code below.
216215
"*Wget*",
217216
// The following user agents are used only for internal testing
@@ -222,6 +221,15 @@ const char* kInsertDnsPrefetchBlacklist[] = {
222221
"*Firefox/1.*",
223222
"*Firefox/2.*",
224223
"*Firefox/3.*",
224+
// Safari indicates version with a separate Version/N.N.N token that appears
225+
// somewhere before the Safari/ token. This only started with version 3, but
226+
// versions before 3 are 10+ years old at this point and won't run on any
227+
// supported OS.
228+
"*Version/3.*Safari/*",
229+
"*Version/4.*Safari/*",
230+
// 5.0.1+ actually did support it, but that's long obsolete, so don't bother
231+
// contorting the list to include it.
232+
"*Version/5.*Safari/*",
225233
"*MSIE 5.*",
226234
"*MSIE 6.*",
227235
"*MSIE 7.*",

pagespeed/kernel/http/user_agent_matcher_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ TEST_F(UserAgentMatcherTest, SupportsDnsPrefetch) {
438438
kIe9UserAgent));
439439
EXPECT_TRUE(user_agent_matcher_->SupportsDnsPrefetch(
440440
kFirefox5UserAgent));
441+
EXPECT_TRUE(user_agent_matcher_->SupportsDnsPrefetch(
442+
kSafari6UserAgent));
443+
EXPECT_TRUE(user_agent_matcher_->SupportsDnsPrefetch(
444+
kSafari9UserAgent));
441445
for (int i = 0; i < kIe11UserAgentsArraySize; ++i) {
442446
EXPECT_TRUE(user_agent_matcher_->SupportsDnsPrefetch(
443447
kIe11UserAgents[i]));

pagespeed/kernel/http/user_agent_matcher_test_base.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ const char UserAgentMatcherTestBase::kRoverUserAgent[] =
277277
const char UserAgentMatcherTestBase::kSafariUserAgent[] =
278278
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.51.22 "
279279
"(KHTML, like Gecko) Version/5.1.1 Safari/534.51.22";
280+
const char UserAgentMatcherTestBase::kSafari6UserAgent[] =
281+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.25 "
282+
"(KHTML, like Gecko) Version/6.0 Safari/536.25";
283+
const char UserAgentMatcherTestBase::kSafari9UserAgent[] =
284+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/601.6.17 "
285+
"(KHTML, like Gecko) Version/9.1.1 Safari/601.6.17";
280286
const char UserAgentMatcherTestBase::kSAGEMMobileUserAgent[] =
281287
"SAGEM-my202C/Orange1.0 UP.Browser/5.0.5.6 (GUI)";
282288
const char UserAgentMatcherTestBase::kSAGEMUserAgent[] =

pagespeed/kernel/http/user_agent_matcher_test_base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class UserAgentMatcherTestBase : public testing::Test {
123123
static const char kPSPUserAgent[];
124124
static const char kRoverUserAgent[];
125125
static const char kSafariUserAgent[];
126+
static const char kSafari6UserAgent[];
127+
static const char kSafari9UserAgent[];
126128
static const char kSAGEMMobileUserAgent[];
127129
static const char kSAGEMUserAgent[];
128130
static const char kSAMSUNGMobileUserAgent[];

0 commit comments

Comments
 (0)