flavorjones / loofah

Ruby library for HTML/XML transformation and sanitization
MIT License
934 stars 137 forks source link

Getting errors using Nokogiri < 1.12 #266

Closed srussking closed 1 year ago

srussking commented 1 year ago

Hi, I am getting the following error:

     1: from /usr/share/rvm/gems/ruby-2.7.2/gems/loofah-2.21.1/lib/loofah/html4/document.rb:4:in `<module:Loofah>'
/usr/share/rvm/gems/ruby-2.7.2/gems/loofah-2.21.1/lib/loofah/html4/document.rb:10:in `<module:HTML4>': uninitialized constant Nokogiri::HTML4 (NameError)

It seems that Nokogiri added the HTML4 name in version 1.12.x, so upgrading to the latest Nokogiri seems to fix this, but might be better if you were requiring that in your gemspec, which SEEMS to be 1.5.9?

Thanks!

an280420 commented 1 year ago

There seems to be a problem with older versions of ruby. I use ruby v 2.4.10, nokogiri v 1.10.10 and getting the error

NameError: uninitialized constant Nokogiri::HTML4
Did you mean?  Nokogiri::HTML
....rbenv/versions/2.4.10/lib/ruby/gems/2.4.0/gems/loofah-2.21.1/lib/loofah/html4/document.rb:10:in `<module:HTML4>'

Thanks!

vrodokanakis commented 1 year ago

It seems it has to do with nokogiri version. Same error on ruby 2.6.8.

Maybe a new version needs to be released, with nokogiri dependency > 12 (instead of >= 1.5.9)? 🙏

Thanks.

flavorjones commented 1 year ago

Thanks for the comments, everyone. I'll look into it.

flavorjones commented 1 year ago

PR at #267, if all is well I should be able to cut a patch release quickly.

flavorjones commented 1 year ago

v2.21.2 has been released fixing this. Thanks for your patience.

abhisapate commented 1 year ago

@flavorjones won't it still look for v2.21.1 in the case of nokogiri 1.10.10?

flavorjones commented 1 year ago

@abhisapate Are you having a problem? I'd be happy to try to help, but I need more information.

abhisapate commented 1 year ago

Yeah, in case I don't specify the loofah version in Gemfile and we are using Ruby 2.4.10 and nokogiri is locked to 1.10.10.

Before this patch it was fetching loofah v2.21.1 but the dependencies were updated in the patch for v2.21.2, so the bundler will still get the version v2.21.1 which will give me the below error, right?

NameError: uninitialized constant Nokogiri::HTML4
Did you mean?  Nokogiri::HTML
....rbenv/versions/2.4.10/lib/ruby/gems/2.4.0/gems/loofah-2.21.1/lib/loofah/html4/document.rb:10:in `<module:HTML4>'
sl0thentr0py commented 1 year ago

also seeing this on sentry-ruby https://github.com/getsentry/sentry-ruby/actions/runs/4829581698/jobs/8913943865

EDIT:

ok just saw the min 2.5 ruby requirement, will fix on our end. you can ignore!

flavorjones commented 1 year ago

I'm not yanking these versions of the gem, as yanking tends to be very disruptive to the community. Please pin this dependency in your apps if you're on Ruby 2.4 or earlier, or consider upgrading. Apologies for the inconvenience.

abhisapate commented 1 year ago

@flavorjones Sure, I'll specify the version in Gemfile. Thanks for the help!