active_encode 1.1.1 → 1.1.2

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: e5072c5649f874b8c8c99bd14560479b662a9b0c6cee42d02769f41ac0da1cde
4
- data.tar.gz: cccb1ee9a220eade7333a523564bb621120154eb4b591c0fa0ba406c712530d8
3
+ metadata.gz: aae1d452186e5101e0e42b4211fd25da561b068caee41d8839f019067309048a
4
+ data.tar.gz: d54cc90a08b0907885281ada0ad0c8a62aae0806213b36010282e279f85803bc
5
5
  SHA512:
6
- metadata.gz: 9d99535227987a68561b3bf14ee8703cae691baa438d1f37a2cc2f72c31389b59ed2bec7f8136ee99d472e645b906fa48e31fad3ea23ea3942e09b9b6f1d5910
7
- data.tar.gz: 3e02c5b00f1cf201dcefb913203d3649385cb250b77424d030fb1692bfbe7943fe7ff6f1f289a57a076dd10f965ebd918183788efccf0ea199520320a614df60
6
+ metadata.gz: c1080a31e991e8784dcbf9a8b1f7740fedf299a3eb5075d3ff9f665589fe0f73560679f592f3e97925a9424277a6e12a845187501858d520e2564f3e2a078302
7
+ data.tar.gz: 77f94da2c42eeaff56e9298138b1c04a5a79a7fc7b256bd6fa65ba691cb25b3b216dd1cfbad414ad22f3180aceb934a07518a0a2fb062ce63dc8c6f37a3ab6e1
data/.circleci/config.yml CHANGED
@@ -10,7 +10,7 @@ jobs:
10
10
  type: string
11
11
  bundler_version:
12
12
  type: string
13
- default: 2.0.2
13
+ default: 2.4.5
14
14
  ffmpeg_version:
15
15
  type: string
16
16
  default: 4.1.4
@@ -63,27 +63,31 @@ jobs:
63
63
  workflows:
64
64
  ci:
65
65
  jobs:
66
+ - bundle_and_test:
67
+ name: "ruby3-2_rails7-0"
68
+ ruby_version: "3.2.0"
69
+ rails_version: "7.0.4.2"
70
+ - bundle_and_test:
71
+ name: "ruby3-1_rails7-0"
72
+ ruby_version: "3.1.3"
73
+ rails_version: "7.0.4.2"
66
74
  - bundle_and_test:
67
75
  name: "ruby3-0_rails7-0"
68
- ruby_version: "3.0.3"
69
- rails_version: "7.0.1"
76
+ ruby_version: "3.0.5"
77
+ rails_version: "7.0.4.2"
70
78
  - bundle_and_test:
71
79
  name: "ruby3-0_rails6-1"
72
- ruby_version: "3.0.3"
73
- rails_version: "6.1.4.4"
80
+ ruby_version: "3.0.5"
81
+ rails_version: "6.1.7.2"
74
82
  - bundle_and_test:
75
83
  name: "ruby3-0_rails6-0"
76
- ruby_version: "3.0.3"
77
- rails_version: "6.0.4.4"
84
+ ruby_version: "3.0.5"
85
+ rails_version: "6.0.6.1"
78
86
  - bundle_and_test:
79
87
  name: "ruby2-7_rails6-0"
80
- ruby_version: "2.7.5"
81
- rails_version: "6.0.4.4"
88
+ ruby_version: "2.7.7"
89
+ rails_version: "6.0.6.1"
82
90
  - bundle_and_test:
83
91
  name: "ruby2-7_rails5-2"
84
- ruby_version: "2.7.5"
85
- rails_version: "5.2.6"
86
- - bundle_and_test:
87
- name: "ruby2-6_rails5-2"
88
- ruby_version: "2.6.9"
89
- rails_version: "5.2.6"
92
+ ruby_version: "2.7.7"
93
+ rails_version: "5.2.8.1"
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ["lib"]
22
+ spec.metadata = { "rubygems_mfa_required" => "true" }
22
23
 
23
24
  spec.add_dependency "rails"
24
25
  spec.add_dependency "addressable", "~> 2.8"
@@ -44,7 +44,11 @@ module ActiveEncode
44
44
  else
45
45
  ""
46
46
  end
