Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3919bd62ec83c09518a8000ff29870a613d22e5b
https://github.com/WebKit/WebKit/commit/3919bd62ec83c09518a8000ff29870a613d22e5b
Author: Chris Dumez <[email protected]>
Date: 2026-06-12 (Fri, 12 Jun 2026)
Changed paths:
M Source/WebKit/UIProcess/WebsiteData/Cocoa/ScreenTimeWebsiteDataSupport.mm
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ScreenTime.mm
Log Message:
-----------
ScreenTime data removal uses an unanchored host suffix match, deleting
unrelated sites' data
https://bugs.webkit.org/show_bug.cgi?id=316884
Reviewed by Abrar Rahman Protyasha.
ScreenTimeWebsiteDataSupport::removeScreenTimeData() built a set of host
strings from the origins to remove, then for every URL in the ScreenTime
history deleted it when [[url host] hasSuffix:domainString]. A bare
hasSuffix: check has no label boundary, so removing ScreenTime data for
"apple.com" also matched and deleted history for "notapple.com",
"myapple.com", "evilapple.com", etc. — any host that happens to end with
the literal suffix.
WebsiteDataRecord::hostIsInDomain() already implements the correct
semantics: a suffix match additionally requires either an exact match or
that the character preceding the suffix is '.'. Add an NSString-based
equivalent and use it in place of the bare hasSuffix: check, so that
"apple.com" matches "apple.com" and "www.apple.com" but not "notapple.com".
The comparison is kept in NSString space because the
fetchAllHistoryWithCompletionHandler completion block may run off the
main thread, where WTF::String ref-counting is not thread-safe. Also
break out of the inner loop once a URL matches (avoiding a redundant
deleteHistoryForURL: for the same URL), and skip empty hosts when
building the match set.
Test: ScreenTime.RemoveDataDoesNotMatchUnanchoredHostSuffix
* Source/WebKit/UIProcess/WebsiteData/Cocoa/ScreenTimeWebsiteDataSupport.mm:
(WebKit::ScreenTimeWebsiteDataSupport::hostIsInDomain):
(WebKit::ScreenTimeWebsiteDataSupport::removeScreenTimeData):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ScreenTime.mm:
(TEST(ScreenTime, RemoveDataDoesNotMatchUnanchoredHostSuffix)):
Canonical link: https://commits.webkit.org/315087@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications