cloudinary 1.16.1 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeda4318322d6304cf37a68c621387dc7d4382cd45d6665eddea154ce30adac3
4
- data.tar.gz: ef675318a0c25a7e729d91ad014a8b36bad2756cafb73c20f69693b230747537
3
+ metadata.gz: e36bd9efd91c46b00fc0f52a3448ee076990a85b88a470e2cc8e7ccc610ed368
4
+ data.tar.gz: dbf3cb94bc5cae2b502b2ca1bea558c93c11e0f77d91fe0577e019452c2acc93
5
5
  SHA512:
6
- metadata.gz: c1ad5eee4b1b5eca7467e134cba0fc9516c0fe5af018637c1c0dbabc0a707a30e1cb115892de48f2acd2f8d339159842599edb7e0a1be15ea4ef391cbe569b78
7
- data.tar.gz: 19235e8274a35ed46c302a57056c45ff885b1a59a8ad852b057bce384729b108105b9b6d53638adefc2b317cccbc3fae48f4dbae962937e3e682da962f817b86
6
+ metadata.gz: ba800e50f02feb8cd582a4ca42f6bdfe0fd77c6e36c9dd7e0c3314c9d944bafc451329c79276b02b417f04357aad5ff0ad71e32d3b433f36f2732bfbba70fa84
7
+ data.tar.gz: de478592b7552f4aa1b6459effe907b692d22b334b63eb1dc02e7a3ca5e0e5779c7fe82306d3211935df1964f085fdba0e3e6f159716a0055dc45e370be8f6c4
@@ -0,0 +1,24 @@
1
+ ### Brief Summary of Changes
2
+ <!--
3
+ Provide some context as to what was changed, from an implementation standpoint.
4
+ -->
5
+
6
+ #### What does this PR address?
7
+ [ ] Gitub issue (Add reference - #XX)
8
+ [ ] Refactoring
9
+ [ ] New feature
10
+ [ ] Bug fix
11
+ [ ] Adds more tests
12
+
13
+ #### Are tests included?
14
+ [ ] Yes
15
+ [ ] No
16
+
17
+ #### Reviewer, Please Note:
18
+ <!--
19
+ List anything here that the reviewer should pay special attention to. This might
20
+ include, for example:
21
+ • Dependence on other PRs
22
+ • Reference to other Cloudinary SDKs
23
+ • Changes that seem arbitrary without further explanations
24
+ -->
@@ -12,4 +12,8 @@ matrix:
12
12
  rvm: ruby-2.5.3
13
13
  before_install:
14
14
  - gem install bundler
15
+
16
+ before_script: >
17
+ export CLOUDINARY_URL=$(bash tools/get_test_cloud.sh);
18
+ echo cloud_name: "$(echo $CLOUDINARY_URL | cut -d'@' -f2)"
15
19
  script: bundle exec rspec
@@ -1,4 +1,21 @@
1
1
 
2
+ 1.17.0 / 2020-08-21
3
+ ===================
4
+
5
+ New functionality and features
6
+ ------------------------------
7
+
8
+ * Add support for `eval` upload parameter
9
+ * Add support for 32-char signature length
10
+
11
+ Other Changes
12
+ -------------
13
+
14
+ * Fix escaping of query string characters in CarrierWave integration
15
+ * Fix detection integration test
16
+ * Integrate with sub-account test service
17
+ * Add pull request template
18
+
2
19
  1.16.1 / 2020-07-06
3
20
  ===================
4
21
 
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
 
34
34
  s.add_development_dependency "sqlite3"
35
35
  s.add_development_dependency "rspec", '>=3.5'
36
+ s.add_development_dependency "rspec-retry"
36
37
  s.add_development_dependency "rails", "~>5.2" if RUBY_VERSION >= "2.2.2"
37
38
 
38
39
  s.add_development_dependency "railties", "<= 4.2.7" if RUBY_VERSION <= "1.9.3"
@@ -4,7 +4,8 @@ module Cloudinary::CarrierWave
4
4
  if respond_to?(:process_uri)
5
5
  uri = process_uri(uri)
6
6
  else # Backward compatibility with old CarrierWave
7
- uri = URI.parse(Cloudinary::Utils.smart_escape(Cloudinary::Utils.smart_unescape(uri)))
7
+ remote_url_unsafe_chars = /([^a-zA-Z0-9_.\-\/:?&=]+)/ # In addition allow query string characters: "?","&" and "="
8
+ uri = URI.parse(Cloudinary::Utils.smart_escape(Cloudinary::Utils.smart_unescape(uri), remote_url_unsafe_chars))
8
9
  end
9
10
  return if uri.to_s.blank?
10
11
  self.original_filename = @cache_id = @filename = File.basename(uri.path).gsub(/[^a-zA-Z0-9\.\-\+_]/, '')
@@ -37,6 +37,7 @@ class Cloudinary::Uploader
37
37
  :eager_async => Cloudinary::Utils.as_safe_bool(options[:eager_async]),
38
38
  :eager_notification_url => options[:eager_notification_url],
39
39
  :exif => Cloudinary::Utils.as_safe_bool(options[:exif]),
40
+ :eval => options[:eval],
40
41
  :face_coordinates => Cloudinary::Utils.encode_double_array(options[:face_coordinates]),
41
42
  :faces => Cloudinary::Utils.as_safe_bool(options[:faces]),
42
43
  :folder => options[:folder],
@@ -141,6 +141,9 @@ class Cloudinary::Utils
141
141
 
142
142
  REMOTE_URL_REGEX = %r(^ftp:|^https?:|^s3:|^gs:|^data:([\w-]+\/[\w-]+(\+[\w-]+)?)?(;[\w-]+=[\w-]+)*;base64,([a-zA-Z0-9\/+\n=]+)$)
143
143
 
144
+ LONG_URL_SIGNATURE_LENGTH = 32
145
+ SHORT_URL_SIGNATURE_LENGTH = 8
146
+
144
147
  def self.extract_config_params(options)
145
148
  options.select{|k,v| URL_KEYS.include?(k)}
146
149
  end
@@ -497,6 +500,7 @@ class Cloudinary::Utils
497
500
  url_suffix = options.delete(:url_suffix)
498
501
  use_root_path = config_option_consume(options, :use_root_path)
499
502
  auth_token = config_option_consume(options, :auth_token)
503
+ long_url_signature = config_option_consume(options, :long_url_signature)
500
504
  unless auth_token == false
501
505
  auth_token = Cloudinary::AuthToken.merge_auth_token(Cloudinary.config.auth_token, auth_token)
502
506
  end
@@ -541,7 +545,7 @@ class Cloudinary::Utils
541
545
  raise(CloudinaryException, "Must supply api_secret") if (secret.nil? || secret.empty?)
542
546
  to_sign = [transformation, sign_version && version, source_to_sign].reject(&:blank?).join("/")
543
547
  to_sign = fully_unescape(to_sign)
544
- signature = 's--' + Base64.urlsafe_encode64(Digest::SHA1.digest(to_sign + secret))[0,8] + '--'
548
+ signature = compute_signature(to_sign, secret, long_url_signature)
545
549
  end
546
550
 
547
551
  prefix = unsigned_download_url_prefix(source, cloud_name, private_cdn, cdn_subdomain, secure_cdn_subdomain, cname, secure, secure_distribution)
@@ -1132,4 +1136,24 @@ class Cloudinary::Utils
1132
1136
  def self.is_remote?(url)
1133
1137
  REMOTE_URL_REGEX === url
1134
1138
  end
1139
+
1140
+ # Computes a short or long signature based on a message and secret
1141
+ # @param [String] message The string to sign
1142
+ # @param [String] secret A secret that will be added to the message when signing
1143
+ # @param [Boolean] long_signature Whether to create a short or long signature
1144
+ # @return [String] Properly formatted signature
1145
+ def self.compute_signature(message, secret, long_url_signature)
1146
+ combined_message_secret = message + secret
1147
+
1148
+ algo, signature_length =
1149
+ if long_url_signature
1150
+ [Digest::SHA256, LONG_URL_SIGNATURE_LENGTH]
1151
+ else
1152
+ [Digest::SHA1, SHORT_URL_SIGNATURE_LENGTH]
1153
+ end
1154
+
1155
+ "s--#{Base64.urlsafe_encode64(algo.digest(combined_message_secret))[0, signature_length]}--"
1156
+ end
1157
+
1158
+ private_class_method :compute_signature
1135
1159
  end
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.16.1"
3
+ VERSION = "1.17.0"
4
4
  end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ API_ENDPOINT="https://sub-account-testing.cloudinary.com/create_sub_account"
4
+
5
+ SDK_NAME="${1}"
6
+
7
+ CLOUD_DETAILS=$(curl -sS -d "{\"prefix\" : \"${SDK_NAME}\"}" "${API_ENDPOINT}")
8
+
9
+ echo "${CLOUD_DETAILS}" | ruby -e "require 'json'; c=JSON.parse(ARGF.read)['payload']; puts 'cloudinary://' + c['cloudApiKey'] + ':'+ c['cloudApiSecret'] + '@' + c['cloudName']"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4
+
5
+ RUBY_VER=$(ruby -v | head -n 1 | cut -d ' ' -f 2);
6
+ SDK_VER=$(grep -oiP '(?<=VERSION = ")([a-zA-Z0-9\-.]+)(?=")' lib/cloudinary/version.rb)
7
+
8
+
9
+ bash "${DIR}"/allocate_test_cloud.sh "Ruby ${RUBY_VER} SDK ${SDK_VER}"
@@ -12,6 +12,8 @@ QUOTE=
12
12
 
13
13
  NEW_VERSION=
14
14
 
15
+ UPDATE_ONLY=false
16
+
15
17
  function echo_err
16
18
  {
17
19
  echo "$@" 1>&2;
@@ -23,6 +25,7 @@ function usage
23
25
  echo " -v | --version <version> set a new version"
24
26
  echo " -c | --current show current version"
25
27
  echo " -d | --dry-run print the commands without executing them"
28
+ echo " -u | --update-only only update the version"
26
29
  echo " -h | --help print this information and exit"
27
30
  echo
28
31
  echo "For example: $0 -v 1.2.3"
@@ -30,7 +33,7 @@ function usage
30
33
 
31
34
  function process_arguments
32
35
  {
33
- while [ "$1" != "" ]; do
36
+ while [[ "$1" != "" ]]; do
34
37
  case $1 in
35
38
  -v | --version )
36
39
  shift
@@ -53,6 +56,11 @@ function process_arguments
53
56
  echo "Dry Run"
54
57
  echo ""
55
58
  ;;
59
+ -u | --update-only )
60
+ UPDATE_ONLY=true
61
+ echo "Only update version"
62
+ echo ""
63
+ ;;
56
64
  -h | --help )
