From 9338f5d7609095a02cfc6f3b96b4c823efbc844e Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 26 Jun 2026 09:53:27 -0400 Subject: [PATCH] Add `inline_qrcode_svg` helper for confirmation page (#39633) --- app/helpers/settings_helper.rb | 6 ++++++ .../two_factor_authentication/confirmations/new.html.haml | 2 +- spec/helpers/settings_helper_spec.rb | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 11786b22fe7..6da714700b3 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -9,6 +9,12 @@ module SettingsHelper LanguagesHelper.sorted_locale_keys(I18n.available_locales) end + def inline_qrcode_svg(code) + code + .as_svg(padding: 0, module_size: 4, use_path: true) + .html_safe # rubocop:disable Rails/OutputSafety + end + def featured_tags_hint(recently_used_tags) recently_used_tags.present? && safe_join( diff --git a/app/views/settings/two_factor_authentication/confirmations/new.html.haml b/app/views/settings/two_factor_authentication/confirmations/new.html.haml index 2ce422e997a..89b1fb20d71 100644 --- a/app/views/settings/two_factor_authentication/confirmations/new.html.haml +++ b/app/views/settings/two_factor_authentication/confirmations/new.html.haml @@ -5,7 +5,7 @@ %p.hint= t('otp_authentication.instructions_html') .qr-wrapper - .qr-code!= @qrcode.as_svg(padding: 0, module_size: 4, use_path: true) + .qr-code= inline_qrcode_svg(@qrcode) .qr-alternative %p.hint= t('otp_authentication.manual_instructions') diff --git a/spec/helpers/settings_helper_spec.rb b/spec/helpers/settings_helper_spec.rb index d45940b57bb..4453dbe27d8 100644 --- a/spec/helpers/settings_helper_spec.rb +++ b/spec/helpers/settings_helper_spec.rb @@ -19,6 +19,14 @@ RSpec.describe SettingsHelper do end end + describe '#inline_qrcode_svg' do + subject { inline_qrcode_svg(code) } + + let(:code) { RQRCode::QRCode.new('https://host.example') } + + it { is_expected.to include('').and(be_html_safe) } + end + describe 'session_device_icon' do context 'with a mobile device' do let(:session) { SessionActivation.new(user_agent: 'Mozilla/5.0 (iPhone)') }