Skip to content

Commit

Permalink
fix feed tests
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2325 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information
technoweenie committed Oct 4, 2006
1 parent faaf9bc commit 8d632b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Expand Up @@ -73,7 +73,7 @@ def comment_expiration_options

def sanitize_feed_content(html, sanitize_tables = false)
options = sanitize_tables ? {:tags => %w(table thead tfoot tbody td tr th)} : {}
returning h(white_list(html, options)) do |html|
returning h(white_list(html.strip, options)) do |html|
html.gsub! /&(#\d+);/ do |s|
"&#{$1};"
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/feed/_article.rxml
Expand Up @@ -16,7 +16,7 @@ xm.entry 'xml:base' => home_url do
end
unless article.body_html.blank?
xm << %{<content type="html">
#{sanitize_feed_content article.excerpt_html + article.body_html}
#{sanitize_feed_content [article.excerpt_html, article.body_html].compact * "\n"}
</content>}
end
end
6 changes: 3 additions & 3 deletions test/functional/feed_controller_test.rb
Expand Up @@ -96,12 +96,12 @@ def setup
end

specify "should not double escape html" do
text = @contents.first.get_text.to_s
assert text.starts_with("&lt;p&gt;quentin&#8217;s &#8220;welcome&#8221;"), "'#{text.inspect}' was double escaped"
text = @contents.first.get_text.to_s.strip
assert text.starts_with("welcome summary\n&lt;p&gt;quentin&#8217;s &#8220;welcome&#8221;"), "'#{text.inspect}' was double escaped"
end

specify "should sanitize content" do
text = @contents.first.get_text.to_s
text = @contents.first.get_text.to_s.strip
evil = "<script>hi</script><a onclick=\"foo\" href=\"#\">linkage</a></p>"
good = "&lt;script>hi&lt;/script><a href='#'>linkage</a></p>"
assert !text.ends_with(CGI::escapeHTML(evil)), "'#{text.inspect}' was not sanitized"
Expand Down

0 comments on commit 8d632b8

Please sign in to comment.