fix(paste): prevent \r \n characters from interfering with url redirects
Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
parent
ec4661fe44
commit
1ecb497199
@ -21,7 +21,9 @@ defmodule KetbinWeb.PageController do
|
|||||||
# paste is a url, redirect
|
# paste is a url, redirect
|
||||||
# regular paste, show content
|
# regular paste, show content
|
||||||
if paste.is_url do
|
if paste.is_url do
|
||||||
redirect(conn, external: paste.content)
|
redirect(conn,
|
||||||
|
external: paste.content |> String.replace("\r", "") |> String.replace("\n", "")
|
||||||
|
)
|
||||||
else
|
else
|
||||||
render(conn, "show.html",
|
render(conn, "show.html",
|
||||||
paste: paste,
|
paste: paste,
|
||||||
|
@ -11,6 +11,6 @@
|
|||||||
<%= if @extension == "md" do%>
|
<%= if @extension == "md" do%>
|
||||||
<div class="break-word px-6 py-4 h-full w-full markdown overflow-y-auto"><%= raw Earmark.as_html!(@paste.content, escape: true, gfm_tables: true) |> HtmlSanitizeEx.markdown_html %></div>
|
<div class="break-word px-6 py-4 h-full w-full markdown overflow-y-auto"><%= raw Earmark.as_html!(@paste.content, escape: true, gfm_tables: true) |> HtmlSanitizeEx.markdown_html %></div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<code class="break-word px-6 py-4 h-full w-full overflow-y-auto"><%= raw Ketbin.Utils.Syntax.highlight_text(@paste.content, @extension) |> HtmlSanitizeEx.strip_tags %></code>
|
<code class="break-word px-6 py-4 h-full w-full overflow-y-auto"><%= raw Ketbin.Utils.Syntax.highlight_text(@paste.content, @extension) |> HtmlSanitizeEx.html5 %></code>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user