aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-12-27 19:56:24 +0100
committerbptato <nincsnevem662@gmail.com>2024-12-27 20:07:09 +0100
commit93033c2c382aaff01b1aba6f5db7652c35708bf3 (patch)
tree0dcfe87eb2baff4d2e70e088eafa8436cf702fd9 /src
parent158cf739c933692c05cc74938b0f8d5e1d8341c4 (diff)
downloadchawan-93033c2c382aaff01b1aba6f5db7652c35708bf3.tar.gz
cookie: remove broken third-party-cookie option
Looking at it closer, this never actually did what it advertised to do. It only affected first-party cookies from subdomains, but that has been fixed; third-party cookies were never supported in the first place. (In fact, even first-party cookies are still skipped unless directly received on navigation. This should probably be fixed.)
Diffstat (limited to 'src')
-rw-r--r--src/config/config.nim1
-rw-r--r--src/local/pager.nim3
-rw-r--r--src/types/cookie.nim23
3 files changed, 4 insertions, 23 deletions
diff --git a/src/config/config.nim b/src/config/config.nim
index 68725b77..690014b5 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -61,7 +61,6 @@ type
host*: Option[Regex]
rewrite_url*: Option[JSValueFunction]
cookie*: Option[bool]
- third_party_cookie*: seq[Regex]
share_cookie_jar*: Option[string]
referer_from*: Option[bool]
scripting*: Option[ScriptingMode]
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 2d5f7ec4..6123cec5 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -1848,8 +1848,7 @@ proc applySiteconf(pager: Pager; url: URL; charsetOverride: Charset;
# host/url might have changed by now
let jarid = sc.share_cookie_jar.get(url.host)
if jarid notin pager.cookiejars:
- pager.cookiejars[jarid] = newCookieJar(url,
- sc.third_party_cookie)
+ pager.cookiejars[jarid] = newCookieJar(url)
loaderConfig.cookieJar = pager.cookiejars[jarid]
else:
loaderConfig.cookieJar = nil # override
diff --git a/src/types/cookie.nim b/src/types/cookie.nim
index ac0f1b39..831d7464 100644
--- a/src/types/cookie.nim
+++ b/src/types/cookie.nim
@@ -2,7 +2,6 @@ import std/options
import std/strutils
import std/times
-import monoucha/jsregex
import types/opt
import types/url
import utils/twtstr
@@ -20,7 +19,6 @@ type
CookieJar* = ref object
domain: string
- allowHosts: seq[Regex]
cookies*: seq[Cookie]
proc parseCookieDate(val: string): Option[int64] =
@@ -114,8 +112,6 @@ proc parseCookieDate(val: string): Option[int64] =
proc `$`*(cookieJar: CookieJar): string =
result &= $cookieJar.domain
result &= ":\n"
- for re in cookieJar.allowHosts:
- result &= "third-party " & $re & '\n'
for cookie in cookieJar.cookies:
result &= "Cookie "
result &= $cookie[]
@@ -178,19 +174,9 @@ proc add(cookieJar: CookieJar; cookie: Cookie) =
else:
cookieJar.cookies.add(cookie)
-proc match(cookieJar: CookieJar; url: URL): bool =
- if cookieJar.domain.cookieDomainMatches(url):
- return true
- if cookieJar.allowHosts.len > 0:
- let host = url.host
- for re in cookieJar.allowHosts:
- if re.match(host):
- return true
- return false
-
# https://www.rfc-editor.org/rfc/rfc6265#section-5.4
proc serialize*(cookieJar: CookieJar; url: URL): string =
- if not cookieJar.match(url):
+ if not cookieJar.domain.cookieDomainMatches(url):
return ""
var res = ""
let t = getTime().toUnix()
@@ -258,11 +244,8 @@ proc parseCookie(str: string; t: int64; url: URL): Opt[Cookie] =
cookie.path = defaultCookiePath(url)
return ok(cookie)
-proc newCookieJar*(url: URL; allowHosts: seq[Regex]): CookieJar =
- return CookieJar(
- domain: url.host,
- allowHosts: allowHosts
- )
+proc newCookieJar*(url: URL): CookieJar =
+ return CookieJar(domain: url.host)
proc setCookie*(cookieJar: CookieJar; header: openArray[string]; url: URL) =
let t = getTime().toUnix()