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 +4 -4
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +14 -0
- data/README.md +16 -0
- data/lib/cloudinary/auth_token.rb +5 -1
- data/lib/cloudinary/migrator.rb +3 -3
- data/lib/cloudinary/utils.rb +2 -2
- data/lib/cloudinary/version.rb +1 -1
- data/spec/auth_token_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa2967c1b17b93efadf7db793ac1110b7bd411f6
|
4
|
+
data.tar.gz: 79d2beeae5fe07afd1c4aaffb3bc17d442b2f418
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/cloudinary/migrator.rb
CHANGED
@@ -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
|
91
|
-
raise CloudinaryException, "id not given and
|
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!
|
data/lib/cloudinary/utils.rb
CHANGED
@@ -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
|
-
'%' +
|
641
|
+
string.gsub(unsafe) do |m|
|
642
|
+
'%' + m.unpack('H2' * m.bytesize).join('%').upcase
|
643
643
|
end
|
644
644
|
end
|
645
645
|
|
data/lib/cloudinary/version.rb
CHANGED
data/spec/auth_token_spec.rb
CHANGED
@@ -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
|
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=
|
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
|
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.
|
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-
|
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
|