Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b9b0329aab4d4832c70e831244a9ec7e0b82ab26
      
https://github.com/WebKit/WebKit/commit/b9b0329aab4d4832c70e831244a9ec7e0b82ab26
  Author: Charles Ma <[email protected]>
  Date:   2026-06-19 (Fri, 19 Jun 2026)

  Changed paths:
    M Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/CreateWebArchive.mm

  Log Message:
  -----------
  _archiveWithConfiguration occasionally fails with "Invalid file path" on 
pages with <link rel="icon">
rdar://179262267
https://bugs.webkit.org/show_bug.cgi?id=316813

Reviewed by Sihui Liu.

This patch addresses occasional "Invalid file path" errors when using 
_archiveWithConfiguration.
LegacyWebArchive::createInternal collects subresources in two passes. The 
second loop
reads from DocumentLoader::linkIcons() to pick up favicons and appends whatever 
DocumentLoader::subresource()
returns. Consequently, we might get a brand-new ArchiveResource with empty 
m_relativeFilePath,
which causes ArchiveResource::saveToDisk to hit the empty-path check and cause 
the failure.

This change makes the second loop more closely mirror the first loop.
We skip URLs already in uniqueSubresources, so favicons that are also 
referenced don't produce this
duplicate ArchiveResource. Also, for URLs unique to the icon loop, generate a 
valid filename and
path to avoid this empty relative filepath issue.

The new test reproduces the buggy condition by serving a page by referencing 
the same URL
in <link rel="icon"> and <link rel="stylesheet">. Without the fix, the old 
implementation fails with
_archiveWithConfiguration: fails with WKErrorDomain Code=1 ("Invalid file") and 
with the fix,
the test passes.

* Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::createInternal):

* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/CreateWebArchive.mm:
(TestWebKitAPI::(WebArchive, ArchiveWithConfigurationLinkIcon)):
The test produces 2 files because it gets added once in the first loop.
Since the the favicon is referenced as a stylesheet,
addSubresourcesForCSSStyleSheetsIfNecessary removes it from uniqueSubresources 
and added again.
This means favicon is processed again and appended giving a count of 2.

Canonical link: https://commits.webkit.org/315547@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to