|
| 1 | +From 119abc03aac8c5cf1af0845a0e64b3027ce1fa78 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Sat, 5 Mar 2022 17:02:38 -0800 |
| 4 | +Subject: [PATCH] soup-tld: disabled when libpsl is optional |
| 5 | + |
| 6 | +When building without libpsl, we no longer have soup-tld.c. As a result, |
| 7 | +we do not provide those APIs in the built library and additionally the |
| 8 | +following change is made to soup_cookie_jar_add_cookie_full() |
| 9 | + |
| 10 | +1. We no longer reject cookies for public domains |
| 11 | +2. If the accept policy is not SOUP_COOKIE_JAR_ACCEPT_ALWAYS we assume |
| 12 | + all incoming cookie is third party and reject it. |
| 13 | +--- |
| 14 | + libsoup/meson.build | 4 +++- |
| 15 | + libsoup/soup-cookie-jar.c | 6 ++++++ |
| 16 | + meson.build | 5 ++++- |
| 17 | + tests/meson.build | 7 ++++++- |
| 18 | + 4 files changed, 19 insertions(+), 3 deletions(-) |
| 19 | + |
| 20 | +diff --git a/libsoup/meson.build b/libsoup/meson.build |
| 21 | +index e585b3fe..ec0aca23 100644 |
| 22 | +--- a/libsoup/meson.build |
| 23 | ++++ b/libsoup/meson.build |
| 24 | +@@ -76,7 +76,6 @@ soup_sources = [ |
| 25 | + 'soup-socket.c', |
| 26 | + 'soup-socket-properties.c', |
| 27 | + 'soup-status.c', |
| 28 | +- 'soup-tld.c', |
| 29 | + 'soup-uri.c', |
| 30 | + 'soup-value-utils.c', |
| 31 | + 'soup-version.c', |
| 32 | +@@ -208,6 +207,9 @@ if brotlidec_dep.found() |
| 33 | + soup_headers += 'soup-brotli-decompressor.h' |
| 34 | + endif |
| 35 | + |
| 36 | ++if libpsl_dep.found() |
| 37 | ++ soup_sources += 'soup-tld.c' |
| 38 | ++endif |
| 39 | + |
| 40 | + includedir = join_paths(libsoup_api_name, meson.project_name()) |
| 41 | + install_headers(soup_installed_headers, subdir : includedir) |
| 42 | +diff --git a/libsoup/soup-cookie-jar.c b/libsoup/soup-cookie-jar.c |
| 43 | +index c8231f0e..5e35e135 100644 |
| 44 | +--- a/libsoup/soup-cookie-jar.c |
| 45 | ++++ b/libsoup/soup-cookie-jar.c |
| 46 | +@@ -595,18 +595,24 @@ soup_cookie_jar_add_cookie_full (SoupCookieJar *jar, SoupCookie *cookie, SoupURI |
| 47 | + g_return_if_fail (SOUP_IS_COOKIE_JAR (jar)); |
| 48 | + g_return_if_fail (cookie != NULL); |
| 49 | + |
| 50 | ++#ifdef HAVE_TLD |
| 51 | + /* Never accept cookies for public domains. */ |
| 52 | + if (!g_hostname_is_ip_address (cookie->domain) && |
| 53 | + soup_tld_domain_is_public_suffix (cookie->domain)) { |
| 54 | + soup_cookie_free (cookie); |
| 55 | + return; |
| 56 | + } |
| 57 | ++#endif |
| 58 | + |
| 59 | + priv = soup_cookie_jar_get_instance_private (jar); |
| 60 | + |
| 61 | + if (first_party != NULL) { |
| 62 | ++#ifdef HAVE_TLD |
| 63 | + if (priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NEVER || |
| 64 | + incoming_cookie_is_third_party (jar, cookie, first_party, priv->accept_policy)) { |
| 65 | ++#else // no TLD, assume every cookie is third-party |
| 66 | ++ if (priv->accept_policy != SOUP_COOKIE_JAR_ACCEPT_ALWAYS) { |
| 67 | ++#endif |
| 68 | + soup_cookie_free (cookie); |
| 69 | + return; |
| 70 | + } |
| 71 | +diff --git a/meson.build b/meson.build |
| 72 | +index 3cc56fb9..5865dfc7 100644 |
| 73 | +--- a/meson.build |
| 74 | ++++ b/meson.build |
| 75 | +@@ -148,7 +148,10 @@ endif |
| 76 | + |
| 77 | + libpsl_required_version = '>= 0.20' |
| 78 | + libpsl_dep = dependency('libpsl', version : libpsl_required_version, |
| 79 | +- fallback : ['libpsl', 'libpsl_dep']) |
| 80 | ++ fallback : ['libpsl', 'libpsl_dep'], required : false) |
| 81 | ++if libpsl_dep.found() |
| 82 | ++ cdata.set('HAVE_TLD', '1') |
| 83 | ++endif |
| 84 | + |
| 85 | + if cc.has_function('gmtime_r', prefix : '#include <time.h>', args : default_source_flag) |
| 86 | + cdata.set('HAVE_GMTIME_R', '1') |
| 87 | +diff --git a/tests/meson.build b/tests/meson.build |
| 88 | +index 5482aa86..d5b32a12 100644 |
| 89 | +--- a/tests/meson.build |
| 90 | ++++ b/tests/meson.build |
| 91 | +@@ -62,7 +62,6 @@ tests = [ |
| 92 | + ['ssl', true, []], |
| 93 | + ['streaming', true, []], |
| 94 | + ['timeout', true, []], |
| 95 | +- ['tld', true, []], |
| 96 | + ['uri-parsing', true, []], |
| 97 | + ['websocket', true, [libz_dep]] |
| 98 | + ] |
| 99 | +@@ -82,6 +81,12 @@ if brotlidec_dep.found() |
| 100 | + endif |
| 101 | + endif |
| 102 | + |
| 103 | ++if libpsl_dep.found() |
| 104 | ++ tests += [ |
| 105 | ++ ['tld', true, []], |
| 106 | ++ ] |
| 107 | ++endif |
| 108 | ++ |
| 109 | + if have_apache |
| 110 | + tests += [ |
| 111 | + ['auth', false, []], |
| 112 | +-- |
| 113 | +2.32.0 (Apple Git-132) |
| 114 | + |
0 commit comments