aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Library/LibraryService.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-05-18 12:56:42 +0200
committerGitHub <noreply@github.com>2019-05-18 12:56:42 +0200
commit2d011b781e8a696bb6dc6cf355d19463f6b9cdb3 (patch)
tree8c7e5e3dba3a3e9a831b3951aa15b0768f068508 /MediaBrowser.Api/Library/LibraryService.cs
parent71f81c5fb0e4f9bcf1242552e0d6df7a88593d3e (diff)
parent1bf3a26a6194c6a5878f1e4c98ed953103ac7b71 (diff)
Merge pull request #1383 from jellyfin/release-10.3.z
Backmerge for Release 10.3.3
Diffstat (limited to 'MediaBrowser.Api/Library/LibraryService.cs')
-rw-r--r--MediaBrowser.Api/Library/LibraryService.cs13
1 files changed, 12 insertions, 1 deletions
diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs
index 8eefbdf2c..9f8da9c16 100644
--- a/MediaBrowser.Api/Library/LibraryService.cs
+++ b/MediaBrowser.Api/Library/LibraryService.cs
@@ -2,6 +2,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Net;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Api.Movies;
@@ -828,7 +830,16 @@ namespace MediaBrowser.Api.Library
var filename = (Path.GetFileName(path) ?? string.Empty).Replace("\"", string.Empty);
if (!string.IsNullOrWhiteSpace(filename))
{
- headers[HeaderNames.ContentDisposition] = "attachment; filename=\"" + filename + "\"";
+ // Kestrel doesn't support non-ASCII characters in headers
+ if (Regex.IsMatch(filename, "[^[:ascii:]]"))
+ {
+ // Manually encoding non-ASCII characters, following https://tools.ietf.org/html/rfc5987#section-3.2.2
+ headers[HeaderNames.ContentDisposition] = "attachment; filename*=UTF-8''" + WebUtility.UrlEncode(filename);
+ }
+ else
+ {
+ headers[HeaderNames.ContentDisposition] = "attachment; filename=\"" + filename + "\"";
+ }
}
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions