From: Tom Hughes Date: Fri, 13 Nov 2020 15:13:37 +0000 (+0000) Subject: Fix HTML escaping issues with user role icons X-Git-Tag: live~2391 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/99e537859a813edbcbf4ce94eae69f33f6361e22 Fix HTML escaping issues with user role icons --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 406a13265..c1060cbe2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -172,9 +172,3 @@ Style/FrozenStringLiteralComment: # Configuration parameters: Strict. Style/NumericLiterals: MinDigits: 11 - -# Offense count: 19 -# Cop supports --auto-correct. -Style/StringConcatenation: - Exclude: - - 'test/helpers/user_roles_helper_test.rb' diff --git a/app/helpers/user_roles_helper.rb b/app/helpers/user_roles_helper.rb index 384fb7280..79e7cc012 100644 --- a/app/helpers/user_roles_helper.rb +++ b/app/helpers/user_roles_helper.rb @@ -1,8 +1,6 @@ module UserRolesHelper def role_icons(user) - UserRole::ALL_ROLES.reduce("".html_safe) do |acc, elem| - "#{acc} #{role_icon(user, elem)}" - end + safe_join(UserRole::ALL_ROLES.collect { |role| role_icon(user, role) }.compact, " ") end def role_icon(user, role) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 440d68874..694f561b2 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -2,7 +2,7 @@
<%= user_image @user %>
-

<%= @user.display_name %><%= role_icons(@user) %>

+

<%= @user.display_name %> <%= role_icons(@user) %>

<% if current_user and @user.id == current_user.id %>