cloudinary 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c78db40dfbd0f2a2fa579c3817208c11c89136be
4
- data.tar.gz: c1f15ae49d99c4c1edb404cd6c49eb4a6c992a58
3
+ metadata.gz: aa2967c1b17b93efadf7db793ac1110b7bd411f6
4
+ data.tar.gz: 79d2beeae5fe07afd1c4aaffb3bc17d442b2f418
5
5
  SHA512:
6
- metadata.gz: e8b61e2b1660f36ed2f4cb2b85a38010b8135455e1c1ad743dfe3f267c695c7f88195d038a7548fbe2f6c6d63a005dd458e396ba1f33370c937cf424f5ad14b0
7
- data.tar.gz: dbec90b6f71bbad87e31740e419d225bd8804a012310ee55121661d93a48e4d136ae1b86e8ed80b86111d9f004dde54399c72e3f39138686b77616fc7624b92e
6
+ metadata.gz: a46e2e84655389ac281378a44212964acd0f43f0ff66b9d7ef6fc0ce5cbf8a6b6467925dca57768174f0246780f844d6f4f08683fac95d46a49d3bee1d3ec18b
7
+ data.tar.gz: 873cf3dbb2ad9296c31d0aacfbbacf66b210bad3220c73e27014f7c386295cad91ae1347fd4c4d5c1631d311bc88c8fe899404bc68aa91a6e12f37e7346028f5
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ 1.9.1 / 2018-03-06
3
+ ==================
4
+
5
+ * Add instructions for using the source code. Fixes #291 and #292
6
+ * Fix check for CarrierWave in `Migrator`. Fixes #286
7
+ * Fix acl and url escaping in auth_token generation
8
+
2
9
  1.9.0 / 2018-02-27
3
10
  ==================
4
11
 
data/CONTRIBUTING.md CHANGED
@@ -41,6 +41,20 @@ cd cloudinary_gem
41
41
  git remote add upstream https://github.com/cloudinary/cloudinary_gem.git
42
42
  ```
43
43
 
44
+ #### Install dependencies
45
+
46
+ ```
47
+ gem install bundler
48
+ bundle install
49
+ ```
50
+
51
+ #### Run the tests
52
+ You can obtain the configuration URL from https://cloudinary.com/console.
53
+
54
+ ```
55
+ export CLOUDINARY_URL=cloudinary://<api_key>:<api_secret>@<cloud>
56
+ bundle exec rspec -f d
57
+ ```
44
58
  #### Create a Topic Branch
45
59
 
46
60
  Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
data/README.md CHANGED
@@ -17,6 +17,7 @@ For Ruby on Rails, Cloudinary provides a GEM for simplifying the integration eve
17
17
 
18
18
  ## Setup ######################################################################
19
19
 
20
+ ### Installing the gem
20
21
  To install the Cloudinary Ruby GEM, run:
21
22
 
22
23
  $ gem install cloudinary
@@ -44,6 +45,21 @@ Rails 2.x environment.rb:
44
45
 
45
46
  *Note: The CarrierWave GEM should be loaded before the Cloudinary GEM.*
46
47
 
48
+ ### Using the source code directly
49
+
50
+ You can use the source code of this library directly instead of installing the packaged gem file.
51
+
52
+ git clone https://github.com/cloudinary/cloudinary_gem.git
53
+
54
+ # if you haven't installed bundler, do so now with:
55
+ # gem install bundler
56
+
57
+ bundle install
58
+
59
+ Finally, fetch the related assets. This process is done automatically when the packaged gem is installed.
60
+
61
+ rake cloudinary:fetch_assets
62
+
47
63
  ## Try it right away
48
64
 
49
65
  Sign up for a [free account](https://cloudinary.com/users/register/free) so you can try out image transformations and seamless image delivery through CDN.
@@ -9,6 +9,7 @@ end
9
9
  module Cloudinary
10
10
  module AuthToken
11
11
  SEPARATOR = '~'
12
+ UNSAFE = /[ "#%&\'\/:;<=>?@\[\\\]^`{\|}~]/
12
13
 
13
14
  def self.generate(options = {})
14
15
  key = options[:key]
@@ -56,9 +57,12 @@ module Cloudinary
56
57
 
57
58
  # escape URI pattern using lowercase hex. For example "/" -> "%2f".
58
59
  def self.escape_to_lower(url)
59
- CGI::escape(url).gsub(/%../) { |h| h.downcase }
60
+ Utils.smart_escape(url, UNSAFE).gsub(/%[0-9A-F]{2}/) do |h|
61
+ h.downcase
62
+ end.force_encoding(Encoding::US_ASCII)
60
63
  end
61
64
 
65
+
62
66
  def self.digest(message, key)
