mini_exiftool 2.14.0 → 2.15.0

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +4 -0
  3. data/Tutorial.md +1 -1
  4. data/lib/mini_exiftool.rb +24 -35
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2eb71098832b8fa3c931588d9b35ced2a05241d3f88abd85eccd9b0404c7bbe2
4
- data.tar.gz: 2deb86595f46b8a4a13e026ff54754b915723a24730a9d4c5bccf66054f50e1b
3
+ metadata.gz: 69630b2ee9bc16842745fc2a1d95dbe94a0a17304a1604f7187d5336b60afa7d
4
+ data.tar.gz: bcb202b7810e4605f4d8838ce67c835135a8ae84cd5c8d7cd12cb535a8ffd239
5
5
  SHA512:
6
- metadata.gz: edb5a2802070c2e99f9222d3b3c55fc22f546f793258f501d70fed4655036cf81bbae4f0e4ba635d19be2268f14c3f879004481ee3fe5d072af90291b734435a
7
- data.tar.gz: 2dbd2e65dfbbf3711f8b2910a0a956324fb4ffd95add844b50fce2786198ab910e52d9ef04a521b8ae216f8594691b1f60b2c31044bab4e11bd6c92b5d43f904
6
+ metadata.gz: 41d98a19c65f0910939f844ffd8fdcbbd2c45bff1631b7f71f242b99e3b58e0438878318c675887f74735b79d2b74fbcb9f93fcab29463cb0491b49ab1874af2
7
+ data.tar.gz: a16989012b6ea0bd5e718dc2d4b07ae9046ef8f1ef4614c0fb5cde36673aac819c32143cc3a9f58f21cd14046a57527650c75441259bb6469734d2efdb3bb26c
data/Changelog CHANGED
@@ -1,3 +1,7 @@
1
+ 2.15.0
2
+ - Fix security issue using string concatenation with Open3. Thanks to Sang
3
+ Nguyễn for reporting.
4
+
1
5
  2.14.0
2
6
  - Change default pstore_dir to subdir in Gem.cache_home or under USERPROFILE
3
7
  or Dir.tmpdir if some not defined. So it's now XDG conform and also Ruby
data/Tutorial.md CHANGED
@@ -147,7 +147,7 @@ puts photo['ISO']
147
147
 
148
148
  The kind of the parameter `filename_or_io` is determined via duck typing:
149
149
  if the argument responds to `to_str` it is interpreted as filename, if it
150
- responds to `read` it is interpreted es IO instance.
150
+ responds to `read` it is interpreted as IO instance.
151
151
  Attention: If you use an IO instance then writing of values is not supported!
152
152
 
153
153
  Look at the show_speedup_with_fast_option example in the MiniExiftool examples
data/lib/mini_exiftool.rb CHANGED
@@ -29,7 +29,7 @@ require 'yaml'
29
29
  # Simple OO access to the ExifTool command-line application.
30
30
  class MiniExiftool
31
31
 
32
- VERSION = '2.14.0'
32
+ VERSION = '2.15.0'
33
33
 
34
34
  # Name of the ExifTool command-line application
35
35
  @@cmd = 'exiftool'
@@ -149,13 +149,13 @@ class MiniExiftool
149
149
  end
150
150
  @values.clear
151
151
  @changed_values.clear
152
- params = '-j '
153
- params << (@opts[:numerical] ? '-n ' : '')
154
- params << (@opts[:composite] ? '' : '-e ')
155
- params << (@opts[:coord_format] ? "-c #{escape(@opts[:coord_format])}" : '')
156
- params << (@opts[:fast] ? '-fast ' : '')
157
- params << (@opts[:fast2] ? '-fast2 ' : '')
158
- params << generate_encoding_params
152
+ params = %w(-j)
153
+ params << '-n' if @opts[:numerical]
154
+ params << '-e' unless @opts[:composite]
155
+ params << '-c' << @opts[:coord_format] if @opts[:coord_format]
156
+ params << '-fast' if @opts[:fast]
157
+ params << '-fast2' if @opts[:fast2]
158
+ params += generate_encoding_params
159
159
  if run(cmd_gen(params, @filename))
160
160
  parse_output
161
161
  else
@@ -227,12 +227,12 @@ class MiniExiftool
227
227
  original_tag = MiniExiftool.original_tag(tag)
228
228
  arr_val = val.kind_of?(Array) ? val : [val]
229
229
  arr_val.map! {|e| convert_before_save(e)}
