Skip to content

Commit 7c0a37c

Browse files
committed
Removed a number of uses of html_safe to ensure unsafe input can't get through
1 parent e8fa409 commit 7c0a37c

File tree

17 files changed

+35
-30
lines changed

17 files changed

+35
-30
lines changed

app/helpers/home_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def sort_by_duration
2727
#----------------------------------------------------------------------------
2828
def sort_by_users
2929
users = [[ "all_users", t(:option_all_users) ]] + @all_users.map do |user|
30-
escaped = escape_javascript(user.full_name)
30+
escaped = sanitize(user.full_name)
3131
[ escaped, escaped ]
3232
end
3333

app/mailers/subscription_mailer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Fat Free CRM is freely distributable under the terms of MIT license.
44
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
55
#------------------------------------------------------------------------------
6+
67
class SubscriptionMailer < ActionMailer::Base
78

89
def comment_notification(user, comment)

app/models/polymorphic/task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Task < ActiveRecord::Base
6363
where('user_id = ? OR assigned_to = ?', user.id, user.id)
6464
}
6565

66-
# Show opportunities which either belong to the user and are unassigned, or are assigned to the user
66+
# Show tasks which either belong to the user and are unassigned, or are assigned to the user
6767
scope :visible_on_dashboard, ->(user) {
6868
where('(user_id = :user_id AND assigned_to IS NULL) OR assigned_to = :user_id', :user_id => user.id).where('completed_at IS NULL')
6969
}

app/views/entities/_basic_search.html.haml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
%div{ :style => "margin: 0px 0px 6px 0px" }
66
= text_field_tag('query', @current_query, :size => 32, :placeholder => "Search #{controller_name}")
77
%span.sorting_options
8-
-# sort_by_displaying: Sort {{models}} by {{field}} displaying first name {{position}} last name.
9-
= t(:sort_by, :models => t(:"#{controller_name}_small"), :field => link_to(current_sort_by, "#", :id => :sort_by)).html_safe
8+
= t(:sort_by, :field => link_to(h(current_sort_by), "#", :id => :sort_by)).html_safe
109

1110
:javascript
1211
var searchTimeout;

app/views/fields/_group_view.html.haml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
%tr
55
- group.each do |field|
66
= col(field.label, field.render_value(entity), (i == groups.size - 1) ? :last : nil)
7-
= "<th class='last'></th><td class='last'></td>".html_safe if group.size == 1
7+
- if group.size == 1
8+
%th.last
9+
%td.last

app/views/home/_activity.html.haml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- user = link_to(h(activity.user.full_name), user_path(activity.user)) if activity.user
1+
- user = link_to(activity.user.full_name, user_path(activity.user)) if activity.user
22

33
- subject = if (item = activity.related || activity.item)
44
- if item.respond_to?(:full_name)
@@ -22,12 +22,14 @@
2222
- action = t('action_' + activity.event)
2323
- type = t('subject_' + activity.item_type.downcase)
2424
= link_to avatar_for(activity.user, :size => :thumb), user_path(activity.user)
25-
= t("activity_text", :user => user, :action => action, :type => type, :subject => subject, :default => "#{user} #{action} #{type} #{subject}").html_safe # locales optionally can change the word order for activities using 'activity_text'
25+
= t("activity_text", :user => h(user), :action => h(action), :type => h(type), :subject => h(subject), :default => "#{h user} #{h action} #{h type} #{h subject}").html_safe # locales optionally can change the word order for activities using 'activity_text'
2626
- if ((item = activity.item).class == Comment) and Setting.comments_visible_on_dashboard
2727
= t('action_create_comment', :comment => truncate(h(item.comment), :length => 90)).html_safe
2828
- else
2929
- type = t(activity.item_type.downcase)
3030
- if item.respond_to? :email
3131
= avatar_for(item, :size => "16x16")
32-
= "#{type} #{subject}:".html_safe
33-
= auto_link(t(activity.event)).html_safe
32+
= type
33+
= subject
34+
= ":"
35+
= auto_link(t(activity.event))

app/views/home/_options.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
= hidden_field_tag "account[user_id]", current_user.id
44

55
-# activity_options: Show %{models} %{action_type} performed by %{user} in the past %{period}
6-
= t(:activity_options, :models => link_to(t(@asset).singularize.downcase, "#", :id => :asset), :action_type => link_to(t(@action + "_past_participle").downcase, "#", :id => :event), :user => link_to(t(@user), "#", :id => :user), :period => link_to(t(@duration).downcase, "#", :id => :duration)).html_safe
6+
= t(:activity_options, :models => link_to(t(h(@asset)).singularize.downcase, "#", :id => :asset), :action_type => link_to(t(h(@action) + "_past_participle").downcase, "#", :id => :event), :user => link_to(t(h(@user)), "#", :id => :user), :period => link_to(t(h(@duration)).downcase, "#", :id => :duration)).html_safe
77

88
%script
99
= render "assets_menu"

app/views/home/_task.html.haml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
.indent
77
%label{ :id => dom_id(task, :name) }
88
- if task.user.id != current_user.id
9-
= t(:task_from, link_to(task.user.full_name, user_path(task.user))).html_safe << ':'
10-
= link_to(h(task.name), tasks_path)
9+
= t(:task_from, link_to(h(task.user.full_name), user_path(task.user))).html_safe << ':'
10+
= link_to(task.name, tasks_path)
1111
- if task.asset_id?
12-
== #{t :related} #{link_to(h(task.asset.name), polymorphic_url(task.asset))}
12+
== #{t :related} #{link_to(task.asset.name, polymorphic_url(task.asset))}
1313
&ndash;
1414
%tt
1515
- if task.bucket == "due_asap"
@@ -45,4 +45,4 @@
4545

4646
- unless task.background_info.blank?
4747
%div
48-
%dt= h(task.background_info)
48+
%dt= auto_link(simple_format task.background_info)

app/views/home/_users_menu.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
fade : 500,
55
appear : 500,
66
width : 180,
7-
menu_items: [ #{sort_by_users.join(",")} ]
7+
menu_items: [ #{sort_by_users.join(',')} ]
88
});

app/views/leads/_sidebar_show.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
- unless @lead.background_info.blank?
5656
.caption #{t :background_info}
57-
= auto_link(simple_format @lead.background_info).html_safe
57+
= auto_link(simple_format @lead.background_info)
5858

5959
= render "fields/sidebar_show", :asset => @lead
6060

0 commit comments

Comments
 (0)