63
67
  bin_key = Array(key).pack("H*")
64
68
  digest = OpenSSL::Digest::SHA256.new
@@ -87,8 +87,8 @@ class Cloudinary::Migrator
87
87
  end
88
88
 
89
89
  def process(options={})
90
- raise CloudinaryException, "url not given and no retieve callback given" if options[:url].nil? && self.retrieve.nil?
91
- raise CloudinaryException, "id not given and retieve or complete callback given" if options[:id].nil? && (!self.retrieve.nil? || !self.complete.nil?)
90
+ raise CloudinaryException, "url not given and no retrieve callback given" if options[:url].nil? && self.retrieve.nil?
91
+ raise CloudinaryException, "id not given and retrieve or complete callback given" if options[:id].nil? && (!self.retrieve.nil? || !self.complete.nil?)
92
92
 
93
93
  debug("Process: #{options.inspect}")
94
94
  start
@@ -248,7 +248,7 @@ class Cloudinary::Migrator
248
248
  if defined?(ActiveRecord::Base) && data.is_a?(ActiveRecord::Base)
249
249
  cw = true
250
250
  data.save!
251
- elsif defined?(Cloudinary::CarrierWave) && data.is_a?(Cloudinary::CarrierWave)
251
+ elsif defined?(::CarrierWave) && defined?(Cloudinary::CarrierWave) && data.is_a?(Cloudinary::CarrierWave)
252
252
  cw = true
253
253
  begin
254
254
  data.model.save!
@@ -638,8 +638,8 @@ class Cloudinary::Utils
638
638
 
639
639
  # Based on CGI::unescape. In addition does not escape / :
640
640
  def self.smart_escape(string, unsafe = /([^a-zA-Z0-9_.\-\/:]+)/)
641
- string.gsub(unsafe) do
642
- '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
641
+ string.gsub(unsafe) do |m|
642
+ '%' + m.unpack('H2' * m.bytesize).join('%').upcase
643
643
  end
644
644
  end
645
645
 
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.9.0"
3
+ VERSION = "1.9.1"
4
4
  end
@@ -16,7 +16,7 @@ describe 'auth_token' do
16
16
  end
17
17
  it "should generate with start and duration" do
18
18
  token = Cloudinary::Utils.generate_auth_token :start_time => 1111111111, :acl => "/image/*", :duration => 300
19
- expect(token).to eq '__cld_token__=st=1111111111~exp=1111111411~acl=%2fimage%2f%2a~hmac=0d5b0c9c1485ee162c459879fe62e06caa23bc26fec92d58bd100f2e1592eac6'
19
+ expect(token).to eq '__cld_token__=st=1111111111~exp=1111111411~acl=%2fimage%2f*~hmac=1751370bcc6cfe9e03f30dd1a9722ba0f2cdca283fa3e6df3342a00a7528cc51'
20
20
  end
21
21
 
22
22
  describe "authenticated url" do
@@ -46,7 +46,7 @@ describe 'auth_token' do
46
46
  end
47
47
  it "explicit authToken should override global setting" do
48
48
  url = Cloudinary::Utils.cloudinary_url "sample.jpg", :sign_url => true, :auth_token => { :key => ALT_KEY, :start_time => 222222222, :duration => 100 }, :type => "authenticated", :transformation => { :crop => "scale", :width => 300 }
49
- expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac=7d276841d70c4ecbd0708275cd6a82e1f08e47838fbb0bceb2538e06ddfa3029")
49
+ expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac=55cfe516530461213fe3b3606014533b1eca8ff60aeab79d1bb84c9322eebc1f")
50
50
 
51
51
  end
52
52
  it "should compute expiration as start time + duration" do
@@ -71,7 +71,7 @@ describe 'auth_token' do
71
71
  tokenOptions = { :key => KEY, :duration => 300, :acl => "/*/t_#{user}" }
72
72
  tokenOptions[:start_time] = 222222222 # we can't rely on the default "now" value in tests
73
73
  cookieToken = Cloudinary::Utils.generate_auth_token tokenOptions
74
- expect(cookieToken).to eq("__cld_token__=st=222222222~exp=222222522~acl=%2f%2a%2ft_foobar~hmac=1284376353c1c43d6f6a98f2813c5596f4ff6f34d837cd853fd8c3c9e7f8428c")
74
+ expect(cookieToken).to eq("__cld_token__=st=222222222~exp=222222522~acl=%2f*%2ft_foobar~hmac=8e39600cc18cec339b21fe2b05fcb64b98de373355f8ce732c35710d8b10259f")
75
75
 
76
76
  end
77
77
  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.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nadav Soferman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-02-27 00:00:00.000000000 Z
13
+ date: 2018-03-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws_cf_signer