47
- `#{MEDIAINFO_PATH} #{curl_option} --Output=XML --LogFile=#{working_path("input_metadata", new_encode.id)} "#{input_url}"`
47
+
48
+ clean_url = input_url.is_a?(String) ? ActiveEncode.sanitize_uri(input_url) : input_url
49
+
50
+ `#{MEDIAINFO_PATH} #{curl_option} --Output=XML --LogFile=#{working_path("input_metadata", new_encode.id)} "#{clean_url}"`
51
+
48
52
  new_encode.input = build_input new_encode
49
53
 
50
54
  if new_encode.input.duration.blank?
@@ -19,6 +19,7 @@ module ActiveEncode
19
19
  def create(input_url, options = {})
20
20
  # Decode file uris for ffmpeg (mediainfo works either way)
21
21
  input_url = Addressable::URI.unencode(input_url) if input_url.starts_with? "file:///"
22
+ input_url = ActiveEncode.sanitize_input(input_url)
22
23
 
23
24
  new_encode = ActiveEncode::Base.new(input_url, options)
24
25
  new_encode.id = SecureRandom.uuid
@@ -30,7 +31,7 @@ module ActiveEncode
30
31
  FileUtils.mkdir_p working_path("outputs", new_encode.id)
31
32
 
32
33
  # Extract technical metadata from input file
33
- `#{MEDIAINFO_PATH} --Output=XML --LogFile=#{working_path("input_metadata", new_encode.id)} #{input_url.shellescape}`
34
+ `#{MEDIAINFO_PATH} --Output=XML --LogFile=#{working_path("input_metadata", new_encode.id)} "#{ActiveEncode.sanitize_uri(input_url)}"`
34
35
  new_encode.input = build_input new_encode
35
36
  new_encode.input.id = new_encode.id
36
37
  new_encode.created_at, new_encode.updated_at = get_times new_encode.id
@@ -196,7 +197,7 @@ module ActiveEncode
196
197
 
197
198
  # Extract technical metadata from output file
198
199
  metadata_path = working_path("output_metadata-#{output.label}", id)
199
- `#{MEDIAINFO_PATH} --Output=XML --LogFile=#{metadata_path} #{output.url}` unless File.file? metadata_path
200
+ `#{MEDIAINFO_PATH} --Output=XML --LogFile=#{metadata_path} #{ActiveEncode.sanitize_uri(output.url)}` unless File.file? metadata_path
200
201
  output.assign_tech_metadata(get_tech_metadata(metadata_path))
201
202
 
202
203
  outputs << output
@@ -18,5 +18,14 @@ module ActiveEncode
18
18
  # Replace special characters with underscores and remove excess periods.
19
19
  File.basename(filepath).gsub(/[^0-9A-Za-z.\-\/]/, '_').gsub(/\.(?=.*\.)/, '')
20
20
  end
