lib/paperclip/url_generator.rb in paperclip-4.2.0 vs lib/paperclip/url_generator.rb in paperclip-4.2.1
- old
+ new
@@ -6,12 +6,12 @@
@attachment = attachment
@attachment_options = attachment_options
end
def for(style_name, options)
- escape_url_as_needed(
- timestamp_as_needed(
+ timestamp_as_needed(
+ escape_url_as_needed(
@attachment_options[:interpolator].interpolate(most_appropriate_url, @attachment, style_name),
options
), options)
end
@@ -56,9 +56,17 @@
url
end
end
def escape_url(url)
- (url.respond_to?(:escape) ? url.escape : URI.escape(url)).gsub(/(\/.+)\?(.+\.)/, '\1%3F\2')
+ if url.respond_to?(:escape)
+ url.escape
+ else
+ URI.escape(url).gsub(escape_regex){|m| "%#{m.ord.to_s(16).upcase}" }
+ end
+ end
+
+ def escape_regex
+ /[\?\(\)\[\]\+]/
end
end
end