From a39bfa8e14ff73898e1539e88019a7a88ebf7499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20H=C3=A4ger?= Date: Sat, 25 Mar 2023 20:26:00 +0100 Subject: [PATCH] Fixed: Specify UTF-8 when serving text files to avoid incorrect detection by browsers --- .../Frontend/Mappers/StaticResourceMapperBase.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Lidarr.Http/Frontend/Mappers/StaticResourceMapperBase.cs b/src/Lidarr.Http/Frontend/Mappers/StaticResourceMapperBase.cs index 664259ede..1de8f93f5 100644 --- a/src/Lidarr.Http/Frontend/Mappers/StaticResourceMapperBase.cs +++ b/src/Lidarr.Http/Frontend/Mappers/StaticResourceMapperBase.cs @@ -1,7 +1,9 @@ using System; using System.IO; +using System.Text; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.StaticFiles; +using Microsoft.Net.Http.Headers; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; @@ -39,7 +41,10 @@ namespace Lidarr.Http.Frontend.Mappers contentType = "application/octet-stream"; } - return new FileStreamResult(GetContentStream(filePath), contentType); + return new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType) + { + Encoding = contentType == "text/plain" ? Encoding.UTF8 : null + }); } _logger.Warn("File {0} not found", filePath);