aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin <me@potatodiet.ca>2022-12-03 10:47:59 -0500
committerGitHub <noreply@github.com>2022-12-03 08:47:59 -0700
commitdf66816178ea1c90881ffb1fda920fa5d7e8b27f (patch)
treedf853caa2ed42987f8c08f55ca9aa80e9b8f44ca
parentfe3e7979b0e5301bd13565df5dba674386ea0541 (diff)
Allow non-ASCII in downloaded filenames (#8825)
Fixes https://github.com/jellyfin/jellyfin/issues/8657
-rw-r--r--Jellyfin.Api/Controllers/LibraryController.cs18
1 files changed, 3 insertions, 15 deletions
diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs
index 7a57bf1a2..7d5cfc7ae 100644
--- a/Jellyfin.Api/Controllers/LibraryController.cs
+++ b/Jellyfin.Api/Controllers/LibraryController.cs
@@ -637,22 +637,10 @@ namespace Jellyfin.Api.Controllers
await LogDownloadAsync(item, user).ConfigureAwait(false);
}
- var path = item.Path;
+ // Quotes are valid in linux. They'll possibly cause issues here.
+ var filename = Path.GetFileName(item.Path)?.Replace("\"", string.Empty, StringComparison.Ordinal);
- // Quotes are valid in linux. They'll possibly cause issues here
- var filename = (Path.GetFileName(path) ?? string.Empty).Replace("\"", string.Empty, StringComparison.Ordinal);
- if (!string.IsNullOrWhiteSpace(filename))
- {
- // Kestrel doesn't support non-ASCII characters in headers
- if (Regex.IsMatch(filename, @"[^\p{IsBasicLatin}]"))
- {
- // Manually encoding non-ASCII characters, following https://tools.ietf.org/html/rfc5987#section-3.2.2
- filename = WebUtility.UrlEncode(filename);
- }
- }
-
- // TODO determine non-ASCII validity.
- return PhysicalFile(path, MimeTypes.GetMimeType(path), filename, true);
+ return PhysicalFile(item.Path, MimeTypes.GetMimeType(item.Path), filename, true);
}
/// <summary>