-
Notifications
You must be signed in to change notification settings - Fork 486
Fix html escaping on non strings #1958
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
Changes from all commits
1922d41
799ca28
c362e68
50dde11
f0a77e1
4ffee22
6188b02
87ac4b9
75e3e42
5fbd701
13e6bbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| class InlineSlotHtmlEscapeComponent < ViewComponent::Base | ||
| renders_one :empty_state | ||
|
|
||
| def initialize(counter:, heading:, url:) | ||
| @counter = counter | ||
| @heading = heading | ||
| @url = url | ||
| end | ||
|
|
||
| def call | ||
| return empty_state unless @heading.nil? | ||
|
|
||
| link_to @url do | ||
| @counter + | ||
| tag.p(@heading) | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -752,4 +752,20 @@ def test_slot_names_can_start_with_call | |
| end | ||
| end | ||
| end | ||
|
|
||
| def test_inline_slot_html_escape_with_integer | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests don't appear to assert anything? |
||
| render_inline InlineSlotHtmlEscapeComponent.new(heading: "lorem ipsum", counter: 12, url: "/some_url") do |component| | ||
| component.with_empty_state do | ||
| "empty state" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense for this slot to return a non-string value? Otherwise we're testing the existing behavior and not the behavior mentioned in the issue. |
||
| end | ||
| end | ||
| end | ||
|
|
||
| def test_inline_slot_html_escape_with_json | ||
| render_inline InlineSlotHtmlEscapeComponent.new(heading: "lorem ipsum", counter: {foo: "bar"}.to_json, url: "/some_url") do |component| | ||
| component.with_empty_state do | ||
| "empty state" | ||
| end | ||
| end | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.