Skip to content

Commit

Permalink
m9(xss)<pgr
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyoshikawa committed Mar 1, 2010
1 parent 0403662 commit d68b9ea
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions sample2/app.rb
Expand Up @@ -10,6 +10,9 @@
end

helpers do
include Rack::Utils
alias_method :h, :escape_html

def user_authentication
return if session[:ssid].nil?
@user = User.first(:session => {:id => session[:ssid], :expired_at.gte => Time.now})
Expand Down
2 changes: 1 addition & 1 deletion sample2/models.rb
Expand Up @@ -22,7 +22,7 @@ def timeline
def self.password_crypt(plain_text)
Digest::SHA1.hexdigest(PASSWORD_SALT + plain_text)
end

def password=(plain_text)
attribute_set(:password, User.password_crypt(plain_text))
end
Expand Down
8 changes: 4 additions & 4 deletions sample2/views/index.erb
Expand Up @@ -5,7 +5,7 @@
</p>
<% else %>
<h2>
こんにちわ!<%= @user.name %>さん
こんにちわ!<%= h @user.name %>さん
</h2>
<div id="follow">
フォローしている(<%= @user.followings.count %>)/フォローされている(<%= @user.followers.count %>)
Expand All @@ -15,7 +15,7 @@
</p>
<div id="current_user">
<% @current_users.each do |user| %>
<a href="<%= user.name %>"><%= user.name %></a>
<a href="<%= h user.name %>"><%= h user.name %></a>
<% end %>
</div>
<h3>
Expand All @@ -33,10 +33,10 @@
<% @user.timeline.each do |user, tweet| %>
<tr>
<td>
<a href="<%= user.name %>"><%= user.name %></a>
<a href="<%= h user.name %>"><%= h user.name %></a>
</td>
<td>
<%= tweet.body %>
<%= h tweet.body %>
</td>
<td>
<%= tweet.created_at %>
Expand Down
8 changes: 4 additions & 4 deletions sample2/views/user.erb
@@ -1,12 +1,12 @@
<p>
<%= @someone.name %>さんの最近のつぶやきです
<%= h @someone.name %>さんの最近のつぶやきです
</p>
<% if login? && @someone.name != @user.name %>
<div id="follow">
<% unless @followed %>
<a href="/<%= @someone.name %>/follow">フォローする</a>
<a href="/<%= h @someone.name %>/follow">フォローする</a>
<% else %>
<a href="/<%= @someone.name %>/remove">リムーブする</a>
<a href="/<%= h @someone.name %>/remove">リムーブする</a>
<% end %>
</div>
<% end %>
Expand All @@ -16,7 +16,7 @@
<% @someone.tweets.each do |tweet| %>
<tr>
<td>
<%= tweet.body %>
<%= h tweet.body %>
</td>
<td>
<%= tweet.created_at %>
Expand Down

0 comments on commit d68b9ea

Please sign in to comment.