21
+
22
+ def sanitize_uri(input_url)
23
+ case input_url
24
+ when /^file\:\/\/\//
25
+ input_url.to_s.gsub(/file:\/\//, '')
26
+ when /^s3\:\/\//
27
+ input_url.to_s.gsub(/#{input_url.normalized_site}/, '')
28
+ end
29
+ end
21
30
  end
22
31
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveEncode
3
- VERSION = '1.1.1'
3
+ VERSION = '1.1.2'
4
4
  end
data/lib/file_locator.rb CHANGED
@@ -11,7 +11,7 @@ class FileLocator
11
11
  def initialize(uri)
12
12
  uri = Addressable::URI.parse(uri)
13
13
  @bucket = Addressable::URI.unencode(uri.host)
14
- @key = Addressable::URI.unencode(uri.path).sub(%r{^/*(.+)/*$}, '\1')
14
+ @key = Addressable::URI.unencode(ActiveEncode.sanitize_uri(uri)).sub(%r{^/*(.+)/*$}, '\1')
15
15
  end
16
16
 
17
17
  def object
@@ -51,7 +51,7 @@ class FileLocator
51
51
  when 's3'
52
52
  S3File.new(uri).object.presigned_url(:get)
53
53
  when 'file'
54
- Addressable::URI.unencode(uri.path)
54
+ Addressable::URI.unencode(ActiveEncode.sanitize_uri(uri))
55
55
  else
56
56
  @uri.to_s
57
57
  end
@@ -159,8 +159,8 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
159
159
  end
160
160
  context "when filename has special characters" do
161
161
  context "non-s3 file" do
162
- let(:input) { ["'file_with_single_quote'.mp4", '"file_with_double_quote".mp4', "file with space.mp4", "file.with...periods.mp4", "file.with :=+%sp3c!l-ch4cts().mp4"] }
163
- let(:clean) { ["_file_with_single_quote_.mp4", "_file_with_double_quote_.mp4", "file_with_space.mp4", "filewithperiods.mp4", "filewith_____sp3c_l-ch4cts__.mp4"] }
162
+ let(:input) { ["'file_with_single_quote'.mp4", '"file_with_double_quote".mp4', "file with space.mp4", "file.with...periods.mp4", "file.with :=+%sp3c!l-ch4cts().mp4", '@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov'] }
163
+ let(:clean) { ["_file_with_single_quote_.mp4", "_file_with_double_quote_.mp4", "file_with_space.mp4", "filewithperiods.mp4", "filewith_____sp3c_l-ch4cts__.mp4", '__________________________________.mov'] }
164
164
  let(:source_bucket) { "bucket1" }
165
165
 
166
166
  it "calls the #upload_to_s3 method" do
@@ -171,8 +171,8 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
171
171
  end
172
172
  end
173
173
  context "s3 file" do
174
- let(:input_urls) { ["s3://bucket1/'file_with_single_quote'.mp4", 's3://bucket1/"file_with_double_quote".mp4', "s3://bucket1/file with space.mp4", "s3://bucket1/file.with...periods.mp4", "s3://bucket1/file.with :=+%sp3c!l-ch4cts().mp4"] }
175
- let(:clean) { ["_file_with_single_quote_.mp4", "_file_with_double_quote_.mp4", "file_with_space.mp4", "filewithperiods.mp4", "filewith_____sp3c_l-ch4cts__.mp4"] }
174
+ let(:input_urls) { ["s3://bucket1/'file_with_single_quote'.mp4", 's3://bucket1/"file_with_double_quote".mp4', "s3://bucket1/file with space.mp4", "s3://bucket1/file.with...periods.mp4", "s3://bucket1/file.with :=+%sp3c!l-ch4cts().mp4", 's3://bucket1/@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov'] }
175
+ let(:clean) { ["_file_with_single_quote_.mp4", "_file_with_double_quote_.mp4", "file_with_space.mp4", "filewithperiods.mp4", "filewith_____sp3c_l-ch4cts__.mp4", '__________________________________.mov'] }
176
176
  let(:source_bucket) { "bucket2" }
177
177
 
178
178
  it "calls the #check_s3_bucket method" do
@@ -224,34 +224,44 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
224
224
  let(:file_with_special_characters) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'file.with :=+%sp3c!l-ch4cts().mp4').to_s }
225
225
  let!(:create_special_characters_job) { ActiveEncode::Base.create(file_with_special_characters, outputs: [{ label: "low", ffmpeg_opt: "-s 640x480", extension: 'mp4' }]) }
226
226
  let(:find_special_characters_job) { ActiveEncode::Base.find create_special_characters_job.id }
227
+ let(:file_with_more_special_characters) { "file://" + Rails.root.join('..', 'spec', 'fixtures', '@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov').to_s }
228
+ let!(:create_more_special_characters_job) { ActiveEncode::Base.create(file_with_more_special_characters, outputs: [{ label: "low", ffmpeg_opt: "-s 640x480", extension: 'mp4' }]) }
229
+ let(:find_more_special_characters_job) { ActiveEncode::Base.find create_more_special_characters_job.id }
227
230
 
228
231
  it "does not have errors" do
229
232
  sleep 2
230
233
  expect(find_special_characters_job.errors).to be_empty
234
+ expect(find_more_special_characters_job.errors).to be_empty
231
235
  end
232
236
 
233
237
  it "has the input technical metadata in a file" do
234
238
  expect(File.read("#{work_dir}/#{create_special_characters_job.id}/input_metadata")).not_to be_empty
239
+ expect(File.read("#{work_dir}/#{create_more_special_characters_job.id}/input_metadata")).not_to be_empty
235
240
  end
236
241
 
237
242
  it "has the pid in a file" do
238
243
  expect(File.read("#{work_dir}/#{create_special_characters_job.id}/pid")).not_to be_empty
244
+ expect(File.read("#{work_dir}/#{create_more_special_characters_job.id}/pid")).not_to be_empty
239
245
  end
240
246
 
241
247
  context 'when uri encoded' do
242
248
  let(:file_with_special_characters) { Addressable::URI.encode("file://" + Rails.root.join('..', 'spec', 'fixtures', 'file.with :=+%sp3c!l-ch4cts().mp4').to_s) }
249
+ let(:file_with_more_special_characters) { Addressable::URI.encode("file://" + Rails.root.join('..', 'spec', 'fixtures', '@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov').to_s) }
243
250
 
244
251
  it "does not have errors" do
245
252
  sleep 2
246
253
  expect(find_special_characters_job.errors).to be_empty
254
+ expect(find_more_special_characters_job.errors).to be_empty
247
255
  end
248
256
 
249
257
  it "has the input technical metadata in a file" do
250
258
  expect(File.read("#{work_dir}/#{create_special_characters_job.id}/input_metadata")).not_to be_empty
259
+ expect(File.read("#{work_dir}/#{create_more_special_characters_job.id}/input_metadata")).not_to be_empty
251
260
  end
252
261
 
253
262
  it "has the pid in a file" do
254
263
  expect(File.read("#{work_dir}/#{create_special_characters_job.id}/pid")).not_to be_empty
264
+ expect(File.read("#{work_dir}/#{create_more_special_characters_job.id}/pid")).not_to be_empty
255
265
  end
256
266
  end
257
267
  end
@@ -293,8 +293,8 @@ describe ActiveEncode::EngineAdapters::MediaConvertAdapter do
293
293
  end
294
294
  context "when filename has special characters" do
295
295
  context "non-s3 file" do
296
- let(:input) { ["'file_with_single_quote'.mp4", '"file_with_double_quote".mp4', "file with space.mp4", "file.with...periods.mp4", "file.with :=+%sp3c!l-ch4cts().mp4"] }
297
- let(:clean) { ["_file_with_single_quote_.mp4", "_file_with_double_quote_.mp4", "file_with_space.mp4", "filewithperiods.mp4", "filewith_____sp3c_l-ch4cts__.mp4"] }
296
+ let(:input) { ["'file_with_single_quote'.mp4", '"file_with_double_quote".mp4', "file with space.mp4", "file.with...periods.mp4", "file.with :=+%sp3c!l-ch4cts().mp4", '@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov'] }
297
+ let(:clean) { ["_file_with_single_quote_.mp4", "_file_with_double_quote_.mp4", "file_with_space.mp4", "filewithperiods.mp4", "filewith_____sp3c_l-ch4cts__.mp4", '__________________________________.mov'] }
298
298
  let(:source_bucket) { "bucket1" }
299
299
 
300
300
  it "calls the #upload_to_s3 method" do
@@ -305,8 +305,8 @@ describe ActiveEncode::EngineAdapters::MediaConvertAdapter do
305
305
  end
306
306
  end
307
307
  context "s3 file" do
308
- let(:input_urls) { ["s3://bucket1/'file_with_single_quote'.mp4", 's3://bucket1/"file_with_double_quote".mp4', "s3://bucket1/file with space.mp4", "s3://bucket1/file.with...periods.mp4", "s3://bucket1/file.with :=+%sp3c!l-ch4cts().mp4"] }
309
- let(:clean) { ["_file_with_single_quote_.mp4", "_file_with_double_quote_.mp4", "file_with_space.mp4", "filewithperiods.mp4", "filewith_____sp3c_l-ch4cts__.mp4"] }
308
+ let(:input_urls) { ["s3://bucket1/'file_with_single_quote'.mp4", 's3://bucket1/"file_with_double_quote".mp4', "s3://bucket1/file with space.mp4", "s3://bucket1/file.with...periods.mp4", "s3://bucket1/file.with :=+%sp3c!l-ch4cts().mp4", 's3://bucket1/@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov'] }
309
+ let(:clean) { ["_file_with_single_quote_.mp4", "_file_with_double_quote_.mp4", "file_with_space.mp4", "filewithperiods.mp4", "filewith_____sp3c_l-ch4cts__.mp4", '__________________________________.mov'] }
310
310
  let(:source_bucket) { "bucket2" }
311
311
 
312
312
  it "calls the #check_s3_bucket method" do
@@ -198,25 +198,35 @@ describe ActiveEncode::EngineAdapters::PassThroughAdapter do
198
198
  let(:file_with_special_characters_derivative) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'file.with :=+%sp3c!l-ch4cts().mp4').to_s }
199
199
  let!(:create_special_characters_job) { ActiveEncode::Base.create(file_with_special_characters, outputs: [{ label: "low", url: file_with_special_characters_derivative }]) }
200
200
  let(:find_special_characters_job) { ActiveEncode::Base.find create_special_characters_job.id }
201
+ let(:file_with_more_special_characters) { "file://" + Rails.root.join('..', 'spec', 'fixtures', '@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov').to_s }
202
+ let(:file_with_more_special_characters_derivative) { "file://" + Rails.root.join('..', 'spec', 'fixtures', '@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov').to_s }
203
+ let!(:create_more_special_characters_job) { ActiveEncode::Base.create(file_with_more_special_characters, outputs: [{ label: "low", url: file_with_more_special_characters_derivative }]) }
204
+ let(:find_more_special_characters_job) { ActiveEncode::Base.find create_more_special_characters_job.id }
201
205
 
202
206
  it "does not have errors" do
203
207
  expect(find_special_characters_job.errors).to be_empty
208
+ expect(find_more_special_characters_job.errors).to be_empty
204
209
  end
205
210
 
206
211
  it "has the input technical metadata in a file" do
207
212
  expect(File.read("#{work_dir}/#{create_special_characters_job.id}/input_metadata")).not_to be_empty
213
+ expect(File.read("#{work_dir}/#{create_more_special_characters_job.id}/input_metadata")).not_to be_empty
208
214
  end
209
215
 
210
216
  context 'when uri encoded' do
211
217
  let(:file_with_special_characters) { Addressable::URI.encode("file://" + Rails.root.join('..', 'spec', 'fixtures', 'file.with :=+%sp3c!l-ch4cts().mp4').to_s) }
212
218
  let(:file_with_special_characters_derivative) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'file.with :=+%sp3c!l-ch4cts().mp4').to_s }
219
+ let(:file_with_more_special_characters) { Addressable::URI.encode("file://" + Rails.root.join('..', 'spec', 'fixtures', '@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov').to_s) }
220
+ let(:file_with_more_special_characters_derivative) { "file://" + Rails.root.join('..', 'spec', 'fixtures', '@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov').to_s }
213
221
 
214
222
  it "does not have errors" do
215
223
  expect(find_special_characters_job.errors).to be_empty
224
+ expect(find_more_special_characters_job.errors).to be_empty
216
225
  end
217
226
 
218
227
  it "has the input technical metadata in a file" do
219
228
  expect(File.read("#{work_dir}/#{create_special_characters_job.id}/input_metadata")).not_to be_empty
229
+ expect(File.read("#{work_dir}/#{create_more_special_characters_job.id}/input_metadata")).not_to be_empty
220
230
  end
221
231
  end
222
232
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_encode
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klein, Chris Colvard, Phuong Dinh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-05 00:00:00.000000000 Z
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -302,6 +302,8 @@ files:
302
302
  - spec/fixtures/"file_with_double_quote".mp4
303
303
  - spec/fixtures/'file_with_single_quote'.low.mp4
304
304
  - spec/fixtures/'file_with_single_quote'.mp4
305
+ - spec/fixtures/@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.low.mov
306
+ - spec/fixtures/@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov
305
307
  - spec/fixtures/Bars_512kb.mp4
306
308
  - spec/fixtures/elastic_transcoder/input_completed.json
307
309
  - spec/fixtures/elastic_transcoder/input_generic.json
@@ -429,7 +431,8 @@ files:
429
431
  homepage: https://github.com/samvera-labs/active_encode
430
432
  licenses:
431
433
  - Apache-2.0
432
- metadata: {}
434
+ metadata:
435
+ rubygems_mfa_required: 'true'
433
436
  post_install_message:
434
437
  rdoc_options: []
435
438
  require_paths:
@@ -455,6 +458,8 @@ test_files:
455
458
  - spec/fixtures/"file_with_double_quote".mp4
456
459
  - spec/fixtures/'file_with_single_quote'.low.mp4
457
460
  - spec/fixtures/'file_with_single_quote'.mp4
461
+ - spec/fixtures/@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.low.mov
462
+ - spec/fixtures/@ወዳጅህ ማር ቢ. ሆን ጨርስ. ህ አትላሰ!@#$^^&$%&.mov
458
463
  - spec/fixtures/Bars_512kb.mp4
459
464
  - spec/fixtures/elastic_transcoder/input_completed.json
460
465
  - spec/fixtures/elastic_transcoder/input_generic.json