Skip to content

Commit 3961561

Browse files
committed
Update safe browsing warning for phishing sites
https://bugs.webkit.org/show_bug.cgi?id=288586 rdar://145601460 Reviewed by Charlie Wolfe. Update the phishing warning text according to requirements laid out in radar. This patch also cleans up HAVE_SAFE_BROWSING_RESULT_DETAILS, which is no longer needed. * Source/WTF/wtf/PlatformHave.h: * Source/WebCore/en.lproj/Localizable.strings: * Source/WebKit/Platform/spi/Cocoa/SafeBrowsingSPI.h: * Source/WebKit/UIProcess/Cocoa/BrowsingWarningCocoa.mm: (WebKit::malwareDetailsBase): (WebKit::learnMoreURL): (WebKit::reportAnErrorBase): (WebKit::localizedProviderDisplayName): (WebKit::localizedProviderName): (WebKit::browsingDetailsText): (WebKit::localizedProvider): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm: (-[TestServiceLookupResult localizedProviderDisplayName]): Canonical link: https://commits.webkit.org/291164@main
1 parent aecb3e1 commit 3961561

File tree

5 files changed

+26
-36
lines changed

5 files changed

+26
-36
lines changed

Source/WTF/wtf/PlatformHave.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,10 +1129,6 @@
11291129
#define HAVE_SHARE_SHEET_UI 1
11301130
#endif
11311131

1132-
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000) || PLATFORM(IOS) || PLATFORM(WATCHOS) || PLATFORM(VISION)
1133-
#define HAVE_SAFE_BROWSING_RESULT_DETAILS 1
1134-
#endif
1135-
11361132
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000) \
11371133
|| PLATFORM(IOS_FAMILY)
11381134
#define HAVE_MEMORY_ATTRIBUTION_VM_SHARE_SUPPORT 1

Source/WebCore/en.lproj/Localizable.strings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@
731731
"Host \"%s\" is invalid." = "Host \"%s\" is invalid.";
732732

733733
/* Phishing warning description */
734-
"If you believe this website is safe, you can %report-an-error%. Or, if you understand the risks involved, you can %bypass-link%." = "If you believe this website is safe, you can %report-an-error%. Or, if you understand the risks involved, you can %bypass-link%.";
734+
"This website was reported as deceptive by %provider-display-name%. If you believe this website is safe, you can %report-an-error% to %provider%. Or, if you understand the risks involved, you can %bypass-link%." = "This website was reported as deceptive by %provider-display-name%. If you believe this website is safe, you can %report-an-error% to %provider%. Or, if you understand the risks involved, you can %bypass-link%.";
735735

736736
/* Action from safe browsing warning */
737737
"If you understand the risks involved, you can %visit-this-unsafe-site-link%." = "If you understand the risks involved, you can %visit-this-unsafe-site-link%.";

Source/WebKit/Platform/spi/Cocoa/SafeBrowsingSPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ WTF_EXTERN_C_BEGIN
3939

4040
extern SSBProvider const SSBProviderGoogle;
4141
extern SSBProvider const SSBProviderTencent;
42+
extern SSBProvider const SSBProviderApple;
4243

4344
WTF_EXTERN_C_END
4445

@@ -50,12 +51,11 @@ WTF_EXTERN_C_END
5051
@property (nonatomic, readonly, getter=isMalware) BOOL malware;
5152
@property (nonatomic, readonly, getter=isUnwantedSoftware) BOOL unwantedSoftware;
5253

53-
#if HAVE(SAFE_BROWSING_RESULT_DETAILS)
5454
@property (nonatomic, readonly) NSString *malwareDetailsBaseURLString;
5555
@property (nonatomic, readonly) NSURL *learnMoreURL;
5656
@property (nonatomic, readonly) NSString *reportAnErrorBaseURLString;
5757
@property (nonatomic, readonly) NSString *localizedProviderDisplayName;
58-
#endif
58+
@property (nonatomic, readonly) NSString *localizedProviderShortName;
5959

6060
@end
6161

Source/WebKit/UIProcess/Cocoa/BrowsingWarningCocoa.mm

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,52 +33,46 @@
3333
#import <wtf/StdLibExtras.h>
3434
#import <wtf/text/MakeString.h>
3535