57
65
  usage; return 0
58
66
  ;;
@@ -72,7 +80,7 @@ function pushd
72
80
  # Intentionally make popd silent
73
81
  function popd
74
82
  {
75
- command popd "$@" > /dev/null
83
+ command popd > /dev/null
76
84
  }
77
85
 
78
86
  # Check if one version is less than or equal than other
@@ -82,7 +90,7 @@ function popd
82
90
  # ver_lte 1.2.4 1.2.3 && echo "yes" || echo "no" # no
83
91
  function ver_lte
84
92
  {
85
- [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
93
+ [[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]]
86
94
  }
87
95
 
88
96
  # Extract the last entry or entry for a given version
@@ -108,6 +116,10 @@ function verify_dependencies
108
116
  return 1
109
117
  fi
110
118
 
119
+ if [[ "${UPDATE_ONLY}" = true ]]; then
120
+ return 0;
121
+ fi
122
+
111
123
  if [[ -z "$(type -t git-changelog)" ]]
112
124
  then
113
125
  echo_err "git-extras packages is not installed."
@@ -127,25 +139,26 @@ function safe_replace
127
139
 
128
140
  grep -q "${old}" "${file}" || { echo_err "${old} was not found in ${file}"; return 1; }
129
141
 
130
- ${CMD_PREFIX} sed -E -i '.bak' "${QUOTE}s/${old}/${new}/${QUOTE}" "${file}"
142
+ ${CMD_PREFIX} sed -i.bak -e "${QUOTE}s/${old}/${new}/${QUOTE}" -- "${file}" && rm -- "${file}.bak"
131
143
  }
