Added string escape for DemuxConcatArgument

Fixes issue when source files have a ``'`` in their path
This commit is contained in:
Jonas Kamsker 2022-01-04 16:05:40 +01:00 committed by GitHub
parent 7461407f92
commit 21d1df824f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,8 +16,17 @@ public class DemuxConcatArgument : IInputArgument
public readonly IEnumerable<string> Values;
public DemuxConcatArgument(IEnumerable<string> values)
{
Values = values.Select(value => $"file '{value}'");
Values = values.Select(value => $"file '{Escape(value)}'");
}
/// <summary>
/// Thanks slhck
/// https://superuser.com/a/787651/1089628
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
private string Escape(string value) => value.Replace("'", @"'\''");
private readonly string _tempFileName = Path.Combine(GlobalFFOptions.Current.TemporaryFilesFolder, $"concat_{Guid.NewGuid()}.txt");
public void Pre() => File.WriteAllLines(_tempFileName, Values);