1
0
Fork 0
mirror of https://github.com/Jackett/Jackett synced 2025-01-01 04:38:20 +00:00

core: add rss url decode in download controller. resolves #4617 #6589 #4760 #6397 #5752 (#6936)

This commit is contained in:
Diego Heras 2020-01-12 19:14:36 +01:00 committed by garfield69
parent 92556a56c6
commit 7a1c8f9419
2 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.WebUtilities;
namespace Jackett.Server.ActionFilters
{
public class DownloadActionFilter: ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// in Torznab RSS feed the "link" and "enclosure url" attributes are encoded following the RSS specification
// replacing & with &
// valid link => http://127.0.0.1:9117/dl/1337x/?jackett_apikey=ygm5k29&path=Q2ZESjhBYnJEQUIxeGd&file=Little+Mons
// encoded => http://127.0.0.1:9117/dl/1337x/?jackett_apikey=ygm5k29&path=Q2ZESjhBYnJEQUIxeGd&file=Little+Mons
// all RSS readers are able to decode the url and show the user the valid link
// some Jackett users are not decoding the url properly and this causes a 404 error in Jackett download
// this ActionFilter tries to do the decoding as a fallback, the RSS feed we provide is valid!
if (filterContext.ActionArguments.ContainsKey("path") || !filterContext.HttpContext.Request.QueryString.HasValue)
return;
// recover the original query string and parse it manually
var qs = filterContext.HttpContext.Request.QueryString.Value;
qs = qs.Replace("&", "&");
var parsedQs = QueryHelpers.ParseQuery(qs);
if (parsedQs == null)
return;
// inject the arguments in the controller
if (parsedQs.ContainsKey("path") && !filterContext.ActionArguments.ContainsKey("path"))
filterContext.ActionArguments.Add("path", parsedQs["path"].ToString());
if (parsedQs.ContainsKey("file") && !filterContext.ActionArguments.ContainsKey("file"))
filterContext.ActionArguments.Add("file", parsedQs["file"].ToString());
}
}
}

View file

@ -10,10 +10,12 @@ using NLog;
using System;
using System.Text;
using System.Threading.Tasks;
using Jackett.Server.ActionFilters;
namespace Jackett.Server.Controllers
{
[AllowAnonymous]
[DownloadActionFilter]
[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
[Route("dl/{indexerID}")]
public class DownloadController : Controller