Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't call escape method on Ruby 3.0.0 #14

Closed
zacky1972 opened this issue Dec 25, 2020 · 7 comments
Closed

Can't call escape method on Ruby 3.0.0 #14

zacky1972 opened this issue Dec 25, 2020 · 7 comments

Comments

@zacky1972
Copy link

I can't call escape method of URI on Ruby 3.0.0 as follows:

% ruby --version
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
% irb
irb(main):001:0> p URI.espace('http://images.google.co.jp/images?q=モナリザ&ie=E
UC-JP')
Traceback (most recent call last):
        4: from /Users/zacky/.rbenv/versions/3.0.0/bin/irb:23:in `<main>'
        3: from /Users/zacky/.rbenv/versions/3.0.0/bin/irb:23:in `load'
        2: from /Users/zacky/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
        1: from (irb):1:in `<main>'
NoMethodError (undefined method `espace' for URI:Module)

I feel it has some problems.

@hsbt
Copy link
Member

hsbt commented Dec 25, 2020

It's intentionally removed at 61c6a47

@zacky1972
Copy link
Author

Oh, my gosh.

I use Middleman 4.3, which uses escape method of URI...

Is there an alternative?

@ioquatix
Copy link
Member

# This method is obsolete and should not be used. Instead, use
 # CGI.escape, URI.encode_www_form or URI.encode_www_form_component
 # depending on your specific use case.

@davidelbe
Copy link

Use CGI.escape instead. FYI, your first comment tries to use espacewhich I guess just is a spelling error.

While you are waiting for Middleman to be updated you could always monkeypatch the escape method in URI to use CGI.escape instead.

@GieziJo
Copy link

GieziJo commented Feb 4, 2021

In case somebody else stumbles uppon this, using the latest github version of middleman instead of the default version fixed this for me. In your Gemfile change gem 'middleman' to

gem 'middleman', github: 'middleman/middleman'

@paulschreiber
Copy link

ERB::Util.url_encode worked better for me, as it used %20 instead of + for spaces.

danidoni added a commit to openSUSE/open-build-service that referenced this issue Mar 11, 2022
URI deprecated the escape method on updating to Ruby 3.0.0.
See ruby/uri#14
danidoni added a commit to danidoni/open-build-service that referenced this issue Mar 11, 2022
URI deprecated the escape method on updating to Ruby 3.0.0.
See ruby/uri#14
hennevogel pushed a commit to openSUSE/open-build-service that referenced this issue Mar 11, 2022
URI deprecated the escape method on updating to Ruby 3.0.0.
See ruby/uri#14
danidoni added a commit to danidoni/open-build-service that referenced this issue Mar 11, 2022
URI deprecated the escape method on updating to Ruby 3.0.0.
See ruby/uri#14
danidoni added a commit to danidoni/open-build-service that referenced this issue Mar 11, 2022
URI deprecated the escape method on updating to Ruby 3.0.0.
See ruby/uri#14
hennevogel pushed a commit to openSUSE/open-build-service that referenced this issue Mar 14, 2022
URI deprecated the escape method on updating to Ruby 3.0.0.
See ruby/uri#14
@vidurpunj
Copy link

yes method is missing in ruby 3.1.2 also solution is do a monkey patching.
under intializers foler of rails application add a file.
uri_escape.rb with code as below:

module URI
  def URI.escape(url)
    url
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants