Skip to content

Commit 7a20455

Browse files
committed
Security: Escape more strings
The sqlite3_ruby database adapter does not correctly taint strings unless you first apply this patch: http://rubyforge.org/tracker/index.php?func=detail&aid=20325&group_id=254&atid=1045 With this patch applied, SafeERB finds more errors. These are now fixed. It would be highly desirable to update SafeERB and modify it for production use with Rails 2.2.
1 parent a83309d commit 7a20455

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

app/views/admin/articles/_article.rhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<tr class="<%= article.status %>" id="article_<%= article.id %>">
22
<td><%= image_tag "mephisto/icons/#{status_icon[article.status][1]}", :class => "#{status_icon[article.status][0]} icon", :title => "This article is #{article.status}", :alt => "#{article.status}" %></td>
3-
<td class="article_title"><%= link_to(article.title, {:action => 'edit', :id => article}) %></td>
3+
<td class="article_title"><%= link_to(h(article.title), {:action => 'edit', :id => article}) %></td>
44
<td class="ccount">
55
<% if article.comments.size == 0 %>
66
none

app/views/admin/articles/_shared_options.rhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<li>
66
<%= check_box_tag 'article[section_ids][]', section.id, @article.has_section?(section),
77
:id => "article_section_ids_#{section.id}" %>
8-
<label for="article_section_ids_<%= section.id %>"><%= section.name %></label>
8+
<label for="article_section_ids_<%= section.id %>"><%=h section.name %></label>
99
</li>
1010
<% end %>
1111
</ul>

app/views/admin/overview/_comment_event.rhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<% with_options :controller => 'articles', :id => event.article_id do |article| -%>
22
<li id="event-<%= event.id %>" class="event-comment<%= " shade" if shaded %>">
33
<div id="comment-<%= event.comment_id %>">
4-
<%= link_to event.article.title, :controller => 'articles', :action => 'comments', :id => event.article_id, :anchor => "comment-#{event.comment_id}" %> received a comment.
4+
<%= link_to h(event.article.title), :controller => 'articles', :action => 'comments', :id => event.article_id, :anchor => "comment-#{event.comment_id}" %> received a comment.
55

66
<span class="event-time"><%= event_time_for event, later %></span>
77
<% unless event.body.blank? -%>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<li class="event-revision<%= " shade" if shaded %>">
22
<span class="event-time"><%= event_time_for event, later %></span>
33
<%= link_to h(event.title), :controller => 'articles', :action => 'show', :id => event.article_id %> was created.
4-
<span class="meta">by <%= link_to who(event.user.login), :controller => 'users', :action => 'show', :id => event.user %></span>
5-
</li>
4+
<span class="meta">by <%= link_to h(who(event.user.login)), :controller => 'users', :action => 'show', :id => event.user %></span>
5+
</li>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<li class="event-article<%= " shade" if defined?(shaded) && shaded == true %>">
22
<span class="event-time"><%= event_time_for event, later %></span>
33
<%= link_to h(event.title), :controller => 'articles', :action => 'edit', :id => event.article_id %> was created.
4-
<span class="meta">by <%= link_to who(event.user.login), :controller => 'users', :action => 'show', :id => event.user %></span>
5-
</li>
4+
<span class="meta">by <%= link_to h(who(event.user.login)), :controller => 'users', :action => 'show', :id => event.user %></span>
5+
</li>

app/views/admin/overview/index.rhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<h3>Recent activity</h3>
5050
<ul class="slist" id="activity">
5151
<% @users.each do |user| -%>
52-
<li style="clear:right;"><%= avatar_for user %><%= link_to who(user.login), :controller => 'users', :action => 'show', :id => user %><br /> showed up <%=h distance_of_time_in_words_to_now(user.updated_at) %> ago</li>
52+
<li style="clear:right;"><%= avatar_for user %><%= link_to h(who(user.login)), :controller => 'users', :action => 'show', :id => user %><br /> showed up <%=h distance_of_time_in_words_to_now(user.updated_at) %> ago</li>
5353
<% end -%>
5454
</ul>
5555
</div>

app/views/admin/users/_user.rhtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<li id="<%= user.dom_id %>" class="clear<%= %( deleted) unless user.deleted_at.nil? %><%= %( selected) if @user == user %>" fsdfa>
22
<%= avatar_for user %>
3-
<h3><%= link_to user.login, :action => 'show', :id => user %></h3>
4-
<%= user.email %>
3+
<h3><%= link_to h(user.login), :action => 'show', :id => user %></h3>
4+
<%=h user.email %>
55
<% unless user.admin? || user == current_user -%>
66
<p>
77
<%= check_box_tag user.dom_id(:user_toggle), user.id, user.deleted_at.nil?, :onclick => "UserForm.toggle(this);" %>
@@ -13,4 +13,4 @@
1313
<%= image_tag 'mephisto/progress.gif', :size => '10x10', :style => 'display:none', :id => "#{user.dom_id}-progress" %>
1414
</p>
1515
<% end -%>
16-
</li>
16+
</li>

app/views/layouts/application.rhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<li><%= link_to 'Logout', { :controller => '/account', :action => 'logout' }, :method => :post %></li>
2727
</ul>
2828

29-
<h1><%= link_to "#{site.title} &mdash; Admin", { :controller => '/admin/overview' }, :title => "#{site.title} admin" %></h1>
29+
<h1><%= link_to "#{h site.title} &mdash; Admin", { :controller => '/admin/overview' }, :title => "#{site.title} admin" %></h1>
3030

3131
<!-- div.nav -->
3232
<div id="nav">

app/views/layouts/simple.rhtml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
<html xmlns="http://www.w3.org/1999/xhtml">
44
<head>
55
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6-
<title>Mephisto: <%= controller.controller_name %> Admin</title>
6+
<title>Mephisto: <%=h controller.controller_name %> Admin</title>
77
<%= stylesheet_link_tag 'mephisto/fullscreen' %>
88
<%= javascript_include_tag 'mephisto/prototype', 'mephisto/effects', 'mephisto/lowpro', 'mephisto/application' %>
99
<script type="text/javascript">Mephisto.root = '<%= relative_url_root %>';</script>
1010
</head>
11-
<body id="body-<%= controller.controller_name %>">
11+
<body id="body-<%=h controller.controller_name %>">
1212

1313
<!-- div.header -->
1414
<div id="header">
15-
<h1><%= link_to "#{site.title} &mdash; Admin", { :controller => '/admin/overview' }, :title => "#{site.title} admin" %></h1>
15+
<h1><%= link_to "#{h site.title} &mdash; Admin", { :controller => '/admin/overview' }, :title => "#{site.title} admin" %></h1>
1616
</div>
1717
<!-- /div.header -->
1818

1919
<div id="container">
2020

2121
<!-- div.content -->
2222
<div id="fullscreen">
23-
<div id="flash-errors" style="display: none;"><%= flash[:error] %></div>
24-
<div id="flash-notice" style="display:none"><%= flash[:notice] %></div>
23+
<div id="flash-errors" style="display: none;"><%=h flash[:error] %></div>
24+
<div id="flash-notice" style="display:none"><%=h flash[:notice] %></div>
2525

2626
<!-- div.left -->
2727
<div id="main">

0 commit comments

Comments
 (0)