36+
NSString * const SSBProviderGoogle = @"SSBProviderGoogle";
37+
NSString * const SSBProviderTencent = @"SSBProviderTencent";
38+
NSString * const SSBProviderApple = @"SSBProviderApple";
39+
3640
namespace WebKit {
3741

3842
#if HAVE(SAFE_BROWSING)
3943

4044
static String malwareDetailsBase(SSBServiceLookupResult *result)
4145
{
42-
#if HAVE(SAFE_BROWSING_RESULT_DETAILS)
4346
return result.malwareDetailsBaseURLString;
44-
#else
45-
if ([result.provider isEqualToString:SSBProviderTencent])
46-
return "https://www.urlsec.qq.com/check.html?tpl=safari"_s;
47-
return "https://google.com/safebrowsing/diagnostic?tpl=safari"_s;
48-
#endif
4947
}
5048

5149
static NSURL *learnMoreURL(SSBServiceLookupResult *result)
5250
{
53-
#if HAVE(SAFE_BROWSING_RESULT_DETAILS)
5451
return result.learnMoreURL;
55-
#else
56-
if ([result.provider isEqualToString:SSBProviderTencent])
57-
return [NSURL URLWithString:@"https://www.urlsec.qq.com/standard/s1.html?tpl=safari"];
58-
return [NSURL URLWithString:@"https://www.google.com/support/bin/answer.py?answer=106318"];
59-
#endif
6052
}
6153

6254
static String reportAnErrorBase(SSBServiceLookupResult *result)
6355
{
64-
#if HAVE(SAFE_BROWSING_RESULT_DETAILS)
6556
return result.reportAnErrorBaseURLString;
66-
#else
67-
if ([result.provider isEqualToString:SSBProviderTencent])
68-
return "https://www.urlsec.qq.com/complain.html?tpl=safari"_s;
69-
return "https://www.google.com/safebrowsing/report_error/?tpl=safari"_s;
70-
#endif
7157
}
7258

73-
static String localizedProvider(SSBServiceLookupResult *result)
59+
static String localizedProviderDisplayName(SSBServiceLookupResult *result)
7460
{
75-
#if HAVE(SAFE_BROWSING_RESULT_DETAILS)
7661
return result.localizedProviderDisplayName;
77-
#else
78-
if ([result.provider isEqualToString:SSBProviderTencent])
79-
return WEB_UI_NSSTRING(@"Tencent Safe Browsing", "Tencent Safe Browsing");
80-
return WEB_UI_NSSTRING(@"Google Safe Browsing", "Google Safe Browsing");
81-
#endif
62+
}
63+
64+
static String localizedProviderShortName(SSBServiceLookupResult *result)
65+
{
66+
if ([result respondsToSelector:@selector(localizedProviderShortName)])
67+
return result.localizedProviderShortName;
68+
if ([result.provider isEqual:SSBProviderGoogle])
69+
return "Google"_s;
70+
if ([result.provider isEqual:SSBProviderTencent])
71+
return "Tencent"_s;
72+
if ([result.provider isEqual:SSBProviderApple])
73+
return "Apple"_s;
74+
ASSERT_NOT_REACHED();
75+
return ""_s;
8276
}
8377

8478

@@ -151,20 +145,22 @@ static void addLinkAndReplace(NSMutableAttributedString *string, NSString *toRep
151145
if (result.isPhishing) {
152146
NSString *phishingDescription = WEB_UI_NSSTRING(@"Warnings are shown for websites that have been reported as deceptive. Deceptive websites try to trick you into believing they are legitimate websites you trust.", "Phishing warning description");
153147
NSString *learnMore = WEB_UI_NSSTRING(@"Learn more…", "Action from safe browsing warning");
154-
NSString *phishingActions = WEB_UI_NSSTRING(@"If you believe this website is safe, you can %report-an-error%. Or, if you understand the risks involved, you can %bypass-link%.", "Phishing warning description");
148+
NSString *phishingActions = WEB_UI_NSSTRING(@"This website was reported as deceptive by %provider-display-name%. If you believe this website is safe, you can %report-an-error% to %provider%. Or, if you understand the risks involved, you can %bypass-link%.", "Phishing warning description");
155149
NSString *reportAnError = WEB_UI_NSSTRING(@"report an error", "Action from safe browsing warning");
156150
NSString *visitUnsafeWebsite = WEB_UI_NSSTRING(@"visit this unsafe website", "Action from safe browsing warning");
157151

158152
auto attributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@\n\n%@", phishingDescription, learnMore, phishingActions]]);
159153
addLinkAndReplace(attributedString.get(), learnMore, learnMore, learnMoreURL(result));
154+
replace(attributedString.get(), @"%provider-display-name%", localizedProviderDisplayName(result));
155+
replace(attributedString.get(), @"%provider%", localizedProviderShortName(result));
160156
addLinkAndReplace(attributedString.get(), @"%report-an-error%", reportAnError, reportAnErrorURL(url, result));
161157
addLinkAndReplace(attributedString.get(), @"%bypass-link%", visitUnsafeWebsite, BrowsingWarning::visitUnsafeWebsiteSentinel());
162158
return attributedString.autorelease();
163159
}
164160

165161
auto malwareOrUnwantedSoftwareDetails = [&] (NSString *description, NSString *statusStringToReplace, bool confirmMalware) {
166162
auto malwareDescription = adoptNS([[NSMutableAttributedString alloc] initWithString:description]);
167-
replace(malwareDescription.get(), @"%safeBrowsingProvider%", localizedProvider(result));
163+
replace(malwareDescription.get(), @"%safeBrowsingProvider%", localizedProviderDisplayName(result));
168164
auto statusLink = adoptNS([[NSMutableAttributedString alloc] initWithString:WEB_UI_NSSTRING(@"the status of “%site%”", "Part of malware description")]);
169165
replace(statusLink.get(), @"%site%", url.host().toString());
170166
addLinkAndReplace(malwareDescription.get(), statusStringToReplace, [statusLink string], malwareDetailsURL(url, result));

Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ - (BOOL)isUnwantedSoftware
110110
return _isUnwantedSoftware;
111111
}
112112

113-
#if HAVE(SAFE_BROWSING_RESULT_DETAILS)
114113
- (NSString *)malwareDetailsBaseURLString
115114
{
116115
return @"test://";
@@ -130,7 +129,6 @@ - (NSString *)localizedProviderDisplayName
130129
{
131130
return @"test display name";
132131
}
133-
#endif
134132

135133
@end
136134

0 commit comments

Comments
 (0)