Skip to content

Instantly share code, notes, and snippets.

@abrader
Created June 1, 2011 21:51
Show Gist options
  • Save abrader/1003420 to your computer and use it in GitHub Desktop.
Save abrader/1003420 to your computer and use it in GitHub Desktop.
Brian Goetz fix for Iconv issue in wmainfo-rb
https://rubyforge.org/tracker/index.php?func=detail&aid=27639&group_id=1821&atid=7118
Here's a patch that fixes the error I just reported, where wmainfo barfs on construction if it cannot successfully convert
all the fields using iconv:
-- /usr/lib/ruby/gems/1.8/gems/wmainfo-rb-0.6/lib/wmainfo.rb 2009-12-29 00:50
:02.000000000 -0500
+++ wmainfo.rb 2009-12-29 23:56:19.000000000 -0500
@@ -235,7 +235,12 @@
lengths[key] = read_and_increment_offset(2).unpack("v")[0]
end
keys.each do |key| # now pull the data based on length
- @tags[key] = decode_binary_string(read_and_increment_offset(lengths[key])
)
+ begin
+ data = read_and_increment_offset(lengths[key])
+ @tags[key] = decode_binary_string(data)
+ rescue
+ @tags[key] = "Unavailable (iconv decode error)"
+ end
end
end
@@ -252,7 +257,11 @@
value = read_and_increment_offset(ext['value_length'])
if ext['value_type'] <= 1
+ begin
ext['value'] = decode_binary_string(value)
+ rescue
+ ext['value'] = "Unavailable (iconv decode error)"
+ end
elsif ext['value_type'] == 4
ext['value'] = parse_64bit_string(value)
else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment