Skip to content

Conversation

@takuminmin-m
Copy link

Hi there,

Thanks for this nice gem to use carrierwave-data-uri.

I noticed require "data_uri" fails when I upgraded my application to Ruby3.1.
Look like we mustn't use @@schemes class variable because the suparclass "URI::Generic" has been changed the specification.(the relevant PR is here).

If you have any advices, please tell me.
Hope that helps!

end

@@schemes['DATA'] = Data
scheme_list['DATA'] = Data

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this new improvement could also be used?
ruby/uri@4346daa

Copy link

@olleolleolle olleolleolle Aug 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a Rails initializer with this content, which worked for me:

require 'data_uri'
require 'data_uri/open_uri'

URI.register_scheme('DATA', URI::Data)

mamhoff added a commit to friendlycart/friendly_shipping that referenced this pull request Sep 15, 2022
The URI gem has changed its public API with this version, breaking
compatibility with the largely unmaintained `data_uri` gem. This fixes
the co-dependency issue for now; once this PR in `data_uri` is merged we
can update to the newest `uri` gem:

dball/data_uri#10
end

@@schemes['DATA'] = Data
scheme_list['DATA'] = Data
Copy link

@haseebeqx haseebeqx Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend to do this to make it available for older versions of ruby. also used https://ruby-doc.org/stdlib-3.1.0/libdoc/uri/rdoc/URI.html#method-c-register_scheme

unless defined?(self.register_scheme)
  def self.register_scheme(scheme, klass)
     @@schemes[scheme] = klass
  end
end
register_scheme 'DATA', Data

@PikachuEXE
Copy link

Should we ping contributors individually to see if this can be merged? Or even if this gem is maintained?

@PikachuEXE
Copy link

@dball ?

@PikachuEXE
Copy link

@dball

A fix for a CVE is released

CVE-2023-36617: ReDoS vulnerability in URI

Eventually uri 0.10.x will become unmaintained and this should be addressed soon
Add people as maintainers if you don't the capacity to maintain

@niyando
Copy link

niyando commented May 20, 2024

Can we please get this merged?

@PikachuEXE
Copy link

Released a beta
https://rubygems.org/gems/data_uri_revived/versions/0.1.1.beta2

@olleolleolle
Copy link

olleolleolle commented Jan 7, 2026

Released a beta https://rubygems.org/gems/data_uri_revived/versions/0.1.1.beta2

It seems that the source code for it is available at https://github.com/data-uri-ruby/data_uri/tree/master/lib

I note that the open_uri.rb file is missing from that distributed gem. aredotna had it in their fork: https://github.com/aredotna/data_uri/blob/master/lib/data_uri/open_uri.rb

In order to make the distributed gem work, I added that snippet to my Rails initializer:

require "data_uri_revived"
require "stringio"

module URI
  class Data
    def open
      io = StringIO.new(data)
      OpenURI::Meta.init(io)
      io.meta_add_field("content-type", content_type)
      if block_given?
        begin
          yield io
        ensure
          io.close
        end
      else
        io
      end
    end
  end
end

URI.register_scheme("DATA", URI::Data)

Hope this helps!

@PikachuEXE
Copy link

Ya I removed that part since I have no idea what it does and how people use it
I rather put it into README as a suggestion than some actual code

@PikachuEXE
Copy link

https://github.com/data-uri-ruby/data_uri got https://github.com/data-uri-ruby/data_uri/releases/tag/v0.1.1 a year ago
And I just added 4.0 test in CI and all looks fine
I am guessing there is little hope to see this gem to be updated so switch soon if you haven't
PR welcome

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.

5 participants