From c927fc8240242244a1bba971f55c3ec00d7c92e7 Mon Sep 17 00:00:00 2001 From: Denis Novikov Date: Sun, 1 Apr 2012 12:21:23 +0200 Subject: [PATCH 1/2] Force diff line to UTF-8 encoding to prevent 'incompatible character encodings' error while rendering text file diff in compare view. --- app/views/commits/_text_file.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml index 441bdf2c210..43947f987c4 100644 --- a/app/views/commits/_text_file.html.haml +++ b/app/views/commits/_text_file.html.haml @@ -4,14 +4,14 @@ - if type == "match" %td.old_line= "..." %td.new_line= "..." - %td.line_content.matched= line + %td.line_content.matched= line.force_encoding('UTF-8') - else %td.old_line = link_to raw(type == "new" ? " " : line_old), "##{line_code}", :id => line_code - if @comments_allowed = link_to "", "#", :class => "line_note_link", "line_code" => line_code, :title => "Add note for this line" %td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", :id => line_code - %td.line_content{:class => "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line}  " + %td.line_content{:class => "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line.force_encoding('UTF-8')}  " - if @comments_allowed - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse -- GitLab From 1e1c43fe998c9a6d7ccf1a983808c573e7071012 Mon Sep 17 00:00:00 2001 From: Denis Novikov Date: Sun, 1 Apr 2012 19:04:02 +0200 Subject: [PATCH 2/2] Since we can have a submodule commited it's better to ensure we are actually have methods we're going to call. --- app/views/commits/_diffs.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml index 29eae1c43c7..292dcdef0a5 100644 --- a/app/views/commits/_diffs.html.haml +++ b/app/views/commits/_diffs.html.haml @@ -15,9 +15,9 @@ %strong{:id => "#{diff.b_path}"}= diff.b_path %br/ .diff_file_content - - if file.text? + - if defined? file.text and file.text? = render "commits/text_file", :diff => diff, :index => i - - elsif file.image? + - elsif defined? file.image and file.image? .diff_file_content_image %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - else -- GitLab