diff --git a/azure-pipelines/templates/stages/test.yml b/azure-pipelines/templates/stages/test.yml index f9791a67..704bdecc 100644 --- a/azure-pipelines/templates/stages/test.yml +++ b/azure-pipelines/templates/stages/test.yml @@ -49,7 +49,7 @@ stages: - job: TestMacOS pool: - vmImage: macos-latest + vmImage: macos-11 steps: - template: ../restore.yml diff --git a/src/fiskaltrust.Launcher.Common/fiskaltrust.Launcher.Common.csproj b/src/fiskaltrust.Launcher.Common/fiskaltrust.Launcher.Common.csproj index d25251fb..8c1d32d6 100644 --- a/src/fiskaltrust.Launcher.Common/fiskaltrust.Launcher.Common.csproj +++ b/src/fiskaltrust.Launcher.Common/fiskaltrust.Launcher.Common.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/fiskaltrust.Launcher/Commands/HostCommand.cs b/src/fiskaltrust.Launcher/Commands/HostCommand.cs index df24a6e3..90168609 100644 --- a/src/fiskaltrust.Launcher/Commands/HostCommand.cs +++ b/src/fiskaltrust.Launcher/Commands/HostCommand.cs @@ -90,6 +90,8 @@ public async Task InvokeAsync(InvocationContext context) .WriteTo.GrpcSink(packageConfiguration, processHostService) .CreateLogger(); + System.Text.Encoding.RegisterProvider(new LauncherEncodingProvider()); + var builder = Host.CreateDefaultBuilder() .UseSerilog() .ConfigureServices(services => diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs index d8ad6bfb..881e57e0 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs @@ -40,10 +40,10 @@ public ProcessHostMonarch(ILogger logger, LauncherConfigurat "--launcher-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(launcherConfiguration.Serialize()))}\"", }); - if (Debugger.IsAttached) - { - _process.StartInfo.Arguments += " --debugging"; - } + // if (Debugger.IsAttached) + // { + // _process.StartInfo.Arguments += " --debugging"; + // } _process.StartInfo.RedirectStandardInput = true; _process.StartInfo.RedirectStandardError = true; _process.StartInfo.RedirectStandardOutput = true; diff --git a/src/fiskaltrust.Launcher/Services/EncodingProvider.cs b/src/fiskaltrust.Launcher/Services/EncodingProvider.cs new file mode 100644 index 00000000..8f2d7e47 --- /dev/null +++ b/src/fiskaltrust.Launcher/Services/EncodingProvider.cs @@ -0,0 +1,28 @@ +using System.Text; + +namespace fiskaltrust.Launcher.Services +{ + public class LauncherEncodingProvider : EncodingProvider + { + public override Encoding? GetEncoding(int codepage) => null; + + // This EncodingProvider needs to be registered in the plebian processes + // because ASP.NET Core uses the Encoding.GetEncoding(string) method to parse the charset of the Content-Type header. + // According to the http standard (https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1) the charset may be wrapped in quotes. + // Until this is fixed in ASP.NET we'll need the workaround below. + public override Encoding? GetEncoding(string name) + { + try + { + if ((name.StartsWith('"') && name.EndsWith('"')) || (name.StartsWith('\'') && name.EndsWith('\''))) + { + // This does not lead to an endless recursion, because every time the Encoding.GetEncoding(string) method calls this method either more quotes are trimmed and its recursed or null is returned. + return Encoding.GetEncoding(name.Substring(1, name.Length - 2)); + } + } + catch { } + + return null; + } + } +} \ No newline at end of file diff --git a/src/fiskaltrust.Launcher/fiskaltrust.Launcher.csproj b/src/fiskaltrust.Launcher/fiskaltrust.Launcher.csproj index f0c8e7cc..3b00a172 100644 --- a/src/fiskaltrust.Launcher/fiskaltrust.Launcher.csproj +++ b/src/fiskaltrust.Launcher/fiskaltrust.Launcher.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/test/fiskaltrust.Launcher.IntegrationTest/fiskaltrust.Launcher.IntegrationTest.csproj b/test/fiskaltrust.Launcher.IntegrationTest/fiskaltrust.Launcher.IntegrationTest.csproj index 2f7a90c8..0ddf8ba4 100644 --- a/test/fiskaltrust.Launcher.IntegrationTest/fiskaltrust.Launcher.IntegrationTest.csproj +++ b/test/fiskaltrust.Launcher.IntegrationTest/fiskaltrust.Launcher.IntegrationTest.csproj @@ -9,11 +9,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/fiskaltrust.Launcher.UnitTest/Helpers/EncodingProvider.cs b/test/fiskaltrust.Launcher.UnitTest/Helpers/EncodingProvider.cs new file mode 100644 index 00000000..e0d9b3e0 --- /dev/null +++ b/test/fiskaltrust.Launcher.UnitTest/Helpers/EncodingProvider.cs @@ -0,0 +1,25 @@ +using System.Text; +using fiskaltrust.Launcher.Common; +using fiskaltrust.Launcher.Services; +using FluentAssertions; +using Xunit; + +namespace fiskaltrust.Launcher.UnitTest.Helpers +{ + public class LauncherEncodingProviderTest + { + [Fact] + public void GetEncoding_ReturnsUtf8Encoding() + { + var provider = new LauncherEncodingProvider(); + + Encoding.RegisterProvider(provider); + + provider.GetEncoding("\"UTF-8\"").Should().Be(Encoding.UTF8); + provider.GetEncoding("UTF-8").Should().Be(null); + + Encoding.GetEncoding("\"UTF-8\"").Should().Be(Encoding.UTF8); + Encoding.GetEncoding("UTF-8").Should().Be(Encoding.UTF8); + } + } +} \ No newline at end of file diff --git a/test/fiskaltrust.Launcher.UnitTest/fiskaltrust.Launcher.UnitTest.csproj b/test/fiskaltrust.Launcher.UnitTest/fiskaltrust.Launcher.UnitTest.csproj index 2e2af6b0..550e8823 100644 --- a/test/fiskaltrust.Launcher.UnitTest/fiskaltrust.Launcher.UnitTest.csproj +++ b/test/fiskaltrust.Launcher.UnitTest/fiskaltrust.Launcher.UnitTest.csproj @@ -9,12 +9,12 @@ - + - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/version.json b/version.json index c26f6ba5..773fde25 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "2.0.0-rc.8", + "version": "2.0.0-rc.9", "releaseBranches": [ "^refs/tags/v\\d+(?:\\.\\d+)*(?:-.*)?$" ]