| |   |
| 81 | 81 | out << %Q{<td class="line-numbers">#{dst_sha}</td>} |
| 82 | 82 | out << "<td> </td></tr>\n" |
| 83 | 83 | out << "</thead>\n" |
| 84 | | out << Diff::Display::Unified::Renderer.run(udiff, callback) |
| 84 | out << Diff::Display::Unified::HTMLRenderer.run(udiff, callback) |
| 85 | 85 | out << "</table>" |
| 86 | 86 | out |
| 87 | 87 | end |
| … | … | |
| 93 | 93 | out << %Q{<colgroup class="right"><col class="lines"/><col class="code"/></colgroup>} |
| 94 | 94 | out << %Q{<thead><th colspan="2">#{src_sha}</th>} |
| 95 | 95 | out << %Q{<th colspan="2">#{dst_sha}</th></thead>} |
| 96 | | out << Diff::Display::Unified::Renderer.run(udiff, callback) |
| 96 | out << Diff::Display::Unified::HTMLRenderer.run(udiff, callback) |
| 97 | 97 | out << "</table>" |
| 98 | 98 | out |
| 99 | 99 | end |
| toggle raw diff |
--- a/app/helpers/browse_helper.rb
+++ b/app/helpers/browse_helper.rb
@@ -81,7 +81,7 @@ module BrowseHelper
out << %Q{<td class="line-numbers">#{dst_sha}</td>}
out << "<td> </td></tr>\n"
out << "</thead>\n"
- out << Diff::Display::Unified::Renderer.run(udiff, callback)
+ out << Diff::Display::Unified::HTMLRenderer.run(udiff, callback)
out << "</table>"
out
end
@@ -93,7 +93,7 @@ module BrowseHelper
out << %Q{<colgroup class="right"><col class="lines"/><col class="code"/></colgroup>}
out << %Q{<thead><th colspan="2">#{src_sha}</th>}
out << %Q{<th colspan="2">#{dst_sha}</th></thead>}
- out << Diff::Display::Unified::Renderer.run(udiff, callback)
+ out << Diff::Display::Unified::HTMLRenderer.run(udiff, callback)
out << "</table>"
out
end |
| |   |
| 56 | 56 | def before_remline(line) |
| 57 | 57 | # rems go on the left (hide the right side) |
| 58 | 58 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 59 | | %Q{<td class="code del"><del>#{line}</del></td>} + |
| 59 | %Q{<td class="code del"><del>#{CGI.escapeHTML(line)}</del></td>} + |
| 60 | 60 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 61 | 61 | %Q{<td class="code del hidden"><del>} |
| 62 | 62 | end |
| … | … | |
| 64 | 64 | def before_modline(line) |
| 65 | 65 | # TODO: figure how we best display these |
| 66 | 66 | # %Q{<th class="line-numbers">#{line.number}</th>} + |
| 67 | | # %Q{<td class="code changed mod">#{line}</td>} + |
| 67 | # %Q{<td class="code changed mod">#{CGI.escapeHTML(line)}</td>} + |
| 68 | 68 | # %Q{<th class="line-numbers">#{line.number}</th>} + |
| 69 | 69 | # %Q{<td class="code changed mod">} |
| 70 | 70 | end |
| … | … | |
| 72 | 72 | def before_unmodline(line) |
| 73 | 73 | # unmods goes on both sides |
| 74 | 74 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 75 | | %Q{<td class="code unchanged unmod">#{line}</td>} + |
| 75 | %Q{<td class="code unchanged unmod">#{CGI.escapeHTML(line)}</td>} + |
| 76 | 76 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 77 | 77 | %Q{<td class="code unchanged unmod">} |
| 78 | 78 | end |
| toggle raw diff |
--- a/lib/gitorious/diff/sidebyside_table_callback.rb
+++ b/lib/gitorious/diff/sidebyside_table_callback.rb
@@ -56,7 +56,7 @@ module Gitorious
def before_remline(line)
# rems go on the left (hide the right side)
%Q{<th class="line-numbers">#{line.number}</th>} +
- %Q{<td class="code del"><del>#{line}</del></td>} +
+ %Q{<td class="code del"><del>#{CGI.escapeHTML(line)}</del></td>} +
%Q{<th class="line-numbers">#{line.number}</th>} +
%Q{<td class="code del hidden"><del>}
end
@@ -64,7 +64,7 @@ module Gitorious
def before_modline(line)
# TODO: figure how we best display these
# %Q{<th class="line-numbers">#{line.number}</th>} +
- # %Q{<td class="code changed mod">#{line}</td>} +
+ # %Q{<td class="code changed mod">#{CGI.escapeHTML(line)}</td>} +
# %Q{<th class="line-numbers">#{line.number}</th>} +
# %Q{<td class="code changed mod">}
end
@@ -72,7 +72,7 @@ module Gitorious
def before_unmodline(line)
# unmods goes on both sides
%Q{<th class="line-numbers">#{line.number}</th>} +
- %Q{<td class="code unchanged unmod">#{line}</td>} +
+ %Q{<td class="code unchanged unmod">#{CGI.escapeHTML(line)}</td>} +
%Q{<th class="line-numbers">#{line.number}</th>} +
%Q{<td class="code unchanged unmod">}
end |
| |   |
| 528 | 528 | block_data << before_method(block) |
| 529 | 529 | # Block must use braces rather than do/end due to precedence rules! |
| 530 | 530 | block_data.concat block.inject([]) { |line_data, line| |
| 531 | | line_data << before_method(line) << line << after_method(line) |
| 531 | line_data << before_method(line) << escape(line) << after_method(line) |
| 532 | 532 | } |
| 533 | 533 | block_data << after_method(block) |
| 534 | 534 | end |
| … | … | |
| 543 | 543 | new(diff, callback_object).rendered |
| 544 | 544 | end |
| 545 | 545 | end |
| 546 | |
| 547 | def escape(text) |
| 548 | text |
| 549 | end |
| 546 | 550 | |
| 547 | 551 | private |
| 548 | 552 | |
| … | … | |
| 619 | 619 | end |
| 620 | 620 | #:startdoc:# |
| 621 | 621 | |
| 622 | | # XXX This doesn't make sense anymore...How to implement a convenient way |
| 623 | | # to redefine methods such as space and escape? |
| 624 | | # Mostly a convenience class at this point that just overwrites various |
| 625 | | # customization methods |
| 626 | | class HTMLGenerator < Generator #:nodoc:# |
| 622 | # Renders with HTML as the target output (only effect is escaped lines) |
| 623 | # callbacks will still need to escape any lines they output |
| 624 | class HTMLRenderer < Renderer #:nodoc:# |
| 627 | 625 | |
| 628 | | # This and the space method now don't work/make sense now that those |
| 629 | | # methods are part of the Line class and there certainly won't be an |
| 630 | | # HTMLLine class |
| 626 | # escapes |
| 631 | 627 | def escape(text) |
| 628 | #CGI::escapeHTML(text) |
| 632 | 629 | text.gsub('&', '&'). |
| 633 | 630 | gsub('<', '<' ). |
| 634 | 631 | gsub('>', '>' ). |
| 635 | 632 | gsub('"', '"') |
| 636 | 633 | end |
| 637 | | |
| 638 | | def space |
| 639 | | ' ' |
| 640 | | end |
| 641 | | |
| 642 | | end |
| 643 | | |
| 644 | | # How to implement this? See doc string for HTMLGenerator |
| 645 | | class ASCIIGenerator < Generator #:nodoc:# |
| 646 | 634 | end |
| 647 | 635 | |
| 648 | 636 | end |
| toggle raw diff |
--- a/vendor/diff-display/lib/diff/display/unified.rb
+++ b/vendor/diff-display/lib/diff/display/unified.rb
@@ -528,7 +528,7 @@ module Diff #:nodoc:#
block_data << before_method(block)
# Block must use braces rather than do/end due to precedence rules!
block_data.concat block.inject([]) { |line_data, line|
- line_data << before_method(line) << line << after_method(line)
+ line_data << before_method(line) << escape(line) << after_method(line)
}
block_data << after_method(block)
end
@@ -543,6 +543,10 @@ module Diff #:nodoc:#
new(diff, callback_object).rendered
end
end
+
+ def escape(text)
+ text
+ end
private
@@ -615,30 +619,18 @@ module Diff #:nodoc:#
end
#:startdoc:#
- # XXX This doesn't make sense anymore...How to implement a convenient way
- # to redefine methods such as space and escape?
- # Mostly a convenience class at this point that just overwrites various
- # customization methods
- class HTMLGenerator < Generator #:nodoc:#
+ # Renders with HTML as the target output (only effect is escaped lines)
+ # callbacks will still need to escape any lines they output
+ class HTMLRenderer < Renderer #:nodoc:#
- # This and the space method now don't work/make sense now that those
- # methods are part of the Line class and there certainly won't be an
- # HTMLLine class
+ # escapes
def escape(text)
+ #CGI::escapeHTML(text)
text.gsub('&', '&').
gsub('<', '<' ).
gsub('>', '>' ).
gsub('"', '"')
end
-
- def space
- ' '
- end
-
- end
-
- # How to implement this? See doc string for HTMLGenerator
- class ASCIIGenerator < Generator #:nodoc:#
end
end |