libsoup-3.6.0.patch 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. From 95102597efaddede487bd03c191fa0a08b70e3b6 Mon Sep 17 00:00:00 2001
  2. From: osy <osy@turing.llc>
  3. Date: Mon, 11 Nov 2024 14:47:39 -0800
  4. Subject: [PATCH 1/2] soup-tld: disabled when libpsl is optional
  5. When building without libpsl, we no longer have soup-tld.c. As a result,
  6. we do not provide those APIs in the built library and additionally the
  7. following change is made to soup_cookie_jar_add_cookie_full()
  8. 1. We no longer reject cookies for public domains
  9. 2. If the accept policy is not SOUP_COOKIE_JAR_ACCEPT_ALWAYS we assume
  10. all incoming cookie is third party and reject it.
  11. ---
  12. libsoup/cookies/soup-cookie-jar.c | 15 +++++++++++++++
  13. libsoup/meson.build | 5 ++++-
  14. meson.build | 5 ++++-
  15. tests/meson.build | 5 ++++-
  16. 4 files changed, 27 insertions(+), 3 deletions(-)
  17. diff --git a/libsoup/cookies/soup-cookie-jar.c b/libsoup/cookies/soup-cookie-jar.c
  18. index bdb6697a..753c36b5 100644
  19. --- a/libsoup/cookies/soup-cookie-jar.c
  20. +++ b/libsoup/cookies/soup-cookie-jar.c
  21. @@ -511,6 +511,7 @@ normalize_cookie_domain (const char *domain)
  22. return domain;
  23. }
  24. +#ifdef HAVE_TLD
  25. static gboolean
  26. incoming_cookie_is_third_party (SoupCookieJar *jar,
  27. SoupCookie *cookie,
  28. @@ -563,6 +564,16 @@ incoming_cookie_is_third_party (SoupCookieJar *jar,
  29. return retval;
  30. }
  31. +#else
  32. +static gboolean
  33. +incoming_cookie_is_third_party (SoupCookieJar *jar,
  34. + SoupCookie *cookie,
  35. + GUri *first_party,
  36. + SoupCookieJarAcceptPolicy policy)
  37. +{
  38. + return TRUE;
  39. +}
  40. +#endif
  41. static gboolean
  42. string_contains_ctrlcode (const char *s)
  43. @@ -612,7 +623,11 @@ soup_cookie_jar_add_cookie_full (SoupCookieJar *jar, SoupCookie *cookie, GUri *u
  44. /* Never accept cookies for public domains. */
  45. if (!g_hostname_is_ip_address (soup_cookie_get_domain (cookie)) &&
  46. +#ifdef HAVE_TLD
  47. soup_tld_domain_is_public_suffix (soup_cookie_get_domain (cookie))) {
  48. +#else
  49. + priv->accept_policy != SOUP_COOKIE_JAR_ACCEPT_ALWAYS){
  50. +#endif
  51. soup_cookie_free (cookie);
  52. return;
  53. }
  54. diff --git a/libsoup/meson.build b/libsoup/meson.build
  55. index d920b522..b889931d 100644
  56. --- a/libsoup/meson.build
  57. +++ b/libsoup/meson.build
  58. @@ -87,11 +87,14 @@ soup_sources = [
  59. 'soup-session-feature.c',
  60. 'soup-socket-properties.c',
  61. 'soup-status.c',
  62. - 'soup-tld.c',
  63. 'soup-uri-utils.c',
  64. 'soup-version.c',
  65. ]
  66. +if libpsl_dep.found()
  67. + soup_sources += 'soup-tld.c'
  68. +endif
  69. +
  70. soup_private_enum_headers = [
  71. 'soup-connection.h',
  72. ]
  73. diff --git a/meson.build b/meson.build
  74. index f7c63389..50ca7b91 100644
  75. --- a/meson.build
  76. +++ b/meson.build
  77. @@ -155,7 +155,10 @@ endif
  78. libpsl_required_version = '>= 0.20'
  79. libpsl_dep = dependency('libpsl', version : libpsl_required_version,
  80. - fallback : ['libpsl', 'libpsl_dep'])
  81. + fallback : ['libpsl', 'libpsl_dep'], required : false)
  82. +if libnghttp2_dep.found()
  83. + cdata.set('HAVE_TLD', true)
  84. +endif
  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 01a0c63f..cf24ef97 100644
  89. --- a/tests/meson.build
  90. +++ b/tests/meson.build
  91. @@ -102,12 +102,15 @@ tests = [
  92. },
  93. {'name': 'streaming'},
  94. {'name': 'timeout'},
  95. - {'name': 'tld'},
  96. {'name': 'uri-parsing'},
  97. {'name': 'websocket',
  98. 'dependencies': [libz_dep]},
  99. ]
  100. +if libpsl_dep.found()
  101. + tests += [{'name': 'tld'}]
  102. +endif
  103. +
  104. if brotlidec_dep.found()
  105. tests += [{'name': 'brotli-decompressor'}]
  106. --
  107. 2.41.0
  108. From e4ce620a7db4d2f1a581a8095fea32a182b353aa Mon Sep 17 00:00:00 2001
  109. From: osy <osy@turing.llc>
  110. Date: Mon, 11 Nov 2024 14:48:15 -0800
  111. Subject: [PATCH 2/2] build: make HTTP2 optional
  112. ---
  113. libsoup/meson.build | 13 ++++++++-----
  114. libsoup/server/soup-server-connection.c | 4 ++++
  115. libsoup/soup-connection.c | 4 ++++
  116. meson.build | 9 ++++++---
  117. tests/meson.build | 7 +++++--
  118. 5 files changed, 27 insertions(+), 10 deletions(-)
  119. diff --git a/libsoup/meson.build b/libsoup/meson.build
  120. index b889931d..f2f4a0d7 100644
  121. --- a/libsoup/meson.build
  122. +++ b/libsoup/meson.build
  123. @@ -39,11 +39,7 @@ soup_sources = [
  124. 'http1/soup-message-io-data.c',
  125. 'http1/soup-message-io-source.c',
  126. - 'http2/soup-client-message-io-http2.c',
  127. - 'http2/soup-body-input-stream-http2.c',
  128. -
  129. 'server/http1/soup-server-message-io-http1.c',
  130. - 'server/http2/soup-server-message-io-http2.c',
  131. 'server/soup-auth-domain.c',
  132. 'server/soup-auth-domain-basic.c',
  133. 'server/soup-auth-domain-digest.c',
  134. @@ -70,7 +66,6 @@ soup_sources = [
  135. 'soup-form.c',
  136. 'soup-headers.c',
  137. 'soup-header-names.c',
  138. - 'soup-http2-utils.c',
  139. 'soup-init.c',
  140. 'soup-io-stream.c',
  141. 'soup-logger.c',
  142. @@ -95,6 +90,14 @@ if libpsl_dep.found()
  143. soup_sources += 'soup-tld.c'
  144. endif
  145. +if libnghttp2_dep.found()
  146. + soup_sources += 'http2/soup-client-message-io-http2.c'
  147. + soup_sources += 'http2/soup-body-input-stream-http2.c'
  148. + soup_sources += 'server/http2/soup-server-message-io-http2.c'
  149. + soup_sources += 'soup-http2-utils.c'
  150. +endif
  151. +
  152. +
  153. soup_private_enum_headers = [
  154. 'soup-connection.h',
  155. ]
  156. diff --git a/libsoup/server/soup-server-connection.c b/libsoup/server/soup-server-connection.c
  157. index cac4eaa7..02fdb497 100644
  158. --- a/libsoup/server/soup-server-connection.c
  159. +++ b/libsoup/server/soup-server-connection.c
  160. @@ -395,10 +395,14 @@ soup_server_connection_connected (SoupServerConnection *conn)
  161. conn);
  162. break;
  163. case SOUP_HTTP_2_0:
  164. +#ifdef WITH_HTTP2
  165. priv->io_data = soup_server_message_io_http2_new (conn,
  166. g_steal_pointer (&priv->initial_msg),
  167. (SoupMessageIOStartedFn)request_started_cb,
  168. conn);
  169. +#else
  170. + g_assert_not_reached();
  171. +#endif
  172. break;
  173. }
  174. g_signal_emit (conn, signals[CONNECTED], 0);
  175. diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
  176. index 9100f8c9..fc28cd22 100644
  177. --- a/libsoup/soup-connection.c
  178. +++ b/libsoup/soup-connection.c
  179. @@ -504,7 +504,11 @@ soup_connection_create_io_data (SoupConnection *conn)
  180. priv->io_data = soup_client_message_io_http1_new (conn);
  181. break;
  182. case SOUP_HTTP_2_0:
  183. +#ifdef WITH_HTTP2
  184. priv->io_data = soup_client_message_io_http2_new (conn);
  185. +#else
  186. + g_assert_not_reached();
  187. +#endif
  188. break;
  189. }
  190. }
  191. diff --git a/meson.build b/meson.build
  192. index 50ca7b91..1ec35873 100644
  193. --- a/meson.build
  194. +++ b/meson.build
  195. @@ -112,9 +112,12 @@ glib_deps = [glib_dep, gmodule_dep, gobject_dep, gio_dep]
  196. cdata = configuration_data()
  197. -libnghttp2_dep = dependency('libnghttp2')
  198. -if (libnghttp2_dep.version() == 'unknown' and (libnghttp2_dep.type_name() == 'internal' or cc.has_function('nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation', prefix : '#include <nghttp2/nghttp2.h>', dependencies : libnghttp2_dep))) or libnghttp2_dep.version().version_compare('>=1.50')
  199. - cdata.set('HAVE_NGHTTP2_OPTION_SET_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION', '1')
  200. +libnghttp2_dep = dependency('libnghttp2', required : false)
  201. +if libnghttp2_dep.found()
  202. + cdata.set('WITH_HTTP2', true)
  203. + if (libnghttp2_dep.version() == 'unknown' and (libnghttp2_dep.type_name() == 'internal' or cc.has_function('nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation', prefix : '#include <nghttp2/nghttp2.h>', dependencies : libnghttp2_dep))) or libnghttp2_dep.version().version_compare('>=1.50')
  204. + cdata.set('HAVE_NGHTTP2_OPTION_SET_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION', '1')
  205. + endif
  206. endif
  207. sqlite_dep = dependency('sqlite3', required: false)
  208. diff --git a/tests/meson.build b/tests/meson.build
  209. index cf24ef97..6bd68868 100644
  210. --- a/tests/meson.build
  211. +++ b/tests/meson.build
  212. @@ -78,8 +78,6 @@ tests = [
  213. {'name': 'date'},
  214. {'name': 'forms'},
  215. {'name': 'header-parsing'},
  216. - {'name': 'http2'},
  217. - {'name': 'http2-body-stream'},
  218. {'name': 'hsts'},
  219. {'name': 'hsts-db'},
  220. {'name': 'logger'},
  221. @@ -111,6 +109,11 @@ if libpsl_dep.found()
  222. tests += [{'name': 'tld'}]
  223. endif
  224. +if libnghttp2_dep.found()
  225. + tests += [{'name': 'http2'}]
  226. + tests += [{'name': 'http2-body-stream'}]
  227. +endif
  228. +
  229. if brotlidec_dep.found()
  230. tests += [{'name': 'brotli-decompressor'}]
  231. --
  232. 2.41.0