FIX: restrict a href protocols on form template description (#27472)

This commit is contained in:
Renato Atilio
2024-06-14 11:39:43 -03:00
committed by GitHub
parent fb259acd52
commit 49fdccbb1d
2 changed files with 28 additions and 1 deletions

View File

@ -136,6 +136,23 @@ RSpec.describe FormTemplateYamlValidator, type: :validator do
)
end
end
context "when description field has unsafe anchor href" do
let(:yaml_content) { <<~YAML }
- type: input
id: name
attributes:
label: "Full name"
description: "What is your full name? Details <a href='javascript:alert()'>here</a>."
YAML
it "adds a validation error" do
validator.validate(form_template)
expect(form_template.errors[:template]).to include(
I18n.t("form_templates.errors.unsafe_description"),
)
end
end
end
describe "#check_ids" do