Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit d87f0d5

Browse files
author
Cesar Blum Silveira
committed
Add tests to document that double escaping is allowed.
1 parent 71a342d commit d87f0d5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

test/Microsoft.AspNet.Server.WebListener.FunctionalTests/RequestTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ public async Task Request_MalformedPathReturns400StatusCode(string requestPath)
140140
}
141141
}
142142

143+
[Fact]
144+
public async Task Request_DoubleEscapingAllowed()
145+
{
146+
string root;
147+
using (var server = Utilities.CreateHttpServerReturnRoot("/", out root, httpContext =>
148+
{
149+
var requestInfo = httpContext.Features.Get<IHttpRequestFeature>();
150+
Assert.Equal("/%2F", requestInfo.Path);
151+
return Task.FromResult(0);
152+
}))
153+
{
154+
var response = await SendSocketRequestAsync(root, "/%252F");
155+
var responseStatusCode = response.Substring(9); // Skip "HTTP/1.1 "
156+
Assert.Equal("200", responseStatusCode);
157+
}
158+
}
159+
143160
[Theory]
144161
// The test server defines these prefixes: "/", "/11", "/2/3", "/2", "/11/2"
145162
[InlineData("/", "", "/")]

test/Microsoft.Net.Http.Server.FunctionalTests/RequestTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ public async Task Request_MalformedPathReturns400StatusCode(string requestPath)
100100
}
101101
}
102102

103+
[Fact]
104+
public async Task Request_DoubleEscapingAllowed()
105+
{
106+
string root;
107+
using (var server = Utilities.CreateHttpServerReturnRoot("/", out root))
108+
{
109+
var responseTask = SendSocketRequestAsync(root, "/%252F");
110+
var context = await server.GetContextAsync();
111+
Assert.Equal("/%2F", context.Request.Path);
112+
}
113+
}
114+
103115
[Theory]
104116
// The test server defines these prefixes: "/", "/11", "/2/3", "/2", "/11/2"
105117
[InlineData("/", "", "/")]

0 commit comments

Comments
 (0)