Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't parse Query String if there is no Query String #1081

Closed
Badgerati opened this issue Feb 28, 2023 · 0 comments · Fixed by #1113
Closed

Don't parse Query String if there is no Query String #1081

Badgerati opened this issue Feb 28, 2023 · 0 comments · Fixed by #1113
Assignees
Labels
Milestone

Comments

@Badgerati
Copy link
Owner

var reqQuery = reqMeta[1].Trim();
if (!string.IsNullOrWhiteSpace(reqQuery))
{
var qmIndex = reqQuery.IndexOf("?");
QueryString = HttpUtility.ParseQueryString(qmIndex > 0 ? reqQuery.Substring(qmIndex) : reqQuery);
}
else
{
QueryString = default(NameValueCollection);
}

In the above lines, even if the URL doesn't contain a query string we're still running ParseQueryString on the URL. This means we will have a redundant empty NameValue pair in the returned collection, which is just the URL again.

Originally this didn't matter, but after #1066 which now allows empty keys in Query Strings to be possible, these redundant keys are now being allowed as well 😂 It's not much of an issue, but Pode.Web relies on the keys in the query string collection, and is now behaving ... funkily.

Plan: If the URL doesn't have ? just set the default NameValueCollection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant