A platform for community discussion. Free, open, simple.
FIX: Allow `target` attribute in translation overrides (#29503)
Martin Brennan254cf22559a4
diff --git a/app/models/translation_override.rb b/app/models/translation_override.rbindex 23129688b8c..bca5bbaeb96 100644--- a/app/models/translation_override.rb+++ b/app/models/translation_override.rb@@ -69,7 +69,7 @@ class TranslationOverride < ActiveRecord::Basetranslation_override = find_or_initialize_by(params)sanitized_value =- translation_override.sanitize_field(value, additional_attributes: ["data-auto-route"])+ translation_override.sanitize_field(value, additional_attributes: %w[data-auto-route target])original_translation =I18n.overrides_disabled { I18n.t(transform_pluralized_key(key), locale: :en) }diff --git a/spec/models/translation_override_spec.rb b/spec/models/translation_override_spec.rbindex f1cb27eaef0..336e7937166 100644--- a/spec/models/translation_override_spec.rb+++ b/spec/models/translation_override_spec.rb@@ -186,14 +186,14 @@ RSpec.describe TranslationOverride doendit "sanitizes values before upsert" do- xss = "<a target='blank' href='%{path}'>Click here</a> <script>alert('TEST');</script>"+ xss = "<a target='_blank' href='%{path}'>Click here</a> <script>alert('TEST');</script>"TranslationOverride.upsert!("en", "js.themes.error_caused_by", xss)ovr =TranslationOverride.where(locale: "en", translation_key: "js.themes.error_caused_by").firstexpect(ovr).to be_present- expect(ovr.value).to eq("<a href=\"%{path}\">Click here</a> alert('TEST');")+ expect(ovr.value).to eq("<a target=\"_blank\" href=\"%{path}\">Click here</a> alert('TEST');")enddescribe "site cache" do