Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix encoding organization name in A2HS #9184

Merged
merged 2 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,8 +3,12 @@
module Decidim
# A general presenter to render organization logic to build a manifest
class OrganizationPresenter < SimpleDelegator
def html_name
name.html_safe
end

def translated_description
ActionView::Base.full_sanitizer.sanitize(translated_attribute(description))
ActionView::Base.full_sanitizer.sanitize(translated_attribute(description)).html_safe
end

def pwa_display
Expand Down
2 changes: 1 addition & 1 deletion decidim-core/app/views/decidim/manifests/show.json.erb
@@ -1,5 +1,5 @@
{
"name": "<%= organization_params.name %>",
"name": "<%= organization_params.html_name %>",
"lang": "<%= organization_params.default_locale %>",
"description": "<%= organization_params.translated_description %>",
"display": "<%= organization_params.pwa_display %>",
Expand Down
Expand Up @@ -6,7 +6,7 @@ module Decidim
describe ManifestsController, type: :controller do
routes { Decidim::Core::Engine.routes }

let(:organization) { create(:organization, colors: { "theme" => "#f0f0f0" }) }
let(:organization) { create(:organization, name: "Organization's name", colors: { "theme" => "#f0f0f0" }) }

before do
Decidim::Organization.destroy_all
Expand Down
Expand Up @@ -5,10 +5,16 @@
module Decidim
describe OrganizationPresenter, type: :helper do
let(:description) { { "en" => "<p>A necessitatibus quo. 1</p>" } }
let(:organization) { create(:organization, description: description) }
let(:organization) { create(:organization, name: "Organization's name", description: description) }
let(:subject) { described_class.new(organization) }

context "with an organization" do
describe "#html_name" do
it "returns the description translated and without any html tag" do
expect(subject.html_name).to eq("Organization's name")
end
end

describe "#translated_description" do
it "returns the description translated and without any html tag" do
expect(subject.translated_description).to eq("A necessitatibus quo. 1")
Expand Down