https://bugs.webkit.org/show_bug.cgi?id=104932
Reviewed by Eric Seidel.
Ruby 1.9 added the concept of string encodings, so the use of `match' with binary data
treats it as UTF-8. Forcing the png_bytes string to have the "binary" encoding avoids
this error.
* PrettyPatch/PrettyPatch.rb: Use force_encoding.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138585
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-12-30 Martin Robinson <mrobinson@igalia.com>
+
+ PrettyDiff.rb fails to render image diffs with Ruby 1.9.3p194
+ https://bugs.webkit.org/show_bug.cgi?id=104932
+
+ Reviewed by Eric Seidel.
+
+ Ruby 1.9 added the concept of string encodings, so the use of `match' with binary data
+ treats it as UTF-8. Forcing the png_bytes string to have the "binary" encoding avoids
+ this error.
+
+ * PrettyPatch/PrettyPatch.rb: Use force_encoding.
+
2012-12-06 Ojan Vafai <ojan@chromium.org>
Review page is super flakey now
end
def self.read_checksum_from_png(png_bytes)
+ # Ruby 1.9 added the concept of string encodings, so to avoid treating binary data as UTF-8,
+ # we can force the encoding to binary at this point.
+ if RUBY_VERSION >= "1.9"
+ png_bytes.force_encoding('binary')
+ end
match = png_bytes && png_bytes.match(/tEXtchecksum\0([a-fA-F0-9]{32})/)
match ? match[1] : nil
end