From 7e93a86ae0997bc07dafed3df439c0eacc2b12db Mon Sep 17 00:00:00 2001 From: Diego Heras Date: Sun, 5 Jan 2020 07:31:32 +0100 Subject: [PATCH] core: fix magnet link encoding. resolves #5372 #4761 (#6824) --- src/Jackett.Common/Definitions/1337x.yml | 3 --- src/Jackett.Common/Definitions/extratorrent-ag.yml | 3 --- src/Jackett.Common/Definitions/isohunt2.yml | 2 -- src/Jackett.Common/Definitions/kickasstorrent-kathow.yml | 2 -- src/Jackett.Server/Controllers/DownloadController.cs | 8 ++++++-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Jackett.Common/Definitions/1337x.yml b/src/Jackett.Common/Definitions/1337x.yml index 83171aa13..9f0f86240 100644 --- a/src/Jackett.Common/Definitions/1337x.yml +++ b/src/Jackett.Common/Definitions/1337x.yml @@ -139,9 +139,6 @@ download: # the .torrent url is on the on the details page selector: ul li a[href^="{{ .Config.downloadlink }}"] - filters: - - name: replace # temp fix for #5372 - args: ["%E2%AD%90", ""] search: paths: diff --git a/src/Jackett.Common/Definitions/extratorrent-ag.yml b/src/Jackett.Common/Definitions/extratorrent-ag.yml index a2823e29c..ff503369b 100644 --- a/src/Jackett.Common/Definitions/extratorrent-ag.yml +++ b/src/Jackett.Common/Definitions/extratorrent-ag.yml @@ -957,9 +957,6 @@ download: selector: td a[href^="magnet:?xt="] attribute: href - filters: - - name: replace # temp fix for #5372 - args: ["%E2%AD%90", ""] date: selector: td:nth-last-of-type(5) filters: diff --git a/src/Jackett.Common/Definitions/isohunt2.yml b/src/Jackett.Common/Definitions/isohunt2.yml index b076a93a3..9f20f7f84 100644 --- a/src/Jackett.Common/Definitions/isohunt2.yml +++ b/src/Jackett.Common/Definitions/isohunt2.yml @@ -55,8 +55,6 @@ filters: - name: querystring args: url - - name: replace # temp fix for #5372 - args: ["%E2%AD%90", ""] search: paths: - path: torrents diff --git a/src/Jackett.Common/Definitions/kickasstorrent-kathow.yml b/src/Jackett.Common/Definitions/kickasstorrent-kathow.yml index 2f369ea3b..9687d81b2 100644 --- a/src/Jackett.Common/Definitions/kickasstorrent-kathow.yml +++ b/src/Jackett.Common/Definitions/kickasstorrent-kathow.yml @@ -74,8 +74,6 @@ filters: - name: querystring args: url - - name: replace # temp fix for #5372 - args: ["%E2%AD%90", ""] size: selector: td:nth-child(2) filters: diff --git a/src/Jackett.Server/Controllers/DownloadController.cs b/src/Jackett.Server/Controllers/DownloadController.cs index 99b8a5fc9..43a71d0b8 100644 --- a/src/Jackett.Server/Controllers/DownloadController.cs +++ b/src/Jackett.Server/Controllers/DownloadController.cs @@ -63,8 +63,12 @@ namespace Jackett.Server.Controllers && downloadBytes[6] == 0x3a // : ) { - var magneturi = Encoding.UTF8.GetString(downloadBytes); - return Redirect(new Uri(magneturi).ToString()); + // some sites provide magnet links with non-ascii characters, the only way to be sure the url + // is well encoded is to unscape and escape again + // https://github.com/Jackett/Jackett/issues/5372 + // https://github.com/Jackett/Jackett/issues/4761 + var magneturi = Uri.EscapeUriString(Uri.UnescapeDataString(Encoding.UTF8.GetString(downloadBytes))); + return Redirect(magneturi); } // This will fix torrents where the keys are not sorted, and thereby not supported by Sonarr.