Skip to content

Publish the spec behind the Micrsoft Querystring Parsing and Serialization rules #2734

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

Closed
aspnet-hello opened this issue Jan 2, 2018 · 5 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-http-abstractions question
Milestone

Comments

@aspnet-hello
Copy link

From @nathanaeljones on Friday, May 30, 2014 11:56:39 AM

Could we get some light shed on the whys/hows of querystring handling logic in vNext? Previous versions have been inconsistent at best, and this seems like a great chance to fix things.

An all-encompassing parsing strategy may be possible, but inadvisable, as the logic could not be clearly communicated to developers. I would suggest instead that parsing/serialization formats be named specifically for their appropriate use.

For example, requests with content-type application/x-www-form-urlencoded must follow the WHATWG parsing/serialization spec — which differs from php, ruby, node, python, classic asp, and each implementation in asp.net vNow, most of which have differing rules on one or more points:

  1. Handling of duplicate keys. (error, replace, concatenate, or build list)?
  2. Hash serialization. key[a]=1&key[b]=2 produces key = {a=1, b=2} in some implementations
  3. Array serialization. a=1&a=2, a=1,2, a[]=1&a[]=2, a[1]=1, a[2]=2` are all valid ways to represent an array value on different platforms.
  4. Handling of invalid characters (error, or pretend they were URL encoded)?
  5. Encoding of reserved characters (Most frameworks fail to url encode reserved characters correctly)
  6. Order preservation - some developers (inadvisably) rely on the order of querystring pairs. A recent instance of this is in the latest version of Umbraco.
  7. Case preservation and case sensitivity.
  8. URL decoding pass count (AFAIK, only ASP.NET WebForms messes this up). Ideally, +, %20 -> should be the only lossy operation.

Once we know the team's opinions on querystrings (and paths - and PathInfos), I think there are a lot of developers that would be happy to pitch in with unit tests and compatibility profiles. I imagine that Javascript/Node and php compatibility would be the highest priority.

Of course, this is easiest if we can ensure that we do not lose any data between the network packet and the developer. I'm looking at you, IIS.

Copied from original issue: aspnet/HttpAbstractions#67

@aspnet-hello
Copy link
Author

From @nathanaeljones on Monday, June 16, 2014 6:49:49 AM

Also, a compatibility matrix between Uri.(Un)EscapeDataString and the HttpUtility methods would be useful if we're switching. Incorrect space handling is well-known, but unicode encoding is a different story. HttpUtility guesses encoding (often wrongly) from the request, and both appear to take very different approaches to actual byte mangling.

@aspnet-hello
Copy link
Author

From @glennc on Monday, June 23, 2014 3:39:33 PM

@GrabYourPitchforks Can you talk about this here for now?

@aspnet-hello
Copy link
Author

From @GrabYourPitchforks on Tuesday, June 24, 2014 8:57:18 AM

Not quite sure what you mean about IIS and HttpUtility.UrlEncode/UrlDecode munging the encoding. IIS doesn't touch the query string at all (it just gets forwarded through as raw bytes), and UrlEncode/UrlDecode always assumes UTF8 unless the developer has specified something else in Web.config.

The biggest difference between UnescapeDataString and HttpUtility.UrlDecode is two-fold: (a) UrlDecode can only be used for the query string, not for path segments, due to the way it handles the U+0020 code point; and (b) UrlDecode understands the non-standard %uXXXX format.

We've been working on new encoding / decoding routines which should provide a more uniform and easy-to-understand behavior. These routines will also support previous customer suggestions like leaving IRI-safe characters unescaped. I don't have an ETA for when these will be available.

@aspnet-hello
Copy link
Author

From @davidfowl on Thursday, January 8, 2015 8:51:54 AM

@GrabYourPitchforks These are available now right?

@ghost
Copy link

ghost commented Dec 7, 2019

Thank you for contacting us. Due to no activity on this issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.

@ghost ghost closed this as completed Dec 7, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2019
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-http-abstractions question
Projects
None yet
Development

No branches or pull requests

3 participants