growlyflash
growlyflash copied to clipboard
Breaks in Ruby 3.x due to deprecation of URI.escape
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)
^^^^^^^):
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?
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.