Merge pull request #2483 from xosdy/fix-download-filename

Fix download file with non-ASCII filename
This commit is contained in:
Bond-009 2020-03-03 14:28:48 +01:00 committed by GitHub
commit 20ac3c36e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -815,7 +815,7 @@ namespace MediaBrowser.Api.Library
if (!string.IsNullOrWhiteSpace(filename))
{
// Kestrel doesn't support non-ASCII characters in headers
if (Regex.IsMatch(filename, "[^[:ascii:]]"))
if (Regex.IsMatch(filename, @"[^\p{IsBasicLatin}]"))
{
// 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);