From 62abe4e61c91d4138b6e807d1b5c12d7c8ea62a5 Mon Sep 17 00:00:00 2001 From: da3dsoul Date: Thu, 26 Aug 2021 18:13:07 -0400 Subject: [PATCH] Try Escaping Some Characters for MediaInfo --- Shoko.Server/Utilities/MediaInfoLib/MediaInfo.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Shoko.Server/Utilities/MediaInfoLib/MediaInfo.cs b/Shoko.Server/Utilities/MediaInfoLib/MediaInfo.cs index b3070d332..2ffb70d35 100644 --- a/Shoko.Server/Utilities/MediaInfoLib/MediaInfo.cs +++ b/Shoko.Server/Utilities/MediaInfoLib/MediaInfo.cs @@ -24,7 +24,8 @@ public static MediaContainer GetMediaInfo_New(string filename) try { string exe = GetMediaInfoPathForOS(); - string args = $"--OUTPUT=JSON \"{filename}\""; + var escapedName = filename.Replace("\"", "\\\"").Replace("`", "\\`").Replace("$", "\\$"); + string args = $"--OUTPUT=JSON \"{escapedName}\""; var pProcess = GetProcess(exe, args); pProcess.Start(); @@ -41,7 +42,7 @@ public static MediaContainer GetMediaInfo_New(string filename) if (string.IsNullOrWhiteSpace(output) || output.EqualsInvariantIgnoreCase("null")) output = "No message"; - logger.Error($"MediaInfo threw an error on {filename}: {output}"); + logger.Error($"MediaInfo threw an error on {filename}, {exe} {args}: {output}"); return null; }