Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only escape backslashes, single quotes, and newlines when writing ffmetadata #1161

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions TwitchDownloaderCore/Tools/FfmpegMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,22 @@ private static async Task SerializeChapters(StreamWriter sw, IEnumerable<VideoMo
}
}

// https://trac.ffmpeg.org/ticket/11096 The Ffmpeg documentation is outdated and =;# do not need to be escaped.
private static string SanitizeKeyValue(string str)
{
if (string.IsNullOrWhiteSpace(str))
{
return str;
}

if (str.AsSpan().IndexOfAny(@$"=;#\{LINE_FEED}") == -1)
if (str.AsSpan().IndexOfAny(@$"\'{LINE_FEED}") == -1)
{
return str;
}

return new StringBuilder(str)
.Replace("=", @"\=")
.Replace(";", @"\;")
.Replace("#", @"\#")
.Replace(@"\", @"\\")
.Replace("'", @"\'")
.Replace(LINE_FEED, $@"\{LINE_FEED}")
superbonaci marked this conversation as resolved.
Show resolved Hide resolved
.ToString();
}
Expand Down