Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
Fix a few reflected XSS vulnerabilities
  • Loading branch information
ZeiP authored Jul 25, 2024
2 parents 6a4a722 + b0d288d commit 75420d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions app/controllers/todos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,10 @@ def get_params_for_tag_view
end

@single_tag = @tag_expr.size == 1 && @tag_expr[0].size == 1
@tag_name = @tag_expr[0][0]
@tag_title = @single_tag ? @tag_name : tag_title(@tag_expr)

# These are used in the templates, sanitise to prevent XSS.
@tag_name = sanitize(@tag_expr[0][0])
@tag_title = sanitize(@single_tag ? @tag_name : tag_title(@tag_expr))
end

def filter_format_for_tag_view
Expand Down
12 changes: 6 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<script type="text/javascript">
var SOURCE_VIEW = '<%=@source_view%>';
var AUTH_TOKEN = '<%= raw(protect_against_forgery? ? form_authenticity_token.inspect : "") %>'
var TAG_NAME = '<%= @tag_name ? @tag_name : "" %>'
var GROUP_VIEW_BY = '<%= @group_view_by ? @group_view_by : "" %>'
var SOURCE_VIEW = '<%=j @source_view %>';
var AUTH_TOKEN = '<%=j raw(protect_against_forgery? ? form_authenticity_token.inspect : "") %>'
var TAG_NAME = '<%=j @tag_name ? @tag_name : "" %>'
var GROUP_VIEW_BY = '<%=j @group_view_by ? @group_view_by : "" %>'
var defaultContexts = <%= default_contexts_for_autocomplete.html_safe rescue '{}' %>;
var defaultTags = <%= default_tags_for_autocomplete.html_safe rescue '{}' %>;
var dateFormat = '<%= date_format_for_date_picker %>';
var weekStart = '<%= current_user.prefs.week_starts %>';
var dateFormat = '<%=j date_format_for_date_picker %>';
var weekStart = '<%=j current_user.prefs.week_starts %>';
function relative_to_root(path) { return '<%= root_url %>'+path; };
<% if current_user.prefs.refresh != 0 -%>
setup_auto_refresh(<%= current_user.prefs["refresh"].to_i*60000 %>);
Expand Down
4 changes: 2 additions & 2 deletions app/views/stats/show_selection_from_chart.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
unless @further
-%>
<%= raw t('stats.click_to_show_actions_from_week',
:link => link_to("here", show_actions_from_chart_path(:id=>"#{params[:id]}_end", :index => params[:index])),
:week => params[:index])
:link => link_to("here", show_actions_from_chart_path(:id=>"#{params[:id].to_i}_end", :index => params[:index].to_i)),
:week => params[:index].to_i)
-%>
<%
end
Expand Down

0 comments on commit 75420d9

Please sign in to comment.