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

URI escape invalid #132

Open
kallisti5 opened this issue Feb 17, 2022 · 3 comments
Open

URI escape invalid #132

kallisti5 opened this issue Feb 17, 2022 · 3 comments

Comments

@kallisti5
Copy link

/home/kallisti5/.gem/ruby/3.0.0/gems/s3-0.3.29/lib/s3/bucket.rb:154:in `list_bucket': undefined method `escape' for URI:Module (NoMethodError)
	from /home/kallisti5/.gem/ruby/3.0.0/gems/s3-0.3.29/lib/s3/bucket.rb:115:in `block in objects'
	from /home/kallisti5/.gem/ruby/3.0.0/gems/proxies-0.2.3/lib/proxies/proxy.rb:58:in `proxy_target'
	from /home/kallisti5/.gem/ruby/3.0.0/gems/proxies-0.2.3/lib/proxies/proxy.rb:62:in `method_missing'
	from ./nightly-reaper-s3.rb:37:in `<main>'
@kallisti5 kallisti5 changed the title URI escale invalid URI escape invalid Feb 17, 2022
@qoobaa
Copy link
Owner

qoobaa commented Feb 18, 2022

Yeah, it seems some changes are required in order to launch it on Ruby 3.0.

Could you create a PR?

@kallisti5
Copy link
Author

kallisti5 commented Feb 18, 2022

I was able to work around the issue locally:

--- /home/kallisti5/.gem/ruby/3.0.0/gems/s3-0.3.29/lib/s3/bucket.rb.original	2022-02-18 13:26:37.247078560 -0600
+++ /home/kallisti5/.gem/ruby/3.0.0/gems/s3-0.3.29/lib/s3/bucket.rb	2022-02-18 13:26:47.707146732 -0600
@@ -151,7 +151,7 @@
       # If there are more than 1000 objects S3 truncates listing and
       # we need to request another listing for the remaining objects.
       while parse_is_truncated(response.body)
-        next_request_options = {:marker => URI.escape(objects_attributes.last[:key])}
+        next_request_options = {:marker => URI::DEFAULT_PARSER.escape(objects_attributes.last[:key])}
 
         if max_keys
           break if objects_attributes.length >= max_keys

That's likely not a good fix though since it might break for Ruby 2.x / stdlib 2.x.

Really surprised Ruby didn't leave some compatibility .escape call in the api :-|

@kallisti5
Copy link
Author

I opened https://bugs.ruby-lang.org/issues/18593 maybe the real solution is Ruby 3.x should have been less aggressive in refactoring escape :-)

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

No branches or pull requests

2 participants