Skip to content

Commit 214df1c

Browse files
authored
Merge pull request #22902 from dotnet-maestro-bot/merge/release/3.1-to-master
[automated] Merge branch 'release/3.1' => 'master'
2 parents a44c1ad + cbb8c6d commit 214df1c

File tree

20 files changed

+253
-108
lines changed

20 files changed

+253
-108
lines changed

src/Components/test/E2ETest/Tests/FormsTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
1111
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
1212
using Microsoft.AspNetCore.E2ETesting;
13+
using Microsoft.AspNetCore.Testing;
1314
using OpenQA.Selenium;
1415
using OpenQA.Selenium.Support.UI;
1516
using Xunit;
@@ -190,6 +191,7 @@ public void InputTextAreaInteractsWithEditContext()
190191
}
191192

192193
[Fact]
194+
[QuarantinedTest("https://github.com/dotnet/aspnetcore-internal/issues/3615")]
193195
public void InputDateInteractsWithEditContext_NonNullableDateTime()
194196
{
195197
var appElement = MountTypicalValidationComponent();

src/Servers/HttpSys/src/Microsoft.AspNetCore.Server.HttpSys.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
<ItemGroup>
1515
<Compile Include="$(SharedSourceRoot)HttpSys\**\*.cs" />
1616
<Compile Include="$(SharedSourceRoot)Buffers.MemoryPool\*.cs" LinkBase="MemoryPool" />
17-
</ItemGroup>
18-
19-
<ItemGroup>
17+
<Compile Include="$(SharedSourceRoot)ServerInfrastructure\StringUtilities.cs" LinkBase="ServerInfrastructure\StringUtilities.cs" />
18+
<Compile Include="$(SharedSourceRoot)TaskToApm.cs" />
2019
</ItemGroup>
2120

2221
<ItemGroup>

src/Servers/HttpSys/test/FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Compile Include="$(SharedSourceRoot)runtime\SR.cs" LinkBase="Shared\SR.cs" />
1313
<Compile Include="$(SharedSourceRoot)Http2cat\**\*.cs" LinkBase="Shared\Http2cat" />
1414
<Compile Include="$(SharedSourceRoot)ServerInfrastructure\**\*.cs" LinkBase="Shared\" />
15-
<Compile Include="$(SharedSourceRoot)TaskToApm.cs" Link="Shared\TaskToApm.cs" />
15+
<Compile Remove="$(SharedSourceRoot)ServerInfrastructure\StringUtilities.cs" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

src/Servers/IIS/IIS/src/Core/IISHttpContext.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ internal unsafe IISHttpContext(
7676
IntPtr pInProcessHandler,
7777
IISServerOptions options,
7878
IISHttpServer server,
79-
ILogger logger)
80-
: base((HttpApiTypes.HTTP_REQUEST*)NativeMethods.HttpGetRawRequest(pInProcessHandler))
79+
ILogger logger,
80+
bool useLatin1)
81+
: base((HttpApiTypes.HTTP_REQUEST*)NativeMethods.HttpGetRawRequest(pInProcessHandler), useLatin1: useLatin1)
8182
{
8283
_memoryPool = memoryPool;
8384
_pInProcessHandler = pInProcessHandler;

src/Servers/IIS/IIS/src/Core/IISHttpContextOfT.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Buffers;
6+
using System.Text;
67
using System.Threading;
78
using System.Threading.Tasks;
89
using Microsoft.AspNetCore.Builder;
@@ -17,8 +18,8 @@ internal class IISHttpContextOfT<TContext> : IISHttpContext
1718
{
1819
private readonly IHttpApplication<TContext> _application;
1920

20-
public IISHttpContextOfT(MemoryPool<byte> memoryPool, IHttpApplication<TContext> application, IntPtr pInProcessHandler, IISServerOptions options, IISHttpServer server, ILogger logger)
21-
: base(memoryPool, pInProcessHandler, options, server, logger)
21+
public IISHttpContextOfT(MemoryPool<byte> memoryPool, IHttpApplication<TContext> application, IntPtr pInProcessHandler, IISServerOptions options, IISHttpServer server, ILogger logger, bool useLatin1)
22+
: base(memoryPool, pInProcessHandler, options, server, logger, useLatin1)
2223
{
2324
_application = application;
2425
}

src/Servers/IIS/IIS/src/Core/IISHttpServer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,14 @@ private static void OnRequestsDrained(IntPtr serverContext)
214214

215215
private class IISContextFactory<T> : IISContextFactory
216216
{
217+
private const string Latin1Suppport = "Microsoft.AspNetCore.Server.IIS.Latin1RequestHeaders";
218+
217219
private readonly IHttpApplication<T> _application;
218220
private readonly MemoryPool<byte> _memoryPool;
219221
private readonly IISServerOptions _options;
220222
private readonly IISHttpServer _server;
221223
private readonly ILogger _logger;
224+
private readonly bool _useLatin1;
222225

223226
public IISContextFactory(MemoryPool<byte> memoryPool, IHttpApplication<T> application, IISServerOptions options, IISHttpServer server, ILogger logger)
224227
{
@@ -227,11 +230,12 @@ public IISContextFactory(MemoryPool<byte> memoryPool, IHttpApplication<T> applic
227230
_options = options;
228231
_server = server;
229232
_logger = logger;
233+
AppContext.TryGetSwitch(Latin1Suppport, out _useLatin1);
230234
}
231235

232236
public IISHttpContext CreateHttpContext(IntPtr pInProcessHandler)
233237
{
234-
return new IISHttpContextOfT<T>(_memoryPool, _application, pInProcessHandler, _options, _server, _logger);
238+
return new IISHttpContextOfT<T>(_memoryPool, _application, pInProcessHandler, _options, _server, _logger, _useLatin1);
235239
}
236240
}
237241
}

src/Servers/IIS/IIS/src/Microsoft.AspNetCore.Server.IIS.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
<Compile Include="$(SharedSourceRoot)StackTrace\**\*.cs" LinkBase="Shared\" />
2121
<Compile Include="$(SharedSourceRoot)RazorViews\*.cs" LinkBase="Shared\" />
2222
<Compile Include="$(SharedSourceRoot)ErrorPage\*.cs" LinkBase="Shared\" />
23-
<Compile Include="$(RepoRoot)src\Shared\TaskToApm.cs" Link="Shared\TaskToApm.cs" />
23+
<Compile Include="$(SharedSourceRoot)TaskToApm.cs" Link="Shared\TaskToApm.cs" />
24+
<Compile Include="$(SharedSourceRoot)ServerInfrastructure\*.cs" LinkBase="Shared\" />
2425
</ItemGroup>
2526

2627
<Target Name="ValidateNativeComponentsBuilt" AfterTargets="Build" >
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Net;
6+
using System.Net.Http;
7+
using System.Threading.Tasks;
8+
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
9+
using Microsoft.AspNetCore.Server.IntegrationTesting;
10+
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
11+
using Microsoft.AspNetCore.Testing;
12+
using Xunit;
13+
14+
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests.InProcess
15+
{
16+
[Collection(PublishedSitesCollection.Name)]
17+
public class Latin1Tests : IISFunctionalTestBase
18+
{
19+
public Latin1Tests(PublishedSitesFixture fixture) : base(fixture)
20+
{
21+
}
22+
23+
[ConditionalFact]
24+
[RequiresNewHandler]
25+
public async Task Latin1Works()
26+
{
27+
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
28+
deploymentParameters.TransformArguments((a, _) => $"{a} AddLatin1");
29+
30+
var deploymentResult = await DeployAsync(deploymentParameters);
31+
32+
var client = new HttpClient(new LoggingHandler(new WinHttpHandler() { SendTimeout = TimeSpan.FromMinutes(3) }, deploymentResult.Logger));
33+
34+
var requestMessage = new HttpRequestMessage(HttpMethod.Get, $"{deploymentResult.ApplicationBaseUri}Latin1");
35+
requestMessage.Headers.Add("foo", "£");
36+
37+
var result = await client.SendAsync(requestMessage);
38+
Assert.Equal(HttpStatusCode.OK, result.StatusCode);
39+
}
40+
41+
[ConditionalFact]
42+
[RequiresNewHandler]
43+
public async Task Latin1ReplacedWithoutAppContextSwitch()
44+
{
45+
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
46+
deploymentParameters.TransformArguments((a, _) => $"{a}");
47+
48+
var deploymentResult = await DeployAsync(deploymentParameters);
49+
50+
var client = new HttpClient(new LoggingHandler(new WinHttpHandler() { SendTimeout = TimeSpan.FromMinutes(3) }, deploymentResult.Logger));
51+
52+
var requestMessage = new HttpRequestMessage(HttpMethod.Get, $"{deploymentResult.ApplicationBaseUri}InvalidCharacter");
53+
requestMessage.Headers.Add("foo", "£");
54+
55+
var result = await client.SendAsync(requestMessage);
56+
Assert.Equal(HttpStatusCode.OK, result.StatusCode);
57+
}
58+
59+
[ConditionalFact]
60+
[RequiresNewHandler]
61+
public async Task Latin1InvalidCharacters_HttpSysRejects()
62+
{
63+
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
64+
deploymentParameters.TransformArguments((a, _) => $"{a} AddLatin1");
65+
66+
var deploymentResult = await DeployAsync(deploymentParameters);
67+
68+
using (var connection = new TestConnection(deploymentResult.HttpClient.BaseAddress.Port))
69+
{
70+
await connection.Send(
71+
"GET /ReadAndFlushEcho HTTP/1.1",
72+
"Host: localhost",
73+
"Connection: close",
74+
"foo: £\0a",
75+
"",
76+
"");
77+
78+
await connection.ReceiveStartsWith("HTTP/1.1 400 Bad Request");
79+
}
80+
}
81+
}
82+
}

src/Servers/IIS/IIS/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
@@ -25,6 +25,7 @@
2525
<Reference Include="Microsoft.AspNetCore.Hosting" />
2626
<Reference Include="Microsoft.Extensions.Logging" />
2727
<Reference Include="System.Diagnostics.EventLog" />
28+
<Reference Include="System.Net.Http.WinHttpHandler" />
2829
</ItemGroup>
2930

3031
</Project>

src/Servers/IIS/IIS/test/IIS.NewHandler.FunctionalTests/IIS.NewHandler.FunctionalTests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
@@ -33,6 +33,7 @@
3333
<Reference Include="Microsoft.Extensions.Logging" />
3434
<Reference Include="System.Diagnostics.EventLog" />
3535
<Reference Include="System.Net.WebSockets.WebSocketProtocol" />
36+
<Reference Include="System.Net.Http.WinHttpHandler" />
3637
</ItemGroup>
3738

3839
</Project>

0 commit comments

Comments
 (0)