mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibURL+LibWebView: Move public suffix data to LibURL
This commit is contained in:
parent
edcdcea92d
commit
3124dca528
Notes:
github-actions[bot]
2024-11-30 11:24:22 +00:00
Author: https://github.com/AtkinsSJ
Commit: 3124dca528
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2610
Reviewed-by: https://github.com/shannonbooth ✅
10 changed files with 36 additions and 36 deletions
|
@ -1,5 +1,4 @@
|
|||
include(fontconfig)
|
||||
include(public_suffix)
|
||||
|
||||
set(SOURCES
|
||||
Application.cpp
|
||||
|
@ -21,7 +20,6 @@ set(SOURCES
|
|||
Utilities.cpp
|
||||
ViewImplementation.cpp
|
||||
WebContentClient.cpp
|
||||
${PUBLIC_SUFFIX_SOURCES}
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
|
@ -74,7 +72,6 @@ set(GENERATED_SOURCES
|
|||
|
||||
serenity_lib(LibWebView webview)
|
||||
target_link_libraries(LibWebView PRIVATE LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibRequests LibJS LibWeb LibUnicode LibURL LibSyntax)
|
||||
target_compile_definitions(LibWebView PRIVATE ENABLE_PUBLIC_SUFFIX=$<BOOL:${ENABLE_PUBLIC_SUFFIX_DOWNLOAD}>)
|
||||
|
||||
if (APPLE)
|
||||
target_link_libraries(LibWebView PRIVATE LibThreading)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <LibURL/URL.h>
|
||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
#include <LibWebView/CookieJar.h>
|
||||
#include <LibWebView/URL.h>
|
||||
|
||||
namespace WebView {
|
||||
|
||||
|
@ -335,7 +334,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con
|
|||
}
|
||||
|
||||
// 9. If the user agent is configured to reject "public suffixes" and the domain-attribute is a public suffix:
|
||||
if (is_public_suffix(domain_attribute)) {
|
||||
if (URL::is_public_suffix(domain_attribute)) {
|
||||
// 1. If the domain-attribute is identical to the canonicalized request-host:
|
||||
if (domain_attribute == canonicalized_domain) {
|
||||
// 1. Let the domain-attribute be the empty string.
|
||||
|
|
|
@ -6,34 +6,11 @@
|
|||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibWebView/URL.h>
|
||||
|
||||
#if defined(ENABLE_PUBLIC_SUFFIX)
|
||||
# include <LibWebView/PublicSuffixData.h>
|
||||
#endif
|
||||
|
||||
namespace WebView {
|
||||
|
||||
bool is_public_suffix([[maybe_unused]] StringView host)
|
||||
{
|
||||
#if defined(ENABLE_PUBLIC_SUFFIX)
|
||||
return PublicSuffixData::the()->is_public_suffix(host);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Optional<String> get_public_suffix([[maybe_unused]] StringView host)
|
||||
{
|
||||
#if defined(ENABLE_PUBLIC_SUFFIX)
|
||||
return MUST(PublicSuffixData::the()->get_public_suffix(host));
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
Optional<URL::URL> sanitize_url(StringView url, Optional<StringView> search_engine, AppendTLD append_tld)
|
||||
{
|
||||
if (FileSystem::exists(url.trim_whitespace())) {
|
||||
|
@ -111,7 +88,7 @@ static URLParts break_web_url_into_parts(URL::URL const& url, StringView url_str
|
|||
domain = url_without_scheme;
|
||||
}
|
||||
|
||||
auto public_suffix = get_public_suffix(domain);
|
||||
auto public_suffix = URL::get_public_suffix(domain);
|
||||
if (!public_suffix.has_value() || !domain.ends_with(*public_suffix))
|
||||
return { scheme, domain, remainder };
|
||||
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
|
||||
namespace WebView {
|
||||
|
||||
bool is_public_suffix(StringView host);
|
||||
Optional<String> get_public_suffix(StringView host);
|
||||
|
||||
enum class AppendTLD {
|
||||
No,
|
||||
Yes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue