Skip to content

Commit 75420d9

Browse files
authored
Merge commit from fork
Fix a few reflected XSS vulnerabilities
2 parents 6a4a722 + b0d288d commit 75420d9

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

app/controllers/todos_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,10 @@ def get_params_for_tag_view
863863
end
864864

865865
@single_tag = @tag_expr.size == 1 && @tag_expr[0].size == 1
866-
@tag_name = @tag_expr[0][0]
867-
@tag_title = @single_tag ? @tag_name : tag_title(@tag_expr)
866+
867+
# These are used in the templates, sanitise to prevent XSS.
868+
@tag_name = sanitize(@tag_expr[0][0])
869+
@tag_title = sanitize(@single_tag ? @tag_name : tag_title(@tag_expr))
868870
end
869871

870872
def filter_format_for_tag_view

app/views/layouts/application.html.erb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<%= javascript_include_tag "application" %>
88
<%= csrf_meta_tags %>
99
<script type="text/javascript">
10-
var SOURCE_VIEW = '<%=@source_view%>';
11-
var AUTH_TOKEN = '<%= raw(protect_against_forgery? ? form_authenticity_token.inspect : "") %>'
12-
var TAG_NAME = '<%= @tag_name ? @tag_name : "" %>'
13-
var GROUP_VIEW_BY = '<%= @group_view_by ? @group_view_by : "" %>'
10+
var SOURCE_VIEW = '<%=j @source_view %>';
11+
var AUTH_TOKEN = '<%=j raw(protect_against_forgery? ? form_authenticity_token.inspect : "") %>'
12+
var TAG_NAME = '<%=j @tag_name ? @tag_name : "" %>'
13+
var GROUP_VIEW_BY = '<%=j @group_view_by ? @group_view_by : "" %>'
1414
var defaultContexts = <%= default_contexts_for_autocomplete.html_safe rescue '{}' %>;
1515
var defaultTags = <%= default_tags_for_autocomplete.html_safe rescue '{}' %>;
16-
var dateFormat = '<%= date_format_for_date_picker %>';
17-
var weekStart = '<%= current_user.prefs.week_starts %>';
16+
var dateFormat = '<%=j date_format_for_date_picker %>';
17+
var weekStart = '<%=j current_user.prefs.week_starts %>';
1818
function relative_to_root(path) { return '<%= root_url %>'+path; };
1919
<% if current_user.prefs.refresh != 0 -%>
2020
setup_auto_refresh(<%= current_user.prefs["refresh"].to_i*60000 %>);

app/views/stats/show_selection_from_chart.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
unless @further
55
-%>
66
<%= raw t('stats.click_to_show_actions_from_week',
7-
:link => link_to("here", show_actions_from_chart_path(:id=>"#{params[:id]}_end", :index => params[:index])),
8-
:week => params[:index])
7+
:link => link_to("here", show_actions_from_chart_path(:id=>"#{params[:id].to_i}_end", :index => params[:index].to_i)),
8+
:week => params[:index].to_i)
99
-%>
1010
<%
1111
end

0 commit comments

Comments
 (0)