]> source.dussan.org Git - redmine.git/commitdiff
Rails3: prevent double rendering file view and annotate on Rails 3.0.11 and Rails...
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sat, 25 Feb 2012 06:01:48 +0000 (06:01 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sat, 25 Feb 2012 06:01:48 +0000 (06:01 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8988 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
app/views/common/_file.html.erb
app/views/repositories/annotate.html.erb

index 8d08e9d5b76e4f8a5b3d45dc05ec078866c5f5a1..8a4d387adaae122985cfb4cf24931ba01b72e034 100644 (file)
@@ -355,6 +355,12 @@ module ApplicationHelper
     end
   end
 
+  def syntax_highlight_lines(name, content)
+    lines = []
+    syntax_highlight(name, content).each_line { |line| lines << line }
+    lines
+  end
+
   def syntax_highlight(name, content)
     Redmine::SyntaxHighlighting.highlight_by_filename(content, name)
   end
index 418073efae2388e50d4b851c7fb7e4acf034fff1..22126b949dc0e24ba406c0e848fea8cb9184b7e7 100644 (file)
@@ -2,13 +2,13 @@
 <table class="filecontent syntaxhl">
 <tbody>
 <% line_num = 1 %>
-<% syntax_highlight(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each_line do |line| %>
+<% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %>
   <tr>
     <th class="line-num" id="L<%= line_num %>">
       <a href="#L<%= line_num %>"><%= line_num %></a>
     </th>
     <td class="line-code">
-      <pre><%= line %></pre>
+      <pre><%= line.html_safe %></pre>
     </td>
   </tr>
   <% line_num += 1 %>
index 188d9215dd2fbf0cb6e01110bd9eda50c78af203..1cd782588fa3c97d7b2e5d44cde0d2bbf594a390 100644 (file)
 <table class="filecontent annotate syntaxhl">
   <tbody>
     <% line_num = 1 %>
-    <% syntax_highlight(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each_line do |line| %>
+    <% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %>
       <% revision = @annotate.revisions[line_num - 1] %>
       <tr class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>">
         <th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th>
         <td class="revision">
         <%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision %></td>
         <td class="author"><%= h(revision.author.to_s.split('<').first) if revision %></td>
-        <td class="line-code"><pre><%= line %></pre></td>
+        <td class="line-code"><pre><%= line.html_safe %></pre></td>
       </tr>
       <% line_num += 1 %>
     <% end %>