Commit f2deec2f authored by mrobinson@webkit.org's avatar mrobinson@webkit.org

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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138585 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6f05b8a6
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
......
......@@ -676,6 +676,11 @@ EOF
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment