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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix order to escape proposal content #5367

Merged
merged 2 commits into from Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -29,20 +29,21 @@ def collaborative_draft_path
end

def title(links: false, extras: true, html_escape: false)
renderer = Decidim::ContentRenderers::HashtagRenderer.new(collaborative_draft.title)
text = renderer.render(links: links, extras: extras).html_safe
text = collaborative_draft.title
text = decidim_html_escape(text) if html_escape
text

renderer = Decidim::ContentRenderers::HashtagRenderer.new(text)
renderer.render(links: links, extras: extras).html_safe
end

def body(links: false, extras: true, strip_tags: false)
renderer = Decidim::ContentRenderers::HashtagRenderer.new(collaborative_draft.body)
text = collaborative_draft.body
text = strip_tags(text) if strip_tags

renderer = Decidim::ContentRenderers::HashtagRenderer.new(text)
text = renderer.render(links: links, extras: extras).html_safe
if strip_tags
text = strip_tags(text)
text = Anchored::Linker.auto_link(text, target: "_blank", rel: "noopener")
end
text

Anchored::Linker.auto_link(text, target: "_blank", rel: "noopener")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today I was thinking to open a new PR because text links are always promoted to anchors. But there's already a links flag that we can reuse and make the behavior more consistent.

What's your opinion, do you want me to open a new PR with this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Anchored::Linker.auto_link(text, target: "_blank", rel: "noopener")
text = Anchored::Linker.auto_link(text, target: "_blank", rel: "noopener") if links
text

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense @tramuntanal!

end
end
end
Expand Down
Expand Up @@ -43,20 +43,21 @@ def display_mention
#
# Returns a String.
def title(links: false, extras: true, html_escape: false)
renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.title)
text = renderer.render(links: links, extras: extras).html_safe
text = proposal.title
text = decidim_html_escape(text) if html_escape
text

renderer = Decidim::ContentRenderers::HashtagRenderer.new(text)
renderer.render(links: links, extras: extras).html_safe
end

def body(links: false, extras: true, strip_tags: false)
renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.body)
text = proposal.body
text = strip_tags(text) if strip_tags

renderer = Decidim::ContentRenderers::HashtagRenderer.new(text)
text = renderer.render(links: links, extras: extras).html_safe
if strip_tags
text = strip_tags(text)
text = Anchored::Linker.auto_link(text, target: "_blank", rel: "noopener")
end
text

Anchored::Linker.auto_link(text, target: "_blank", rel: "noopener")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before...

end
end
end
Expand Down