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

handle invalid data urls in absolute source filter #361

Merged
merged 1 commit into from
Jun 12, 2022

Conversation

glaszig
Copy link
Contributor

@glaszig glaszig commented Jun 11, 2022

simply catch exceptions coming from URI.join like the camo filter does.
the truth is that arbitrary input can be mal-formatted, e.g.

URI::InvalidURIError: bad URI(is not URI?): "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='696px' height='391px' viewBox='0 0 696 391'%3E%3Crect x='0' y='0' width='696' height='391' fill='%23f2f2f2'%3E%3C/rect%3E%3C/svg%3E"
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/2.7.0/uri/rfc3986_parser.rb:67:in `split'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/2.7.0/uri/rfc3986_parser.rb:73:in `parse'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/2.7.0/uri/rfc3986_parser.rb:117:in `convert_to_uri'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/2.7.0/uri/generic.rb:1101:in `merge'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/2.7.0/uri/rfc3986_parser.rb:89:in `inject'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/2.7.0/uri/rfc3986_parser.rb:89:in `join'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/2.7.0/uri/common.rb:271:in `join'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/gems/2.7.0/gems/html-pipeline-2.14.0/lib/html/pipeline/absolute_source_filter.rb:31:in `block in call'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6-x86_64-darwin/lib/nokogiri/xml/node_set.rb:234:in `block in each'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6-x86_64-darwin/lib/nokogiri/xml/node_set.rb:233:in `upto'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6-x86_64-darwin/lib/nokogiri/xml/node_set.rb:233:in `each'
    /usr/local/Cellar/rbenv/1.2.0/versions/2.7.4/lib/ruby/gems/2.7.0/gems/html-pipeline-2.14.0/lib/html/pipeline/absolute_source_filter.rb:22:in `call'

simply catch exceptions coming from URI.join like the camo filter does.
the truth is that arbitrary input can be mal-formatted, e.g.

URI::InvalidURIError: bad URI(is not URI?): "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'
@gjtorikian
Copy link
Owner

Thanks!

@gjtorikian gjtorikian merged commit 578f958 into gjtorikian:main Jun 12, 2022
@glaszig
Copy link
Contributor Author

glaszig commented Jun 12, 2022

a release would be helpful as well.

@gjtorikian
Copy link
Owner

https://www.youtube.com/watch?v=CSLw6DAA4O0

Released as 2.14.2.

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