mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace] fix excluding extra characters in Rackspace.escape
This commit is contained in:
parent
bf7d348d88
commit
f651d05654
2 changed files with 7 additions and 2 deletions
|
@ -130,7 +130,10 @@ module Fog
|
|||
|
||||
# CGI.escape, but without special treatment on spaces
|
||||
def self.escape(str,extra_exclude_chars = '')
|
||||
str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
|
||||
# '-' is a special character inside a regex class so it must be first or last.
|
||||
# Add extra excludes before the final '-' so it always remains trailing, otherwise
|
||||
# an unwanted range is created by mistake.
|
||||
str.gsub(/([^a-zA-Z0-9_.#{extra_exclude_chars}-]+)/) do
|
||||
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Shindo.tests('Rackspace | url_encoding', ['rackspace']) do
|
||||
returns( Fog::Rackspace.escape( "is this my file?.jpg" ) ) { "is%20this%20my%20file%3F.jpg" }
|
||||
returns("is%20this%20my%20file%3F.jpg") { Fog::Rackspace.escape("is this my file?.jpg") }
|
||||
returns("foo/bar") { Fog::Rackspace.escape("foo/bar", "/") }
|
||||
returns("foo%2Fbar") { Fog::Rackspace.escape("foo/bar", "0") }
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue