[directlink] manually encode Referer URLs (fixes #1647)

Trying to send a non-latin-1-encodable header raises an exception,
so we encode the Referer value ourselves with 'errors=ignore'.
pull/1677/head
Mike Fährmann 3 years ago
parent 8bdeb2a6dd
commit a416e54765
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2020 Mike Fährmann
# Copyright 2017-2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@ -59,7 +59,8 @@ class DirectlinkExtractor(Extractor):
data["path"], _, name = data["path"].rpartition("/")
data["filename"], _, ext = name.rpartition(".")
data["extension"] = ext.lower()
data["_http_headers"] = {"Referer": self.url}
data["_http_headers"] = {
"Referer": self.url.encode("latin-1", "ignore")}
yield Message.Version, 1
yield Message.Directory, data

Loading…
Cancel
Save