Fixed: Specify UTF-8 when serving text files to avoid incorrect detection by browsers

This commit is contained in:
Martin Häger 2023-03-25 20:26:00 +01:00 committed by Robin Dadswell
parent 16f30e7f19
commit a39bfa8e14
1 changed files with 6 additions and 1 deletions

View File

@ -1,7 +1,9 @@
using System; using System;
using System.IO; using System.IO;
using System.Text;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Net.Http.Headers;
using NLog; using NLog;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
@ -39,7 +41,10 @@ namespace Lidarr.Http.Frontend.Mappers
contentType = "application/octet-stream"; 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); _logger.Warn("File {0} not found", filePath);