Skip to content

Commit 2dd8ec8

Browse files
committed
Feedback
1 parent 88cbe28 commit 2dd8ec8

File tree

2 files changed

+1
-32
lines changed

2 files changed

+1
-32
lines changed

src/Middleware/HostFiltering/src/HostFilteringMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private bool CheckHost(HttpContext context, IList<StringSegment> allowedHosts)
160160
{
161161
var host = context.Request.Headers[HeaderNames.Host].ToString();
162162

163-
if (0u >= (uint)host.Length)
163+
if (host.Length == 0)
164164
{
165165
return IsEmptyHostAllowed(context);
166166
}

src/Middleware/HostFiltering/test/HostFilteringMiddlewareTests.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,37 +97,6 @@ public async Task AllowsEmptyHost(bool allowed, int status)
9797
Assert.Equal(status, (int)response.StatusCode);
9898
}
9999

100-
[Fact]
101-
public async Task WhitespaceHostRejected()
102-
{
103-
var builder = new WebHostBuilder()
104-
.ConfigureServices(services =>
105-
{
106-
services.AddHostFiltering(options =>
107-
{
108-
options.AllowEmptyHosts = true;
109-
options.AllowedHosts.Add("Localhost");
110-
});
111-
})
112-
.Configure(app =>
113-
{
114-
app.Use((ctx, next) =>
115-
{
116-
ctx.Request.Headers[HeaderNames.Host] = " ";
117-
return next();
118-
});
119-
app.UseHostFiltering();
120-
app.Run(c =>
121-
{
122-
return Task.CompletedTask;
123-
});
124-
app.Run(c => Task.CompletedTask);
125-
});
126-
var server = new TestServer(builder);
127-
var response = await server.CreateClient().GetAsync("/");
128-
Assert.Equal(400, (int)response.StatusCode);
129-
}
130-
131100
[Theory]
132101
[InlineData("localHost", "localhost")]
133102
[InlineData("localHost", "*")] // Any - Used by HttpSys

0 commit comments

Comments
 (0)