230
- params = '-q -P -overwrite_original '
231
- params << (arr_val.detect {|x| x.kind_of?(Numeric)} ? '-n ' : '')
232
- params << (@opts[:ignore_minor_errors] ? '-m ' : '')
233
- params << generate_encoding_params
230
+ params = %w(-q -P -overwrite_original)
231
+ params << '-n' if arr_val.detect {|x| x.kind_of?(Numeric)}
232
+ params << '-m' if @opts[:ignore_minor_errors]
233
+ params += generate_encoding_params
234
234
  arr_val.each do |v|
235
- params << %Q(-#{original_tag}=#{escape(v)} )
235
+ params << "-#{original_tag}=#{v}"
236
236
  end
237
237
  result = run(cmd_gen(params, temp_filename))
238
238
  unless result
@@ -263,11 +263,10 @@ class MiniExiftool
263
263
  unless File.exist?(source_filename)
264
264
  raise MiniExiftool::Error.new("Source file #{source_filename} does not exist!")
265
265
  end
266
- params = '-q -P -overwrite_original '
267
- tags_params = Array(tags).map {|t| '-' << t.to_s}.join(' ')
268
- cmd = [@@cmd, params, '-tagsFromFile', escape(source_filename).encode(@@fs_enc), tags_params.encode('UTF-8'), escape(filename).encode(@@fs_enc)].join(' ')
269
- cmd.force_encoding('UTF-8')
270
- result = run(cmd)
266
+ params = %w(-q -P -overwrite_original -tagsFromFile)
267
+ params << source_filename.to_s.encode(@@fs_enc)
268
+ params += Array(tags).map {|t| "-#{t}"}
269
+ result = run(cmd_gen(params, filename))
271
270
  reload
272
271
  result
273
272
  end
@@ -351,7 +350,7 @@ class MiniExiftool
351
350
 
352
351
  # Returns the version of the ExifTool command-line application.
353
352
  def self.exiftool_version
354
- Open3.popen3 "#{MiniExiftool.command} -ver" do |_inp, out, _err, _thr|
353
+ Open3.popen3(MiniExiftool.command, '-ver') do |_inp, out, _err, _thr|
355
354
  out.read.chomp!
356
355
  end
357
356
  rescue SystemCallError
@@ -391,15 +390,15 @@ class MiniExiftool
391
390
  private
392
391
  ############################################################################
393
392
 
394
- def cmd_gen arg_str='', filename
395
- [+@@cmd, arg_str.encode('UTF-8'), escape(filename.encode(@@fs_enc))].map {|s| s.force_encoding('UTF-8')}.join(' ')
393
+ def cmd_gen arg_arr=[], filename
394
+ [@@cmd, *arg_arr.map {|s| s.encode('UTF-8')}, filename.encode(@@fs_enc)]
396
395
  end
397
396
 
398
397
  def run cmd
399
398
  if $DEBUG
400
- $stderr.puts cmd
399
+ $stderr.puts cmd.inspect
401
400
  end
402
- status = Open3.popen3(cmd) do |inp, out, err, thr|
401
+ status = Open3.popen3(*cmd) do |inp, out, err, thr|
403
402
  if @io
404
403
  begin
405
404
  IO.copy_stream @io, inp
@@ -542,21 +541,11 @@ class MiniExiftool
542
541
  tags
543
542
  end
544
543
 
545
- if @@running_on_windows
546
- def escape val
547
- '"' << val.to_s.gsub(/([\\"`])/, "\\\\\\1") << '"'
548
- end
549
- else
550
- def escape val
551
- '"' << val.to_s.gsub(/([\\"$`])/, "\\\\\\1") << '"'
552
- end
553
- end
554
-
555
544
  def generate_encoding_params
556
- params = ''
545
+ params = []
557
546
  @@encoding_types.each do |enc_type|
558
547
  if enc_val = @opts[MiniExiftool.encoding_opt(enc_type)]
559
- params << "-charset #{enc_type}=#{enc_val} "
548
+ params << '-charset' << "#{enc_type}=#{enc_val}"
560
549
  end
561
550
  end
562
551
  params
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_exiftool
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Friedrich
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ostruct
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  requirements:
145
145
  - exiftool, version >= 7,65
146
- rubygems_version: 3.7.0.dev
146
+ rubygems_version: 4.0.6
147
147
  specification_version: 4
148
148
  summary: This library is a wrapper for the ExifTool command-line application (https://exiftool.org).
149
149
  test_files: []