diff --git a/CHANGELOG.md b/CHANGELOG.md index f2acdf77f..e782974f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Fix bug where tail or fallback filler would sometimes schedule much longer than expected - This only happened with fixed start schedule items following a schedule item with tail or fallback filler +- Fix NFO reader bug that caused inaccurate warning messages about invalid XML and incomplete metadata ### Added - Add music video credits template system diff --git a/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj b/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj index 94ac78608..7a3f32794 100644 --- a/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj +++ b/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj @@ -12,7 +12,7 @@ - + diff --git a/ErsatzTV.Core/Metadata/Nfo/NfoReader.cs b/ErsatzTV.Core/Metadata/Nfo/NfoReader.cs index df228a2e4..12184bde4 100644 --- a/ErsatzTV.Core/Metadata/Nfo/NfoReader.cs +++ b/ErsatzTV.Core/Metadata/Nfo/NfoReader.cs @@ -35,22 +35,16 @@ public abstract class NfoReader protected async Task SanitizedStreamForFile(string fileName) { - using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, Buffer.Length, true)) - { - while (await fs.ReadAsync(Buffer) > 0) - { - // read the file - } - - string text = Encoding.UTF8.GetString(Buffer); - // trim BOM and zero width space, replace controls with replacement character - string stripped = Pattern.Replace(text.Trim('\uFEFF', '\u200B'), "\ufffd"); - - MemoryStream ms = _recyclableMemoryStreamManager.GetStream(); - await ms.WriteAsync(Encoding.UTF8.GetBytes(stripped)); - ms.Position = 0; - return ms; - } + await using var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, Buffer.Length, true); + using var sr = new StreamReader(fs, Encoding.UTF8); + string text = await sr.ReadToEndAsync(); + // trim BOM and zero width space, replace controls with replacement character + string stripped = Pattern.Replace(text.Trim('\uFEFF', '\u200B'), "\ufffd"); + + MemoryStream ms = _recyclableMemoryStreamManager.GetStream(); + await ms.WriteAsync(Encoding.UTF8.GetBytes(stripped)); + ms.Position = 0; + return ms; } protected async Task ReadStringContent(XmlReader reader, T nfo, Action action) diff --git a/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj b/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj index 5c56624e4..0b1e6470d 100644 --- a/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj +++ b/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj @@ -14,12 +14,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ErsatzTV/ErsatzTV.csproj b/ErsatzTV/ErsatzTV.csproj index 492b0a995..87bbb89a4 100644 --- a/ErsatzTV/ErsatzTV.csproj +++ b/ErsatzTV/ErsatzTV.csproj @@ -55,14 +55,14 @@ - + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -70,7 +70,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/ErsatzTV/Resources/Templates/_default.ass.sbntxt b/ErsatzTV/Resources/Templates/_default.ass.sbntxt index 26139787c..da3fd39b6 100644 --- a/ErsatzTV/Resources/Templates/_default.ass.sbntxt +++ b/ErsatzTV/Resources/Templates/_default.ass.sbntxt @@ -12,4 +12,4 @@ Style: Default,OPTIKabel-Heavy,{{ resolution.height // 20.0 }},&HFFFFFF,&HFFFFFF [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text -Dialogue: 0,00:00:09.00,00:00:16.00,Default,,{{ resolution.width * 0.03 | math.round }},{{ resolution.width * 0.03 | math.round }},{{ resolution.height * 0.05 | math.round }},,{fad(1200, 1200)}{{ if all_artists | array.size == 0 }}{{ artist }}{{ else }}{{ all_artists | array.join " / " }}{{ end }}\N"{{ title }}"{{ if album }}\N{{ album }}{{ end }} +Dialogue: 0,00:00:09.00,00:00:16.00,Default,,{{ resolution.width * 0.03 | math.round }},{{ resolution.width * 0.03 | math.round }},{{ resolution.height * 0.05 | math.round }},,{\fad(1200, 1200)}{{ if all_artists | array.size == 0 }}{{ artist }}{{ else }}{{ all_artists | array.join " / " }}{{ end }}\N"{{ title }}"{{ if album }}\N{{ album }}{{ end }} diff --git a/ErsatzTV/Shared/MarkdownView.razor.cs b/ErsatzTV/Shared/MarkdownView.razor.cs index 295e6b712..a5558f649 100644 --- a/ErsatzTV/Shared/MarkdownView.razor.cs +++ b/ErsatzTV/Shared/MarkdownView.razor.cs @@ -1,4 +1,4 @@ -using Ganss.XSS; +using Ganss.Xss; using Markdig; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; diff --git a/ErsatzTV/Startup.cs b/ErsatzTV/Startup.cs index 25959b96f..d15a6e3c1 100644 --- a/ErsatzTV/Startup.cs +++ b/ErsatzTV/Startup.cs @@ -56,7 +56,7 @@ using ErsatzTV.Services; using ErsatzTV.Services.RunOnce; using FluentValidation; using FluentValidation.AspNetCore; -using Ganss.XSS; +using Ganss.Xss; using MediatR; using MediatR.Courier.DependencyInjection; using Microsoft.AspNetCore.StaticFiles;