From 79b1040189912c3b09022ac835f80e2513360b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 15 Aug 2021 21:17:40 +0200 Subject: [PATCH] Supress warnings in Paperclip::UrlGenerator We were getting hundreds of "warning: URI.escape is obsolete" messages. So we're using `URI::DEFAULT_PARSER.escape` instead. IMHO it's OK to add this monkey-patch because we're replacing Paperclip with Active Storage, and when we finish with that we'll delete this file. --- config/initializers/paperclip.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 config/initializers/paperclip.rb diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb new file mode 100644 index 00000000000..97a4079d9b8 --- /dev/null +++ b/config/initializers/paperclip.rb @@ -0,0 +1,13 @@ +class Paperclip::UrlGenerator + private + + # Code copied from the paperclip gem, only replacing + # `URI.escape` with `URI::DEFAULT_PARSER.escape` + def escape_url(url) + if url.respond_to?(:escape) + url.escape + else + URI::DEFAULT_PARSER.escape(url).gsub(escape_regex) { |m| "%#{m.ord.to_s(16).upcase}" } + end + end +end