From 4e55187bdb6d9cd2ae9cfbdad2a5ed52999f5515 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 9 Jun 2023 01:43:54 +0300 Subject: [PATCH] cardigann: catch JsonReaderException when parsing JSON Fixes #14439 --- src/Jackett.Common/Indexers/CardigannIndexer.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Jackett.Common/Indexers/CardigannIndexer.cs b/src/Jackett.Common/Indexers/CardigannIndexer.cs index 426a42c0d..df40fcce1 100644 --- a/src/Jackett.Common/Indexers/CardigannIndexer.cs +++ b/src/Jackett.Common/Indexers/CardigannIndexer.cs @@ -21,6 +21,7 @@ using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; using Jackett.Common.Utils.Clients; using Microsoft.AspNetCore.WebUtilities; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; using static Jackett.Common.Models.IndexerConfig.ConfigurationData; @@ -1486,7 +1487,18 @@ namespace Jackett.Common.Indexers continue; } - var parsedJson = JToken.Parse(results); + JToken parsedJson; + + try + { + parsedJson = JToken.Parse(results); + } + catch (JsonReaderException ex) + { + logger.Debug("Unexpected response content ({0} bytes): {1}", response.ContentBytes.Length, response.ContentString); + + throw new Exception("Error Parsing Json Response", ex); + } if (parsedJson == null) {