Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d5d7c2176bc747df9090acab2eac8193424b4273
https://github.com/WebKit/WebKit/commit/d5d7c2176bc747df9090acab2eac8193424b4273
Author: Joanne Pan <[email protected]>
Date: 2026-06-11 (Thu, 11 Jun 2026)
Changed paths:
M Source/WebKit/Shared/WebHitTestResultData.cpp
M Source/WebKit/WebProcess/WebPage/WebFrame.cpp
M Source/WebKit/WebProcess/WebPage/WebFrame.h
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/ContextMenuTests.mm
Log Message:
-----------
tumblr.com: Saving .gifv image adds .html to end of filename
https://bugs.webkit.org/show_bug.cgi?id=316350
rdar://70161124
Reviewed by Sammy Gill.
The problem: when an <img>'s url coincides with the main document url,
Save Image suggests a filename with the wrong extension
(e.g., tumblr_inline_*.gifv.html). WebFrame::suggestedFilenameForResourceWithURL
and mimeTypeForResourceWithURL short-circuit to the document loader's
response when the image url equals the document url, so an <img> on an
HTML interstitial gets the document's text/html MIME instead of the
image's image/* MIME. NSURLResponse.suggestedFilename then appends .html
to the url-derived filename, and MIMETypeRegistry::correctExtensionForMIMEType
can't recover when the url extension is unregistered.
The fix: add a WebFrame::ResourceType { Generic, Image } hint and thread it
through suggestedFilenameForResourceWithURL and mimeTypeForResourceWithURL.
When the caller passes ResourceType::Image, the main resource short circuit
skips itself if the document's MIME is non-image (the contradiction the bug
hinges on), and the methods fall through to CachedResourceLoader::cachedResource
to find the actual image's response. WebHitTestResultData no longer reaches
into the render tree from Source/WebKit/Shared/.
Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/ContextMenuTests.mm
* Source/WebKit/Shared/WebHitTestResultData.cpp:
(WebKit::imageSuggestedFilenameFromHitTestResult):
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::suggestedFilenameForResourceWithURL const):
(WebKit::WebFrame::mimeTypeForResourceWithURL const):
* Source/WebKit/WebProcess/WebPage/WebFrame.h:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/ContextMenuTests.mm:
(TestWebKitAPI::imageSuggestedFilenameFromCollidingImageURL):
(TestWebKitAPI::TEST(ContextMenuTests,
HitTestResultImageSuggestedFilenameWhenURLCollidesWithMainResource)):
(TestWebKitAPI::TEST(ContextMenuTests,
HitTestResultImageSuggestedFilenameWhenURLCollidesAndNoContentDisposition)):
Canonical link: https://commits.webkit.org/315059@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications