Skip to content

Commit

Permalink
Web Manifest: parsing the id member should strip the hash
Browse files Browse the repository at this point in the history
rdar://127864531
https://bugs.webkit.org/show_bug.cgi?id=273991

Reviewed by Sihui Liu.

Strips the hash from the id member when parsing the Web Manifest.
Part of w3c/manifest#1122

* Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseId):
* Tools/TestWebKitAPI/Tests/WebCore/ApplicationManifestParser.cpp:
(TEST_F):

Canonical link: https://commits.webkit.org/278724@main
  • Loading branch information
marcoscaceres committed May 14, 2024
1 parent 2dad7c4 commit 4a635aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ URL ApplicationManifestParser::parseId(const JSON::Object& manifest, const URL&
if (!protocolHostAndPortAreEqual(idURL, startURL))
return startURL;

idURL.removeFragmentIdentifier();

return idURL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,12 @@ TEST_F(ApplicationManifestParserTest, Id)
testId("./foo"_s, m_startURL, "https://example.com/foo"_s);
testId("foo/"_s, m_startURL, "https://example.com/foo/"_s);
testId("../../foo/bar"_s, m_startURL, "https://example.com/foo/bar"_s);
testId("../../foo/bar?query=hi#hi"_s, m_startURL, "https://example.com/foo/bar?query=hi#hi"_s);
testId("../../foo/bar?query=hi#fragment"_s, m_startURL, "https://example.com/foo/bar?query=hi"_s);
testId("../../foo/bar?query=hi#"_s, m_startURL, "https://example.com/foo/bar?query=hi"_s);

testId("https://example.com/foo"_s, m_startURL, "https://example.com/foo"_s);
testId("https://example.com/foo#"_s, m_startURL, "https://example.com/foo"_s);
testId("https://example.com/foo#fragment"_s, m_startURL, "https://example.com/foo"_s);
testId("https://anothersite.com/foo"_s, m_startURL, m_startURL.string());
testId("https://invalid.com:a"_s, m_startURL, m_startURL.string());
}
Expand Down

0 comments on commit 4a635aa

Please sign in to comment.