132
144
 
133
145
  function current_version
134
146
  {
135
- grep -oiP '(?<=VERSION = ")([0-9.]+[^ ]*)(?=")' lib/cloudinary/version.rb
147
+ grep -oiP '(?<=VERSION = ")([a-zA-Z0-9\-.]+)(?=")' lib/cloudinary/version.rb
136
148
  }
137
149
 
138
150
  function update_version
139
151
  {
140
- if [ -z "${NEW_VERSION}" ]; then
152
+ if [[ -z "${NEW_VERSION}" ]]; then
141
153
  usage; return 1
142
154
  fi
143
155
 
144
156
  # Enter git root
145
157
  pushd $(git rev-parse --show-toplevel)
158
+
146
159
  local current_version=$(current_version)
147
160
 
148
- if [ -z "${current_version}" ]; then
161
+ if [[ -z "${current_version}" ]]; then
149
162
  echo_err "Failed getting current version, please check directory structure and/or contact developer"
150
163
  return 1
151
164
  fi
@@ -166,12 +179,17 @@ function update_version
166
179
  lib/cloudinary/version.rb\
167
180
  || return 1
168
181
 
169
- ${CMD_PREFIX} git changelog -t ${NEW_VERSION} || true
182
+ if [[ "${UPDATE_ONLY}" = true ]]; then
183
+ popd;
184
+ return 0;
185
+ fi
186
+
187
+ ${CMD_PREFIX} git changelog -t "${NEW_VERSION}" || true
170
188
 
171
189
  echo ""
172
190
  echo "# After editing CHANGELOG.md, optionally review changes and issue these commands:"
173
191
  echo git add lib/cloudinary/version.rb CHANGELOG.md
174
- echo git commit -m \"Version ${NEW_VERSION}\"
192
+ echo git commit -m "\"Version ${NEW_VERSION}\""
175
193
  echo sed -e "'1,/^${NEW_VERSION//./\\.}/d'" \
176
194
  -e "'/^=/d'" \
177
195
  -e "'/^$/d'" \
@@ -180,7 +198,7 @@ function update_version
180
198
  \| git tag -a "'${NEW_VERSION}'" --file=-
181
199
 
182
200
  # Don't run those commands on dry run
183
- [ -n "${CMD_PREFIX}" ] && { popd; return 0; }
201
+ [[ -n "${CMD_PREFIX}" ]] && { popd; return 0; }
184
202
 
185
203
  echo ""
186
204
  read -p "Run the above commands automatically? (y/N): " confirm && [[ ${confirm} == [yY] || ${confirm} == [yY][eE][sS] ]] || { popd; return 0; }
@@ -197,6 +215,6 @@ function update_version
197
215
  popd
198
216
  }
