ninenines / cowlib

Support library for manipulating Web protocols.
ISC License
281 stars 172 forks source link

cow_qs:qs/1 percent-encode the reserved characters like comma #127

Closed blaxmirror closed 2 years ago

blaxmirror commented 2 years ago

According to the examples in OpenAPI The query in URI could be something like /users?id=3,4,5. And according to RFC3986:

The purpose of reserved characters is to provide a set of delimiting characters that are distinguishable from other data within a URI. URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent. Percent- encoding a reserved character, or decoding a percent-encoded octet that corresponds to a reserved character, will change how the URI is interpreted by most applications. Thus, characters in the reserved set are protected from normalization and are therefore safe to be used by scheme-specific and producer-specific algorithms for delimiting data subcomponents within a URI.

I suppose enforcing the percent-encode for reserved characters is not that reasonable. Could you help take a look?

essen commented 2 years ago

cow_qs is the x-www-form-urlencoded format. You probably want the cow_uri module which follows RFC3986.

https://github.com/ninenines/cowlib/blob/master/src/cow_uri.erl#L37