Skip to content

Commit fb67d21

Browse files
committed
More sanitization
1 parent e041bce commit fb67d21

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

app/helpers/application_helper.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def signup_js
245245

246246
def twitter_link(username)
247247
link_to("http://twitter.com/#{username}", target: '_blank', rel: 'noopener') do
248-
"<i class='fa fa-twitter'></i> @#{username}".html_safe
248+
content_tag(:i, nil, class: 'fa fa-twitter') + "@#{username}"
249249
end
250250
end
251251

@@ -256,7 +256,8 @@ def info_button(title, opts = {}, &block)
256256
content_tag(:a, tabindex: 0, class: classes,
257257
data: { toggle: 'popover', placement: 'bottom',
258258
title:, html: true, content: capture(&block) }) do
259-
"<i class='icon icon-md information-icon'></i> <span class='hidden-xs'>#{title_text}</span>".html_safe
259+
content_tag(:i, nil, class: 'icon icon-md information-icon') +
260+
content_tag(:span, title_text, class: 'hidden-xs')
260261
end
261262
end
262263

@@ -301,7 +302,7 @@ def tab(text, icon, href, disabled: { check: false }, active: false, count: nil,
301302
text << " (#{count})" if count
302303

303304
link_to("##{href}", options) do
304-
%(<i class="#{icon}" aria-hidden="true"></i> #{text}).html_safe
305+
content_tag(:i, nil, class: icon, 'aria-hidden': 'true') + ' ' + text
305306
end
306307
end
307308
end
@@ -333,9 +334,9 @@ def format_for_dropdown(collection)
333334

334335
def title_with_privacy(resource)
335336
html = resource.title
336-
html += " #{icon_for(:private, nil, class: 'muted')}" unless resource.public
337+
html = safe_join([html + ' ', icon_for(:private, nil, class: 'muted')]) unless resource.public
337338

338-
html.html_safe
339+
html
339340
end
340341

341342
ActionView::Helpers::FormBuilder.class_eval do
@@ -463,7 +464,7 @@ def star_button(resource)
463464

464465
def external_link_button(text, url, options = {})
465466
options.reverse_merge!({ class: 'btn btn-primary' })
466-
text = (text + ' <i class="icon icon-md arrow-top-right-white-icon"></i>').html_safe
467+
text = safe_join([text, '<i class="icon icon-md arrow-top-right-white-icon"></i>'.html_safe])
467468
external_link(text, url, options)
468469
end
469470

0 commit comments

Comments
 (0)