Terminate at null char for audio tags (#14100)

This commit is contained in:
gnattu
2025-05-19 08:40:18 +08:00
committed by GitHub
parent fe2596dc0e
commit 9d601f8e9b
2 changed files with 71 additions and 24 deletions
@@ -135,5 +135,18 @@ namespace Jellyfin.Extensions
{
return values.Select(i => (i ?? string.Empty).Trim());
}
/// <summary>
/// Truncates a string at the first null character ('\0').
/// </summary>
/// <param name="text">The input string.</param>
/// <returns>
/// The substring up to (but not including) the first null character,
/// or the original string if no null character is present.
/// </returns>
public static string TruncateAtNull(this string text)
{
return string.IsNullOrEmpty(text) ? text : text.AsSpan().LeftPart('\0').ToString();
}
}
}