cloudinary 1.0.62 → 1.0.63

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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
- elsif !format.blank?
137
- source = "#{source}.#{format}"
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(/([^ a-zA-Z0-9_.-\/:]+)/) do
232
+ string.gsub(/([^a-zA-Z0-9_.\-\/:]+)/) do
231
233
  '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
232
- end.tr(' ', '+')
234
+ end
233
235
  end
234
236
 
235
237
  def self.random_public_id
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.62"
3
+ VERSION = "1.0.63"
4
4
  end
@@ -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%2DM"
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.62
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-30 00:00:00.000000000 Z
14
+ date: 2013-08-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rest-client