From cb65c7c2ef7ab91d3e125dc92e760e49dc67744b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 29 Sep 2021 12:51:32 +0100 Subject: [PATCH] Fix deprecation warning in Paperclip Fixes deprecation warnings in Paperclip::UrlGenerator#escape_url On a side note: we shouldn't be using Paperclip at all, and should migrate to ActiveStorage. --- config/initializers/paperclip.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index f934179d47..c2b04b98b5 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -28,3 +28,12 @@ if Paperclip::VERSION.to_f < 3.5 else Rails.logger.warn "The Paperclip::GeometryDetector patch can now be removed." end + +module UpdatedUrlGenerator + def escape_url(url) + (url.respond_to?(:escape) ? url.escape : URI::Parser.new.escape(url)). + gsub(/(\/.+)\?(.+\.)/, '\1%3F\2') + end +end + +Paperclip::UrlGenerator.prepend(UpdatedUrlGenerator)