forked from utmapp/UTM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibsoup-2.74.2.patch
114 lines (102 loc) · 3.53 KB
/
libsoup-2.74.2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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)