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

Tags passed to phx_link get escaped #19

Closed
shritesh opened this issue Aug 27, 2019 · 2 comments · Fixed by #20
Closed

Tags passed to phx_link get escaped #19

shritesh opened this issue Aug 27, 2019 · 2 comments · Fixed by #20
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@shritesh
Copy link
Contributor

Describe the bug
Tags passed to phx_link should generate unescaped html but don't.

To Reproduce

phx_link to: "/" do
  h1 "Hello World"
  p "Lorem Ipsum"
end

Expected behavior
The unescaped html should be wrapped in the link tag and not be escaped

Screenshots
Screen Shot 2019-08-27 at 2 03 01 PM

@mhanberg mhanberg added bug Something isn't working good first issue Good for newcomers labels Aug 27, 2019
@mhanberg
Copy link
Owner

I think the problem here are these lines:

{:safe, content} =

We should be passing in the whole tagged tuple into the phoenix_html function to avoid double escaping.

@shritesh
Copy link
Contributor Author

This is being tested as an expected behavior

test "emits a link when passed block that has more markup" do
{:safe, actual} =
temple do
phx_link to: "/hello" do
div do
div "hi"
end
end
end
assert String.starts_with?(actual, ~s{<a})
assert actual =~ ~s{href="/hello"}
assert actual =~ ~s{&lt;div&gt;&lt;div&gt;}
assert actual =~ ~s{hi}
assert actual =~ ~s{&lt;/div&gt;&lt;/div&gt;}
assert String.ends_with?(actual, ~s{</a>})
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants