Skip to content
Browse files

changed spec: SuperPre#to_html escape content in itself, not using es…

…caped parameters
  • Loading branch information...
1 parent ed9c509 commit f2612c537609796245ba7c1908555c3db04719ef @takahashim takahashim committed May 10, 2010
Showing with 7 additions and 4 deletions.
  1. +1 −1 lib/hparser/block/super_pre.rb
  2. +4 −1 lib/hparser/html.rb
  3. +2 −2 test/test_block.rb
View
2 lib/hparser/block/super_pre.rb
@@ -21,7 +21,7 @@ def self.parse scanner,inlines
end
if content then
- SuperPre.new content.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;"), format
+ SuperPre.new content, format
end
end
View
5 lib/hparser/html.rb
@@ -80,7 +80,10 @@ def html_tag() 'pre' end
class SuperPre
include Html
- private
+ def to_html
+ content = html_content.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
+ %(<#{html_tag}>#{content}</#{html_tag}>)
+ end
def html_tag() 'pre' end
alias_method :html_content,:content
end
View
4 test/test_block.rb
@@ -75,7 +75,7 @@ def test_spre
end
def test_spre_html
- assert_equal [SuperPre.new('&lt;foo /&gt;')],parse(<<-END)
+ assert_equal [SuperPre.new('<foo />')],parse(<<-END)
>||
<foo />
||<
@@ -84,7 +84,7 @@ def test_spre_html
end
def test_spre_format
- assert_equal [SuperPre.new('&lt;foo /&gt;')],parse(<<-END)
+ assert_equal [SuperPre.new('<foo />')],parse(<<-END)
>|xml|
<foo />
||<

0 comments on commit f2612c5

Please sign in to comment.
Something went wrong with that request. Please try again.