mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
Merge pull request #1294 from DrPandemic/fix-download-non-ascii
Fix non-ascii filename downloads
This commit is contained in:
commit
cd83d80f2b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user