-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix overly aggressive remote image url escaping in specific instances #2457
Conversation
@@ -40,7 +40,9 @@ def download(url, remote_headers = {}) | |||
def process_uri(uri) | |||
uri_parts = uri.split('?') | |||
encoded_uri = Addressable::URI.parse(uri_parts.shift).normalize.to_s | |||
encoded_uri << '?' << Addressable::URI.encode(uri_parts.join('?')).gsub('%5B', '[').gsub('%5D', ']') if uri_parts.any? | |||
encoded_uri << '?' << Addressable::URI.encode(uri_parts.join('?')). | |||
gsub('%5B', '[').gsub('%253A%252F%252F', '%3A%2F%2F'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is specifically targeting for the ://
portion of the https://
or http://
or some-protocol://
and removing the double escape. This, coupled with the change in the next line, is what fixes the issue.
Also related to #2473, but different |
Ping. Anyone using Vimeo or imgix for mashups (overlays) defining the secondary image in a query param can’t use carrierwave in this manner. |
update from upstream repo
@mshibuya since your commit doesn't actually seem to address the issue my PR addressed (albeit, maybe mine wasn't the best approach, but it worked), what's an easy way of overriding the |
Dude I apologize. You’re right. Thanks man. |
Fixes carrierwaveuploader#2456, Closes carrierwaveuploader#2457, Fixes carrierwaveuploader#2472, Closes carrierwaveuploader#2473, Fixes carrierwaveuploader#2505, Fixes carrierwaveuploader#2517, Closes carrierwaveuploader#2518
Closes #2456 - which is an issue where in specific instances, when the remote download is trying to parse and escape the remote absolute image url, it can improperly escape some characters that are actually needed in order for the image/download to work - specifically when the image source is actually in the query string, and not in the base portion of the path.
You'll see this type of pattern semi-often; where the image path/source is actually defined in the query parameter in on-the-fly overlays/mashups of images (which imgix supports) and in the way Vimeo's thumbnail images work as well (among others).
The related issue at #2456 has more information and an example.