gjtorikian / html-pipeline

HTML processing filters and utilities
MIT License
2.26k stars 380 forks source link

handle invalid data urls in absolute source filter #361

Closed glaszig closed 2 years ago

glaszig commented 2 years ago

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'
gjtorikian commented 2 years ago

Thanks!

glaszig commented 2 years ago

a release would be helpful as well.

gjtorikian commented 2 years ago

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

Released as 2.14.2.