diff options
author | bptato <nincsnevem662@gmail.com> | 2024-12-27 19:56:24 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-12-27 20:07:09 +0100 |
commit | 93033c2c382aaff01b1aba6f5db7652c35708bf3 (patch) | |
tree | 0dcfe87eb2baff4d2e70e088eafa8436cf702fd9 /src/types | |
parent | 158cf739c933692c05cc74938b0f8d5e1d8341c4 (diff) | |
download | chawan-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/types')
-rw-r--r-- | src/types/cookie.nim | 23 |
1 files changed, 3 insertions, 20 deletions
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() |