Используем Addressable для эскейпинга URLов

This commit is contained in:
Nastia Gorokhova-Alekseeva
2022-08-30 13:50:29 +03:00
parent b1441563f7
commit 1ee553b7b3
9 changed files with 9 additions and 2 deletions

View File

@@ -24,6 +24,8 @@ gem 'thoughtbot-shoulda', '>= 2.9.0'
gem 'pry'
gem 'pry-byebug'
gem 'addressable'
group :lint do
gem 'rubocop', '0.81.0'
gem 'rubocop-rails', '2.5.2'

View File

@@ -15,6 +15,7 @@ gem "mocha"
gem "thoughtbot-shoulda", ">= 2.9.0"
gem "pry"
gem "pry-byebug"
gem "addressable"
group :lint do
gem "rubocop", "0.81.0"

View File

@@ -15,6 +15,7 @@ gem "mocha"
gem "thoughtbot-shoulda", ">= 2.9.0"
gem "pry"
gem "pry-byebug"
gem "addressable"
group :lint do
gem "rubocop", "0.81.0"

View File

@@ -15,6 +15,7 @@ gem "mocha"
gem "thoughtbot-shoulda", ">= 2.9.0"
gem "pry"
gem "pry-byebug"
gem "addressable"
group :lint do
gem "rubocop", "0.81.0"

View File

@@ -15,6 +15,7 @@ gem "mocha"
gem "thoughtbot-shoulda", ">= 2.9.0"
gem "pry"
gem "pry-byebug"
gem "addressable"
group :lint do
gem "rubocop", "0.81.0"

View File

@@ -180,7 +180,7 @@ module Paperclip
# К ссылке, сформированной по паттерну (например, через наш CDN), добавляем параметры с подписью
def presigned_url(style)
uri = URI.parse(CGI.escape(storage_url(style)))
uri = URI.parse(Addressable::URI.escape(storage_url(style)))
basic_params = CGI.parse(uri.query || '')
presign_params = CGI.parse(URI.parse(self.class.store_by(self.class.main_store_id).object(key(style))
.presigned_url(:get)).query)

View File

@@ -17,5 +17,6 @@ Gem::Specification.new do |s|
s.summary = %q{File attachments as attributes for ActiveRecord}
s.add_dependency 'activesupport', '< 7.1'
s.add_dependency 'addressable'
s.add_dependency 'fastimage'
end

0
test/fixtures/кириллица.txt vendored Normal file
View File

View File

@@ -41,7 +41,7 @@ class NoCacheS3Test < Test::Unit::TestCase
@store1_stub.stubs(:url).returns('http://store.local')
@store2_stub.stubs(:url).returns('http://store.local')
@instance.avatar.class.stubs(:stores).returns({ store_1: @store1_stub, store_2: @store2_stub })
Dummy::AvatarAttachment.any_instance.stubs(:to_file).returns(stub_file('test.txt', 'qwe'))
Dummy::AvatarAttachment.any_instance.stubs(:to_file).returns(stub_file('кириллица.txt', 'qwe'))
end
teardown { TEST_ROOT.rmtree if TEST_ROOT.exist? }