-
Notifications
You must be signed in to change notification settings - Fork 585
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
Add option to decide what to do on invalid UTF-8 urlencoded params #1200
Conversation
…g that isn't utf8 encoded.
…tion information in the message
…und in String.valid? bc essentially all characters in a query string will be ASCII.
error: @utf8_error_code, | ||
context: context, | ||
byte: byte | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should always raise, and not behave differently based on the format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What information should be in the exception? I guess I'm not exactly clear on what exactly should change with different error codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want a way to not raise, then we should create a validate_utf8
that returns {:error, Exception}
without raising. But we should not use the status code to control that. It is unclear what is the ultimate gain here.
There are many changes here. Can you please keep add them granularly? Although I don't think there is a need for position or to change the return type based on the code. It is a function with |
Something like this?
|
No, that does not change how the server is going to respond in any way. Can you take a step back and remind us what is your end goal? :) If you want to change the exception, it would be something like:
When defining the exception being raised. |
@@ -1,4 +1,6 @@ | |||
defmodule Plug.Conn.Utils do | |||
require Logger | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added error_code and byte_position to validate_utf8!
added ascii optimization as found in String.valid?
wrote tests for changes
edited existing tests to incorporate "in position #{byte_position}
added documentation