Skip to content

Commit 7ac7fd7

Browse files
committed
Merge remote-tracking branch 'origin/main' into safia/interceptors-rdg
2 parents 20133a7 + bd9f5d1 commit 7ac7fd7

File tree

8 files changed

+33
-64
lines changed

8 files changed

+33
-64
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ dotnet_diagnostic.CA1018.severity = warning
8787
dotnet_diagnostic.CA1047.severity = warning
8888

8989
# CA1305: Specify IFormatProvider
90-
dotnet_diagnostic.CA1305.severity = warning
90+
# TODO: Renable as warning after https://github.com/dotnet/roslyn-analyzers/issues/6746 is resolved
91+
dotnet_diagnostic.CA1305.severity = suggestion
9192

9293
# CA1507: Use nameof to express symbol names
9394
dotnet_diagnostic.CA1507.severity = warning

eng/Version.Details.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@
353353
<Uri>https://github.com/dotnet/roslyn</Uri>
354354
<Sha>1aa759af23d2a29043ea44fcef5bd6823dafa5d0</Sha>
355355
</Dependency>
356+
<Dependency Name="System.Composition" Version="7.0.0">
357+
<Uri>https://github.com/dotnet/runtime</Uri>
358+
<Sha>d099f075e45d2aa6007a22b71b45a08758559f80</Sha>
359+
</Dependency>
356360
</ProductDependencies>
357361
<ToolsetDependencies>
358362
<!-- Listed explicitly to workaround https://github.com/dotnet/cli/issues/10528 -->

eng/Versions.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@
166166
<MicrosoftSourceBuildIntermediatesourcebuildreferencepackagesVersion>8.0.0-alpha.1.23326.1</MicrosoftSourceBuildIntermediatesourcebuildreferencepackagesVersion>
167167
<!-- Packages from dotnet/symreader -->
168168
<MicrosoftSourceBuildIntermediatesymreaderVersion>2.0.0-beta-23228-03</MicrosoftSourceBuildIntermediatesymreaderVersion>
169+
<!-- Packages from dotnet/runtime -->
170+
<SystemCompositionVersion>7.0.0</SystemCompositionVersion>
169171
<!-- Packages from dotnet/xdt -->
170172
<MicrosoftWebXdtVersion>7.0.0-preview.22423.2</MicrosoftWebXdtVersion>
171173
</PropertyGroup>

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "8.0.100-preview.7.23321.23"
3+
"version": "8.0.100-preview.7.23356.6"
44
},
55
"tools": {
6-
"dotnet": "8.0.100-preview.7.23321.23",
6+
"dotnet": "8.0.100-preview.7.23356.6",
77
"runtimes": {
88
"dotnet/x86": [
99
"$(MicrosoftNETCoreBrowserDebugHostTransportVersion)"

src/Http/Http.Abstractions/src/HostString.cs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Buffers;
45
using System.Diagnostics;
56
using System.Globalization;
67
using Microsoft.AspNetCore.Http.Abstractions;
@@ -15,6 +16,15 @@ namespace Microsoft.AspNetCore.Http;
1516
[DebuggerDisplay("{Value}")]
1617
public readonly struct HostString : IEquatable<HostString>
1718
{
19+
// Allowed Characters:
20+
// A-Z, a-z, 0-9, .,
21+
// -, %, [, ], :
22+
// Above for IPV6
23+
private static readonly SearchValues<char> s_safeHostStringChars =
24+
SearchValues.Create("%-.0123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz");
25+
26+
private static readonly IdnMapping s_idnMapping = new();
27+
1828
private readonly string _value;
1929

2030
/// <summary>
@@ -121,33 +131,23 @@ public override string ToString()
121131
/// <returns>The <see cref="HostString"/> value formated for use in a URI or HTTP header.</returns>
122132
public string ToUriComponent()
123133
{
124-
if (string.IsNullOrEmpty(_value))
134+
if (!HasValue)
125135
{
126136
return string.Empty;
127137
}
128138

129-
int i;
130-
for (i = 0; i < _value.Length; ++i)
139+
if (!_value.AsSpan().ContainsAnyExcept(s_safeHostStringChars))
131140
{
132-
if (!HostStringHelper.IsSafeHostStringChar(_value[i]))
133-
{
134-
break;
135-
}
141+
return _value;
136142
}
137143

138-
if (i != _value.Length)
139-
{
140-
GetParts(_value, out var host, out var port);
141-
142-
var mapping = new IdnMapping();
143-
var encoded = mapping.GetAscii(host.Buffer!, host.Offset, host.Length);
144+
GetParts(_value, out var host, out var port);
144145

145-
return StringSegment.IsNullOrEmpty(port)
146-
? encoded
147-
: string.Concat(encoded, ":", port.ToString());
148-
}
146+
var encoded = s_idnMapping.GetAscii(host.Buffer!, host.Offset, host.Length);
149147

150-
return _value;
148+
return StringSegment.IsNullOrEmpty(port)
149+
? encoded
150+
: string.Concat(encoded, ":", port.AsSpan());
151151
}
152152

153153
/// <summary>
@@ -177,14 +177,12 @@ public static HostString FromUriComponent(string uriComponent)
177177
if (index >= 0)
178178
{
179179
// Has a port
180-
string port = uriComponent.Substring(index);
181-
var mapping = new IdnMapping();
182-
uriComponent = mapping.GetUnicode(uriComponent, 0, index) + port;
180+
var port = uriComponent.AsSpan(index);
181+
uriComponent = string.Concat(s_idnMapping.GetUnicode(uriComponent, 0, index), port);
183182
}
184183
else
185184
{
186-
var mapping = new IdnMapping();
187-
uriComponent = mapping.GetUnicode(uriComponent);
185+
uriComponent = s_idnMapping.GetUnicode(uriComponent);
188186
}
189187
}
190188
}

src/Http/Http.Abstractions/src/Internal/HostStringHelper.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Http/samples/MinimalSample/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
54
using System.Reflection;
65
using Microsoft.AspNetCore.Http.HttpResults;
76
using Microsoft.AspNetCore.Http.Metadata;
@@ -10,7 +9,7 @@
109
var builder = WebApplication.CreateBuilder(args);
1110
var app = builder.Build();
1211

13-
app.Logger.LogInformation($"Current process ID: {Process.GetCurrentProcess().Id}");
12+
app.Logger.LogInformation($"Current process ID: {Environment.ProcessId}");
1413

1514
string Plaintext() => "Hello, World!";
1615
app.MapGet("/plaintext", Plaintext);

src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ internal static void AddMvcCoreServices(IServiceCollection services)
183183
//
184184
// Action Invoker
185185
//
186-
// The IActionInvokerFactory is cachable
186+
// The IActionInvokerFactory is cacheable
187187
services.TryAddSingleton<IActionInvokerFactory, ActionInvokerFactory>();
188188
services.TryAddEnumerable(
189189
ServiceDescriptor.Transient<IActionInvokerProvider, ControllerActionInvokerProvider>());

0 commit comments

Comments
 (0)