elixir-plug / plug

Compose web applications with functions
https://hex.pm/packages/plug
Other
2.88k stars 587 forks source link

Make whitespace (more) optional in list strings #1155

Closed ryanwinchester closed 1 year ago

ryanwinchester commented 1 year ago

CurrentlyPlug.Conn.Utils.list/1 would not handle all the whitespace around the commas if the space is before the comma.

According to what I understand from RFC9110§5.6.1, lists should look like:

element *( OWS "," OWS element )

With OWS (Optional White Space) on either side of the comma.

Right now I have it as handling only a single whitespace on either side, but we might have to clean up the string and then split, or clean it up after?

Examples

It should look like this:

iex> Plug.Conn.Utils.list("whitespace , is,optional")
["whitespace", "is", "optional"]

But it looks like this:

iex> Plug.Conn.Utils.list("whitespace , is,optional")
["whitespace ", "is", "optional"]

Discuss

josevalim commented 1 year ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart: