-
Couldn't load subscription status.
- Fork 10.5k
Closed
Labels
area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.good first issueGood for newcomers.Good for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue
Milestone
Description
An incoming request with a query string that contains an escaped key without a value is not properly unescaped.
Example:
GET http://localhost/api/demo?fields%5BtodoItems%5D HTTP/1.1string keys = string.Join(' ', new HttpContextAccessor().HttpContext.Request.Query.Keys);
// keys: %5BtodoItems%5DIn contrast, when the query string does contain a value, it gets unescaped properly.
GET http://localhost/api/demo?fields%5BtodoItems%5D=1 HTTP/1.1string keys = string.Join(' ', new HttpContextAccessor().HttpContext.Request.Query.Keys);
// keys: [todoItems]This bug applies to ASP.NET Core version: 3.1, 5.0 and the master branch.
The problem is caused by the next line:
| accumulator.Append(queryString.Substring(scanIndex, delimiterIndex - scanIndex), string.Empty); |
which does not unescape. To fix, replace this line with:
string name = queryString.Substring(scanIndex, delimiterIndex - scanIndex);
accumulator.Append(Uri.UnescapeDataString(name.Replace('+', ' ')), string.Empty);When this gets fixed, it would be great to also backport it to .NET Core 3.1 and 5.0.
Metadata
Metadata
Assignees
Labels
area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.good first issueGood for newcomers.Good for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue