This commit is contained in:
technoweenie 2013-01-04 11:11:22 -07:00
Родитель 412110ac73
Коммит 9b556eac46
4 изменённых файлов: 31 добавлений и 15 удалений

Просмотреть файл

@ -28,19 +28,30 @@ require 's3/connection'
require 's3/authentication'
require 's3/response'
AWS::S3::Base.class_eval do
include AWS::S3::Connection::Management
module AWS
module S3
UNSAFE_URI = /[^-_.!~*'()a-zA-Z\d;\/?:@&=$,\[\]]/n
def self.escape_uri(path)
URI.escape(path.to_s, UNSAFE_URI)
end
Base.class_eval do
include AWS::S3::Connection::Management
end
Bucket.class_eval do
include AWS::S3::Logging::Management
include AWS::S3::ACL::Bucket
end
S3Object.class_eval do
include AWS::S3::ACL::S3Object
include AWS::S3::BitTorrent
end
end
end
AWS::S3::Bucket.class_eval do
include AWS::S3::Logging::Management
include AWS::S3::ACL::Bucket
end
AWS::S3::S3Object.class_eval do
include AWS::S3::ACL::S3Object
include AWS::S3::BitTorrent
end
require_library_or_gem 'xmlsimple', 'xml-simple' unless defined? XmlSimple
# If libxml is installed, we use the FasterXmlSimple library, that provides most of the functionality of XmlSimple

Просмотреть файл

@ -8,7 +8,7 @@ module AWS
def prepare_path(path)
path = path.remove_extended unless path.valid_utf8?
URI.escape(path)
AWS::S3.escape_uri(path)
end
end
@ -275,4 +275,4 @@ module AWS
end
end
end
end
end

Просмотреть файл

@ -7,7 +7,7 @@ class Hash
unless empty?
query_string << '?' if include_question_mark
query_string << inject([]) do |params, (key, value)|
params << "#{key}=#{value}"
params << "#{key}=#{AWS::S3.escape_uri(value)}"
end.join('&')
end
query_string

Просмотреть файл

@ -26,6 +26,11 @@ class HashExtensionsTest < Test::Unit::TestCase
qs = hash.to_query_string
assert qs['one=1&two=2'] || qs['two=2&one=1']
end
def test_escape_values
hash = {:one => '5+ 1'}
assert_equal '?one=5%2B%201', hash.to_query_string
end
def test_normalized_options
expectations = [
@ -342,4 +347,4 @@ class AttributeProxyTest < Test::Unit::TestCase
assert_equal 'baz', n.foo
end
end
end