Skip to content

Commit

Permalink
h() escaping some more stuff - better solution would be to make mock_…
Browse files Browse the repository at this point in the history
…model taint all of it's strings automatically
  • Loading branch information
xaviershay committed Nov 6, 2008
1 parent 427bf7a commit 524e187
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/helpers/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def post_path(post, options = {})
suffix = options[:anchor] ? "##{options[:anchor]}" : ""
path = post.published_at.strftime("/%Y/%m/%d/") + post.slug + suffix
path = URI.join(config[:url], path) if options[:only_path] == false
path
path.untaint
end

def post_comments_path(post)
Expand All @@ -36,9 +36,9 @@ def page_path(page)

def author_link(comment)
if comment.author_url.blank?
comment.author
h(comment.author)
else
link_to(comment.author, comment.author_url, :title => "Authenticated by #{comment.author_openid_authority}", :class => 'openid')
link_to(h(comment.author), h(comment.author_url), :title => h("Authenticated by #{comment.author_openid_authority}"), :class => 'openid')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/views/posts/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:title => "A post",
:body_html => "Posts contents!",
:published_at => 1.year.ago,
:slug => 'a-post',
:slug => 'a-post'.taint,
:approved_comments => [mock_model(Comment)],
:tags => [mock_tag]
)
Expand Down
15 changes: 11 additions & 4 deletions spec/views/posts/show.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@

mock_comment = mock_model(Comment,
:created_at => 1.month.ago,
:author => "Don Alias",
:author_url => "http://enkiblog.com",
:author_openid_authority => "http://enkiblog.com/server",
:author => "Don Alias".taint,
:author_url => "http://enkiblog.com".taint,
:author_openid_authority => "http://enkiblog.com/server".taint,
:body_html => "A comment"
)

mock_comment2 = mock_model(Comment,
:created_at => 1.month.ago,
:author => "Don Alias".taint,
:author_url => ''.taint,
:body_html => "A comment"
)

Expand All @@ -21,7 +28,7 @@
:body_html => "Posts contents!",
:published_at => 1.year.ago,
:slug => 'a-post',
:approved_comments => [mock_comment],
:approved_comments => [mock_comment, mock_comment2],
:tags => [mock_tag]
)
assigns[:post] = @post
Expand Down

0 comments on commit 524e187

Please sign in to comment.