199
217
 
218
+ process_arguments "$@"
200
219
  verify_dependencies
201
- process_arguments $*
202
220
  update_version
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.1
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nadav Soferman
8
8
  - Itai Lahan
9
9
  - Tal Lev-Ami
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-07-06 00:00:00.000000000 Z
13
+ date: 2020-08-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws_cf_signer
@@ -110,6 +110,20 @@ dependencies:
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: '3.5'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rspec-retry
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
113
127
  - !ruby/object:Gem::Dependency
114
128
  name: rails
115
129
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +191,7 @@ extra_rdoc_files: []
177
191
  files:
178
192
  - ".github/ISSUE_TEMPLATE/bug_report.md"
179
193
  - ".github/ISSUE_TEMPLATE/feature_request.md"
194
+ - ".github/pull_request_template.md"
180
195
  - ".gitignore"
181
196
  - ".rspec"
182
197
  - ".travis.yml"
@@ -222,6 +237,8 @@ files:
222
237
  - lib/cloudinary/video_helper.rb
223
238
  - lib/tasks/cloudinary/fetch_assets.rake
224
239
  - lib/tasks/cloudinary/sync_static.rake
240
+ - tools/allocate_test_cloud.sh
241
+ - tools/get_test_cloud.sh
225
242
  - tools/update_version
226
243
  - vendor/assets/html/cloudinary_cors.html
227
244
  - vendor/assets/javascripts/cloudinary/canvas-to-blob.min.js
@@ -239,7 +256,7 @@ homepage: http://cloudinary.com
239
256
  licenses:
240
257
  - MIT
241
258
  metadata: {}
242
- post_install_message:
259
+ post_install_message:
243
260
  rdoc_options: []
244
261
  require_paths:
245
262
  - lib
@@ -254,8 +271,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
271
  - !ruby/object:Gem::Version
255
272
  version: '0'
256
273
  requirements: []
257
- rubygems_version: 3.0.6
258
- signing_key:
274
+ rubygems_version: 3.1.4
275
+ signing_key:
259
276
  specification_version: 4
260
277
  summary: Client library for easily using the Cloudinary service
261
278
  test_files: []