Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switching from shellwords to manual escaping (Win support).

  • Loading branch information...
commit 9c219396ea43dd65ac0fe86be4029fafd3681b82 1 parent 6da0938
@janfri authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/mini_exiftool.rb
View
8 lib/mini_exiftool.rb
@@ -18,7 +18,6 @@
require 'pstore'
require 'rational'
require 'set'
-require 'shellwords'
require 'time'
# Simple OO access to the Exiftool command-line application.
@@ -90,7 +89,7 @@ def load filename
opt_params << (@composite ? '' : '-e ')
opt_params << (@convert_encoding ? '-L ' : '')
opt_params << (@coord_format ? "-c \"#{@coord_format}\"" : '')
- cmd = %Q(#@@cmd -q -q -s -t #{opt_params} #{@@sep_op} #{Shellwords.escape(filename)})
+ cmd = %Q(#@@cmd -q -q -s -t #{opt_params} #{@@sep_op} #{MiniExiftool.escape(filename)})
if run(cmd)
parse_output
else
@@ -162,7 +161,7 @@ def save
arr_val.map! {|e| convert e}
tag_params = ''
arr_val.each do |v|
- tag_params << %Q(-#{original_tag}=#{Shellwords.escape(v.to_s)} )
+ tag_params << %Q(-#{original_tag}=#{MiniExiftool.escape(v)} )
end
opt_params = ''
opt_params << (arr_val.detect {|x| x.kind_of?(Numeric)} ? '-n ' : '')
@@ -442,6 +441,9 @@ def self.determine_tags arg
tags
end
+ def self.escape(val)
+ '"' << val.to_s.gsub(/\\/, '\\'*4).gsub(/"/, '\"') << '"'
+ end
# Hash with indifferent access:
# DateTimeOriginal == datetimeoriginal == date_time_original
Please sign in to comment.
Something went wrong with that request. Please try again.