Skip to content

Commit

Permalink
Compare copyright prefix in a more encoding safe way
Browse files Browse the repository at this point in the history
id is a ASCII-8BIT string but the literal "\xa9" could be
UTF-8 string which in that case Ruby won't conceder them equal.
This is probably because "\xa9" is an invalid UTF-8 string etc.

"\xa9".force_encoding(Encoding::ASCII_8BIT) == "\xa9".force_encoding(Encoding::UTF_8) => false
  • Loading branch information
wader committed Oct 23, 2013
1 parent 9d9f8ef commit a6dd4e1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mp4info.rb
Expand Up @@ -155,7 +155,7 @@ def parse_atom(io_stream, level, parent_size)
raise "Parse error"
end

if id.unpack("M")[0][0] == "\xA9"
if id[0].ord == 0xa9
# strip copyright sign at the beginning
id = id[1..-1]
end
Expand Down

0 comments on commit a6dd4e1

Please sign in to comment.