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

[7.1-stable] Mark ingredient output as html_safe #2782

Merged
merged 1 commit into from
Mar 8, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/audio_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class AudioView < BaseView
def call
content_tag(:audio, **html_options) do
tag(:source, src: src, type: type)
end
end.html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/base_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(ingredient, html_options: {})
end

def call
value
value.html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/boolean_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Alchemy
module Ingredients
class BooleanView < BaseView
def call
Alchemy.t(value, scope: "ingredient_values.boolean")
Alchemy.t(value, scope: "ingredient_values.boolean").html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/datetime_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def call
ingredient.value.to_s(:rfc822)
else
::I18n.l(ingredient.value, format: date_format)
end
end.html_safe
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/file_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call
class: ingredient.css_class.presence,
title: ingredient.title.presence
}.merge(html_options)
)
).html_safe
end

def render?
Expand Down
23 changes: 16 additions & 7 deletions app/components/alchemy/ingredients/headline_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ def initialize(ingredient, level: nil, html_options: {})
end

def call
content_tag "h#{@level || ingredient.level}",
ingredient.value,
id: ingredient.dom_id.presence,
class: [
ingredient.size ? "h#{ingredient.size}" : nil,
html_options[:class]
]
content_tag tag_name, id: dom_id, class: css_classes do
ingredient.value
end.html_safe
end

private

def tag_name = "h#{@level || ingredient.level}"

def dom_id = ingredient.dom_id.presence

def css_classes
[
ingredient.size ? "h#{ingredient.size}" : nil,
html_options[:class]
]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/link_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(ingredient, text: nil, html_options: {})
end

def call
link_to(link_text, value, {target: link_target}.merge(html_options))
link_to(link_text, value, {target: link_target}.merge(html_options)).html_safe
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/page_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class PageView < BaseView
delegate :page, to: :ingredient

def call
link_to page.name, alchemy.show_page_path(urlname: page.urlname)
link_to(page.name, alchemy.show_page_path(urlname: page.urlname)).html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/picture_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def call
content_tag(:figure, output, {class: ingredient.css_class.presence}.merge(html_options))
else
output
end
end.html_safe
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/richtext_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def call
ingredient.stripped_body
else
value.to_s.html_safe
end
end.html_safe
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/text_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def call
target: ((link_target == "blank") ? "_blank" : nil),
data: {link_target: link_target}
}.merge(html_options))
end
end.html_safe
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/video_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class VideoView < BaseView
def call
content_tag(:video, html_options) do
tag(:source, src: src, type: attachment.file_mime_type)
end
end.html_safe
end

def render?
Expand Down
Loading