Skip to content
This repository
Browse code

Fix rubyforge bug [#29596], Quotes in values.

  • Loading branch information...
commit 36950ac88dc0d3851d77387aac44240e8b357cd9 1 parent 63f3007
janfri authored May 30, 2012
2  lib/mini_exiftool.rb
@@ -154,7 +154,7 @@ def save
154 154
       arr_val.map! {|e| convert e}
155 155
       tag_params = ''
156 156
       arr_val.each do |v|
157  
-        tag_params << %Q(-#{original_tag}="#{v}" )
  157
+        tag_params << %Q(-#{original_tag}=#{Shellwords.escape(v)} )
158 158
       end
159 159
       opt_params = ''
160 160
       opt_params << (arr_val.detect {|x| x.kind_of?(Numeric)} ? '-n ' : '')
22  test/test_write.rb
@@ -55,6 +55,28 @@ def test_access_non_writable_tags
55 55
     assert_equal true, @mini_exiftool_num.changed?
56 56
   end
57 57
 
  58
+  # Catching rubyforge bug [#29596]
  59
+  # Thanks to Michael Grove for reporting
  60
+  # Part 1
  61
+  def test_quotes_in_values
  62
+    caption = "\"String in quotes\""
  63
+    @mini_exiftool.caption = caption
  64
+    assert_equal true, @mini_exiftool.save, 'Saving error'
  65
+    @mini_exiftool.reload
  66
+    assert_equal caption, @mini_exiftool.caption
  67
+  end
  68
+
  69
+  # Catching rubyforge bug [#29596]
  70
+  # Thanks to Michael Grove for reporting
  71
+  # Part 2
  72
+  def test_quotes_and_apostrophe_in_values
  73
+    caption = caption = "\"Watch your step, it's slippery.\""
  74
+    @mini_exiftool.caption = caption
  75
+    assert_equal true, @mini_exiftool.save, 'Saving error'
  76
+    @mini_exiftool.reload
  77
+    assert_equal caption, @mini_exiftool.caption
  78
+  end
  79
+
58 80
   def test_time_conversion
59 81
     t = Time.now
60 82
     @mini_exiftool_num['DateTimeOriginal'] = t

0 notes on commit 36950ac

Please sign in to comment.
Something went wrong with that request. Please try again.