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

Make whitespace (more) optional in list strings #1155

Merged

Conversation

ryanwinchester
Copy link
Contributor

@ryanwinchester ryanwinchester commented Jun 12, 2023

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

  • Do we want this behaviour?
  • Do we handle more than one space on each side of the comma?
  • What is the most performant way to handle it either way?

@ryanwinchester ryanwinchester changed the title Make whitespace (more) optional in list strings [WIP] Make whitespace (more) optional in list strings Jun 12, 2023
lib/plug/conn/utils.ex Outdated Show resolved Hide resolved
@ryanwinchester ryanwinchester changed the title [WIP] Make whitespace (more) optional in list strings Make whitespace (more) optional in list strings Jun 12, 2023
@josevalim josevalim merged commit c30c454 into elixir-plug:main Jun 12, 2023
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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

Successfully merging this pull request may close these issues.

2 participants