Files
sure/app/helpers/accounts_helper.rb
bugbug11111 86d92508cb fix(accounts): sanitize activity entry names for highlighting
* Updated the `highlight_activity_entry_name` method to escape HTML in activity entry names before highlighting. This change prevents potential XSS vulnerabilities and ensures safe rendering of user-generated content.
2026-05-05 12:07:04 +02:00

22 lines
741 B
Ruby

module AccountsHelper
ACTIVITY_HIGHLIGHT_MARKUP = '<span class="text-warning/80 font-medium underline decoration-warning/60 underline-offset-2">\1</span>'.freeze
def summary_card(title:, &block)
content = capture(&block)
render "accounts/summary_card", title: title, content: content
end
def sync_path_for(account)
# Always use the account sync path, which handles syncing all providers
sync_account_path(account)
end
def highlight_activity_entry_name(name, query = params.dig(:q, :search))
search = query.to_s.strip
return name if search.blank?
escaped_name = ERB::Util.html_escape(name.to_s)
highlight(escaped_name, search, highlighter: ACTIVITY_HIGHLIGHT_MARKUP, sanitize: false)
end
end