From 975bd75c5de76f5ae0dea8c468f216d38d02f5be Mon Sep 17 00:00:00 2001 From: alex6dj Date: Sun, 3 Oct 2021 11:07:15 -0400 Subject: [PATCH] Fixed single quotes escape in subtitle file path --- FFMpegCore.Test/ArgumentBuilderTest.cs | 4 ++-- FFMpegCore/Extend/StringExtensions.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/FFMpegCore.Test/ArgumentBuilderTest.cs b/FFMpegCore.Test/ArgumentBuilderTest.cs index 5f2ce5c..9a358ae 100644 --- a/FFMpegCore.Test/ArgumentBuilderTest.cs +++ b/FFMpegCore.Test/ArgumentBuilderTest.cs @@ -353,10 +353,10 @@ public void Builder_BuildString_SubtitleHardBurnFilterFixedPaths() .OutputToFile("output.mp4", false, opt => opt .WithVideoFilters(filterOptions => filterOptions .HardBurnSubtitle(SubtitleHardBurnOptions - .Create(subtitlePath: @"sample( \ : [ ] , ).srt")))) + .Create(subtitlePath: @"sample( \ : [ ] , ' ).srt")))) .Arguments; - Assert.AreEqual(@"-i ""input.mp4"" -vf ""subtitles='sample( \\ \: \[ \] \, ).srt'"" ""output.mp4""", + Assert.AreEqual(@"-i ""input.mp4"" -vf ""subtitles='sample( \\ \: \[ \] \, '\\\'' ).srt'"" ""output.mp4""", str); } diff --git a/FFMpegCore/Extend/StringExtensions.cs b/FFMpegCore/Extend/StringExtensions.cs index 7afcc34..2c33681 100644 --- a/FFMpegCore/Extend/StringExtensions.cs +++ b/FFMpegCore/Extend/StringExtensions.cs @@ -7,11 +7,11 @@ internal static class StringExtensions { private static Dictionary CharactersSubstitution { get; } = new Dictionary { - {'\\', @"\\"}, - {':', @"\:"}, - {'[', @"\["}, - {']', @"\]"}, - // {'\'', @"\'"} TODO: Quotes need to be escaped but i failed miserably + { '\\', @"\\" }, + { ':', @"\:" }, + { '[', @"\[" }, + { ']', @"\]" }, + { '\'', @"'\\\''" } }; ///