estum / growlyflash

Growl-styled flash messages for Ruby on Rails and Bootstrap
MIT License
58 stars 34 forks source link

Breaks in Ruby 3.x due to deprecation of URI.escape #49

Open pkarjala opened 1 year ago

pkarjala commented 1 year ago

Due to the deprecation of URI.escape (see https://github.com/ruby/uri/commit/61c6a47ebf1f2726b60a2bbd70964d64e14b1f98 and https://github.com/ruby/uri/issues/14), this gem will no longer work in Ruby 3.x based Rails projects.

Fix might be straightforward to replace with CGI.escape instead.

Specific error from a project using growlyflash 0.10.1:

NoMethodError (undefined method `escape' for URI:Module

        response.headers['X-Message'] = URI.escape(growlyhash.to_json)
                                           ^^^^^^^):
pkarjala commented 1 year ago

Tested replacing URI.escape with CGI.escape which works, but re-encodes spaces as + instead. Which isn't ideal, but at least fixes the underlying issue.

Alternatively, can remove the URI.escape entirely and the response will send fine with no re-encoded content. Not sure if URI.escape is needed or not for security or standardization reasons?

pkarjala commented 3 weeks ago

Following up with this, replacing URI.escape with ERB::Util.url_encode seems to fix the issue entirely. Will issue pull request on the chance this ever gets updated.