mirror of https://github.com/utmapp/UTM.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.5 KiB
114 lines
3.5 KiB
From 119abc03aac8c5cf1af0845a0e64b3027ce1fa78 Mon Sep 17 00:00:00 2001
|
|
From: osy <50960678+osy@users.noreply.github.com>
|
|
Date: Sat, 5 Mar 2022 17:02:38 -0800
|
|
Subject: [PATCH] soup-tld: disabled when libpsl is optional
|
|
|
|
When building without libpsl, we no longer have soup-tld.c. As a result,
|
|
we do not provide those APIs in the built library and additionally the
|
|
following change is made to soup_cookie_jar_add_cookie_full()
|
|
|
|
1. We no longer reject cookies for public domains
|
|
2. If the accept policy is not SOUP_COOKIE_JAR_ACCEPT_ALWAYS we assume
|
|
all incoming cookie is third party and reject it.
|
|
---
|
|
libsoup/meson.build | 4 +++-
|
|
libsoup/soup-cookie-jar.c | 6 ++++++
|
|
meson.build | 5 ++++-
|
|
tests/meson.build | 7 ++++++-
|
|
4 files changed, 19 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/libsoup/meson.build b/libsoup/meson.build
|
|
index e585b3fe..ec0aca23 100644
|
|
--- a/libsoup/meson.build
|
|
+++ b/libsoup/meson.build
|
|
@@ -76,7 +76,6 @@ soup_sources = [
|
|
'soup-socket.c',
|
|
'soup-socket-properties.c',
|
|
'soup-status.c',
|
|
- 'soup-tld.c',
|
|
'soup-uri.c',
|
|
'soup-value-utils.c',
|
|
'soup-version.c',
|
|
@@ -208,6 +207,9 @@ if brotlidec_dep.found()
|
|
soup_headers += 'soup-brotli-decompressor.h'
|
|
endif
|
|
|
|
+if libpsl_dep.found()
|
|
+ soup_sources += 'soup-tld.c'
|
|
+endif
|
|
|
|
includedir = join_paths(libsoup_api_name, meson.project_name())
|
|
install_headers(soup_installed_headers, subdir : includedir)
|
|
diff --git a/libsoup/soup-cookie-jar.c b/libsoup/soup-cookie-jar.c
|
|
index c8231f0e..5e35e135 100644
|
|
--- a/libsoup/soup-cookie-jar.c
|
|
+++ b/libsoup/soup-cookie-jar.c
|
|
@@ -595,18 +595,24 @@ soup_cookie_jar_add_cookie_full (SoupCookieJar *jar, SoupCookie *cookie, SoupURI
|
|
g_return_if_fail (SOUP_IS_COOKIE_JAR (jar));
|
|
g_return_if_fail (cookie != NULL);
|
|
|
|
+#ifdef HAVE_TLD
|
|
/* Never accept cookies for public domains. */
|
|
if (!g_hostname_is_ip_address (cookie->domain) &&
|
|
soup_tld_domain_is_public_suffix (cookie->domain)) {
|
|
soup_cookie_free (cookie);
|
|
return;
|
|
}
|
|
+#endif
|
|
|
|
priv = soup_cookie_jar_get_instance_private (jar);
|
|
|
|
if (first_party != NULL) {
|
|
+#ifdef HAVE_TLD
|
|
if (priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NEVER ||
|
|
incoming_cookie_is_third_party (jar, cookie, first_party, priv->accept_policy)) {
|
|
+#else // no TLD, assume every cookie is third-party
|
|
+ if (priv->accept_policy != SOUP_COOKIE_JAR_ACCEPT_ALWAYS) {
|
|
+#endif
|
|
soup_cookie_free (cookie);
|
|
return;
|
|
}
|
|
diff --git a/meson.build b/meson.build
|
|
index 3cc56fb9..5865dfc7 100644
|
|
--- a/meson.build
|
|
+++ b/meson.build
|
|
@@ -148,7 +148,10 @@ endif
|
|
|
|
libpsl_required_version = '>= 0.20'
|
|
libpsl_dep = dependency('libpsl', version : libpsl_required_version,
|
|
- fallback : ['libpsl', 'libpsl_dep'])
|
|
+ fallback : ['libpsl', 'libpsl_dep'], required : false)
|
|
+if libpsl_dep.found()
|
|
+ cdata.set('HAVE_TLD', '1')
|
|
+endif
|
|
|
|
if cc.has_function('gmtime_r', prefix : '#include <time.h>', args : default_source_flag)
|
|
cdata.set('HAVE_GMTIME_R', '1')
|
|
diff --git a/tests/meson.build b/tests/meson.build
|
|
index 5482aa86..d5b32a12 100644
|
|
--- a/tests/meson.build
|
|
+++ b/tests/meson.build
|
|
@@ -62,7 +62,6 @@ tests = [
|
|
['ssl', true, []],
|
|
['streaming', true, []],
|
|
['timeout', true, []],
|
|
- ['tld', true, []],
|
|
['uri-parsing', true, []],
|
|
['websocket', true, [libz_dep]]
|
|
]
|
|
@@ -82,6 +81,12 @@ if brotlidec_dep.found()
|
|
endif
|
|
endif
|
|
|
|
+if libpsl_dep.found()
|
|
+ tests += [
|
|
+ ['tld', true, []],
|
|
+ ]
|
|
+endif
|
|
+
|
|
if have_apache
|
|
tests += [
|
|
['auth', false, []],
|
|
--
|
|
2.32.0 (Apple Git-132)
|
|
|