diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2022-01-09 23:53:26 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2022-01-11 17:10:16 +0100 |
commit | 313da6b5696088b6b493695000ef790f277ed505 (patch) | |
tree | 4ee08b6eadec7a95dea6a60cec6d3f46b57dd2eb /internal/feed | |
parent | c3b84b06ff16aa0ae280538b08ee4912c3d215a8 (diff) | |
download | feed2imap-go-313da6b5696088b6b493695000ef790f277ed505.tar.gz feed2imap-go-313da6b5696088b6b493695000ef790f277ed505.tar.bz2 feed2imap-go-313da6b5696088b6b493695000ef790f277ed505.zip |
Ensure that cookies are sent only to the correct domains.cookies
We want to avoid that authentication data is sent when fetching images from external sources, for instance.
Diffstat (limited to '')
-rw-r--r-- | internal/feed/feed.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/feed/feed.go b/internal/feed/feed.go index f31de65..f403036 100644 --- a/internal/feed/feed.go +++ b/internal/feed/feed.go @@ -21,6 +21,7 @@ type Feed struct { items []Item Global config.GlobalOptions extID FeedID + jar http.CookieJar } type FeedID interface { @@ -35,10 +36,18 @@ type Descriptor struct { } func (feed *Feed) Context() http.Context { + if feed.Url != "" && len(feed.Cookies) > 0 && feed.jar == nil { + var err error + feed.jar, err = http.JarOfCookies(feed.Cookies, feed.Url) + if err != nil { + log.Errorf("Error while initialising cookies for feed '%s': %w", feed.Name, err) + } + } + return http.Context{ Timeout: feed.Global.Timeout, DisableTLS: feed.NoTLS, - Cookies: feed.Cookies, + Jar: feed.jar, } } |