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

URI::InvalidURIError when passed characters outside ascii #127

Open
madmax opened this issue Feb 3, 2022 · 2 comments
Open

URI::InvalidURIError when passed characters outside ascii #127

madmax opened this issue Feb 3, 2022 · 2 comments

Comments

@madmax
Copy link

madmax commented Feb 3, 2022

When we pass some no ascii characters it will raise error with URI::InvalidURIError

example:

Model.new(url:"\u201C").valid?
ArgumentError: wrong number of arguments (given 3, expected 1..2)
from /Users/madmax/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/bundler/gems/rails-ba8d029e0c99/activemodel/lib/active_model/errors.rb:310:in `add'
Caused by URI::InvalidURIError: URI must be ascii only "\u201C"
from /Users/madmax/.rbenv/versions/3.1.0/lib/ruby/3.1.0/uri/rfc3986_parser.rb:21:in `split'
@espen
Copy link

espen commented Aug 21, 2023

Can confirm. Does not handle Norwegian characters, for example https://example.org/path-with-ø/example

@espen
Copy link

espen commented Aug 21, 2023

This looks like a solution: uri = URI.parse(URI::Parser.new.escape(url)). See https://stackoverflow.com/questions/46849219/ruby-uriinvalidurierror-uri-must-be-ascii-only

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

No branches or pull requests

2 participants