cloudinary 1.0.17 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ module Cloudinary::CarrierWave
24
24
  @file = CloudinaryFile.new(identifier, self)
25
25
  @public_id = @stored_public_id = @file.public_id
26
26
  @stored_version = @file.version
27
- self.original_filename = @file.filename
27
+ self.original_filename = sanitize(@file.filename)
28
28
  end
29
29
  end
30
30
 
@@ -76,6 +76,12 @@ module Cloudinary::CarrierWave
76
76
  # Do nothing
77
77
  end
78
78
 
79
+ SANITIZE_REGEXP = CarrierWave::SanitizedFile.respond_to?(:sanitize_regexp) ? CarrierWave::SanitizedFile.sanitize_regexp : /[^a-zA-Z0-9\.\-\+_]/
80
+ def sanitize(filename)
81
+ return nil if filename.nil?
82
+ filename.gsub(SANITIZE_REGEXP, '_')
83
+ end
84
+
79
85
  # Should removed files be removed from Cloudinary as well. Can be overridden.
80
86
  def delete_remote?
81
87
  true
@@ -10,7 +10,7 @@ module Cloudinary::CarrierWave
10
10
  @file = PreloadedCloudinaryFile.new(new_file)
11
11
  @stored_version = @file.version
12
12
  @public_id = @stored_public_id = @file.public_id
13
- self.original_filename = @file.original_filename
13
+ self.original_filename = sanitize(@file.original_filename)
14
14
  @cache_id = "unused" # must not be blank
15
15
  else
16
16
  super
@@ -23,7 +23,7 @@ module Cloudinary::CarrierWave
23
23
  @file = PreloadedCloudinaryFile.new(new_file)
24
24
  @stored_version = @file.version
25
25
  @public_id = @stored_public_id = @file.public_id
26
- self.original_filename = @file.original_filename
26
+ self.original_filename = sanitize(@file.original_filename)
27
27
  @cache_id = "unused" # must not be blank
28
28
  else
29
29
  super
@@ -143,7 +143,7 @@ class Cloudinary::Utils
143
143
  end
144
144
 
145
145
  def self.signed_preloaded_image(result)
146
- "#{result["resource_type"]}/upload/v#{result["version"]}/#{[result["public_id"], result["format"]].join(".")}##{result["signature"]}"
146
+ "#{result["resource_type"]}/upload/v#{result["version"]}/#{[result["public_id"], result["format"]].reject(&:blank?).join(".")}##{result["signature"]}"
147
147
  end
148
148
 
149
149
  @@json_decode = false
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.17"
3
+ VERSION = "1.0.18"
4
4
  end
data/spec/utils_spec.rb CHANGED
@@ -166,4 +166,23 @@ describe Cloudinary::Utils do
166
166
  options.should == {}
167
167
  result.should == "http://res.cloudinary.com/test123/image/fetch/http://blah.com/hello%3Fa%3Db"
168
168
  end
169
+
170
+ it "should support background" do
171
+ options = {:background=>"red"}
172
+ result = Cloudinary::Utils.cloudinary_url("test", options)
173
+ options.should == {}
174
+ result.should == "http://res.cloudinary.com/test123/image/upload/b_red/test"
175
+ options = {:background=>"#112233"}
176
+ result = Cloudinary::Utils.cloudinary_url("test", options)
177
+ options.should == {}
178
+ result.should == "http://res.cloudinary.com/test123/image/upload/b_rgb:112233/test"
179
+ end
180
+
181
+ it "should support default_image" do
182
+ options = {:default_image=>"default"}
183
+ result = Cloudinary::Utils.cloudinary_url("test", options)
184
+ options.should == {}
185
+ result.should == "http://res.cloudinary.com/test123/image/upload/d_default/test"
186
+ end
187
+
169
188
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cloudinary
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.17
5
+ version: 1.0.18
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nadav Soferman
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2012-04-28 00:00:00 +03:00
15
+ date: 2012-05-02 00:00:00 +03:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -81,6 +81,7 @@ files:
81
81
  - assets/js/jquery.fileupload.js
82
82
  - assets/js/jquery.iframe-transport.js
83
83
  - assets/js/jquery.ui.widget.js
84
+ - assets/test/SpecRunner.html
84
85
  has_rdoc: true
85
86
  homepage: http://cloudinary.com
86
87
  licenses: []