Skip to content

Specify for which URL component to encode in DefaultUrlEncoder #29845

@antoinebj

Description

@antoinebj

Currently, the System.Text.Encodings.Web.DefaultUrlEncoder class forces a set of forbidden characters that is the union of all forbidden characters in all components of the URL.
That is regardless of what was specified as allowed in the TextEncoderSettings that can be injected through the constructor.

In my use case, I'd like to encode for the query string only. For example, I would benefit from the : not being encoded, which is allowed in query strings. However, that character is being encoded, because a URL component other than the query string disallows it.

Would it be possible to enhance the DefaultUrlEncoder in one or more of the following ways?

  1. To take a hint of which URL component is being passed for encoding, and leave acceptable characters for that component untouched (e.g. the colon character for query strings)

OR

  1. To honor the TextEncoderSettings to truly override what is allowed or forbidden

OR/AND

  1. To make it public and non-sealed in order to be able to override its behavior (in particular the WillEncode and FindFirstCharacterToEncode methods)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions