From e7a48c423473e1e836fd349a6ba9c03491533022 Mon Sep 17 00:00:00 2001 From: Cory Date: Sat, 4 Jan 2020 12:49:53 -0600 Subject: [PATCH] Fix file location bug in paths with spaces during updates (#6814) resolves #6671 --- src/Jackett.Common/Services/UpdateService.cs | 7 +++++-- src/Jackett.Updater/Program.cs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Jackett.Common/Services/UpdateService.cs b/src/Jackett.Common/Services/UpdateService.cs index 3c4aaff13..427a976d2 100644 --- a/src/Jackett.Common/Services/UpdateService.cs +++ b/src/Jackett.Common/Services/UpdateService.cs @@ -51,8 +51,11 @@ namespace Jackett.Common.Services private string ExePath() { - var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase); - return new FileInfo(location.AbsolutePath).FullName; + // Use EscapedCodeBase to avoid Uri reserved characters from causing bugs + // https://stackoverflow.com/questions/896572 + var location = new Uri(Assembly.GetEntryAssembly().GetName().EscapedCodeBase); + // Use LocalPath instead of AbsolutePath to avoid needing to unescape Uri format. + return new FileInfo(location.LocalPath).FullName; } public void StartUpdateChecker() diff --git a/src/Jackett.Updater/Program.cs b/src/Jackett.Updater/Program.cs index 2af3adbde..e4befeeec 100644 --- a/src/Jackett.Updater/Program.cs +++ b/src/Jackett.Updater/Program.cs @@ -553,8 +553,11 @@ namespace Jackett.Updater private string GetUpdateLocation() { - var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase); - return new FileInfo(WebUtility.UrlDecode(location.AbsolutePath)).DirectoryName; + // Use EscapedCodeBase to avoid Uri reserved characters from causing bugs + // https://stackoverflow.com/questions/896572 + var location = new Uri(Assembly.GetEntryAssembly().GetName().EscapedCodeBase); + // Use LocalPath instead of AbsolutePath to avoid needing to unescape Uri format. + return new FileInfo(location.LocalPath).DirectoryName; } private string GetJackettConsolePath(string directoryPath)