Skip to content

Commit

Permalink
Web Manifest: scope url should strip both query and fragment components
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273989
rdar://127863839

Reviewed by Brady Eidson.

Removes the query and fragment components from the scope URL.
Part of w3c/manifest#1122

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

Canonical link: https://commits.webkit.org/278795@main
  • Loading branch information
marcoscaceres committed May 15, 2024
1 parent f276033 commit a79153b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ std::optional<URL> ApplicationManifestParser::parseScope(const JSON::Object& man
return std::nullopt;
}

scopeURL.removeQueryAndFragmentIdentifier();

return scopeURL;
}

Expand Down
12 changes: 12 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebCore/ApplicationManifestParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,18 @@ TEST_F(ApplicationManifestParserTest, Scope)
m_startURL = URL { "https://example.com/documents/home"_s };
m_manifestURL = URL { "https://example.com/resources/manifest.json"_s };

// Removes query
testScope("\"https://example.com/documents/home?query\""_s, "https://example.com/documents/home"_s, false);
testScope("\"https://example.com/documents/home?query=whatever\""_s, "https://example.com/documents/home"_s, false);

// Removes fragment
testScope("\"https://example.com/documents/home#\""_s, "https://example.com/documents/home"_s, false);
testScope("\"https://example.com/documents/home#fragment\""_s, "https://example.com/documents/home"_s, false);

// Removes query and fragment
testScope("\"https://example.com/documents/home?#\""_s, "https://example.com/documents/home"_s, false);
testScope("\"https://example.com/documents/home?query#fragment\""_s, "https://example.com/documents/home"_s, false);

// It's fine if the document URL or manifest URL aren't within the application scope - only the start URL needs to be.
testScope("\"https://example.com/other\""_s, "https://example.com/other/start-url"_s, "https://example.com/other"_s, false);
}
Expand Down

0 comments on commit a79153b

Please sign in to comment.