cloudinary 1.0.62 → 1.0.63
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cloudinary/uploader.rb +1 -0
- data/lib/cloudinary/utils.rb +6 -4
- data/lib/cloudinary/version.rb +1 -1
- data/spec/utils_spec.rb +14 -1
- metadata +2 -2
data/lib/cloudinary/uploader.rb
CHANGED
@@ -35,6 +35,7 @@ class Cloudinary::Uploader
|
|
35
35
|
:eager_notification_url=>options[:eager_notification_url],
|
36
36
|
:eager_async=>Cloudinary::Utils.as_safe_bool(options[:eager_async]),
|
37
37
|
:proxy=>options[:proxy],
|
38
|
+
:folder=>options[:folder],
|
38
39
|
:tags=>options[:tags] && Cloudinary::Utils.build_array(options[:tags]).join(",")}
|
39
40
|
params
|
40
41
|
end
|
data/lib/cloudinary/utils.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Copyright Cloudinary
|
2
2
|
require 'digest/sha1'
|
3
3
|
require 'zlib'
|
4
|
+
require 'uri'
|
4
5
|
require 'aws_cf_signer'
|
5
6
|
|
6
7
|
class Cloudinary::Utils
|
@@ -133,8 +134,9 @@ class Cloudinary::Utils
|
|
133
134
|
|
134
135
|
if source.match(%r(^https?:/)i)
|
135
136
|
source = smart_escape(source)
|
136
|
-
|
137
|
-
source =
|
137
|
+
else
|
138
|
+
source = smart_escape(URI.decode(source))
|
139
|
+
source = "#{source}.#{format}" if !format.blank?
|
138
140
|
end
|
139
141
|
|
140
142
|
if cloud_name.start_with?("/") # For development
|
@@ -227,9 +229,9 @@ class Cloudinary::Utils
|
|
227
229
|
|
228
230
|
# Based on CGI::unescape. In addition does not escape / :
|
229
231
|
def self.smart_escape(string)
|
230
|
-
string.gsub(/([^
|
232
|
+
string.gsub(/([^a-zA-Z0-9_.\-\/:]+)/) do
|
231
233
|
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
232
|
-
end
|
234
|
+
end
|
233
235
|
end
|
234
236
|
|
235
237
|
def self.random_public_id
|
data/lib/cloudinary/version.rb
CHANGED
data/spec/utils_spec.rb
CHANGED
@@ -235,7 +235,7 @@ describe Cloudinary::Utils do
|
|
235
235
|
options = {:type=>:youtube}
|
236
236
|
result = Cloudinary::Utils.cloudinary_url("http://www.youtube.com/watch?v=d9NF2edxy-M", options)
|
237
237
|
options.should == {}
|
238
|
-
result.should == "http://res.cloudinary.com/test123/image/youtube/http://www.youtube.com/watch%3Fv%3Dd9NF2edxy
|
238
|
+
result.should == "http://res.cloudinary.com/test123/image/youtube/http://www.youtube.com/watch%3Fv%3Dd9NF2edxy-M"
|
239
239
|
end
|
240
240
|
|
241
241
|
it "should support background" do
|
@@ -426,4 +426,17 @@ describe Cloudinary::Utils do
|
|
426
426
|
preloaded = Cloudinary::PreloadedFile.new("image/upload/v1234/folder/file.jpg#" + signature)
|
427
427
|
preloaded.should be_valid
|
428
428
|
end
|
429
|
+
|
430
|
+
it "should escape public_ids" do
|
431
|
+
[
|
432
|
+
["a b", "a%20b"],
|
433
|
+
["a+b", "a%2Bb"],
|
434
|
+
["a%20b", "a%20b"],
|
435
|
+
["a-b", "a-b"],
|
436
|
+
["a??b", "a%3F%3Fb"]
|
437
|
+
].each do
|
438
|
+
|source, target|
|
439
|
+
Cloudinary::Utils.cloudinary_url(source).should == "http://res.cloudinary.com/test123/image/upload/#{target}"
|
440
|
+
end
|
441
|
+
end
|
429
442
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.63
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-07
|
14
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|