Skip to content

Commit

Permalink
More html escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
Qqwy committed Oct 2, 2018
1 parent a00e2de commit bb13159
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
20 changes: 8 additions & 12 deletions lib/planga_web/channels/chat_channel.ex
Expand Up @@ -157,8 +157,6 @@ defmodule PlangaWeb.ChatChannel do
{:noreply, socket}
end



@doc """
Called whenever the chatter attempts to see earlier messages.
"""
Expand All @@ -179,21 +177,19 @@ defmodule PlangaWeb.ChatChannel do
{:noreply, socket}
end

# def handle_in("new_remote_message", payload, socket) do
# broadcast! socket, "new_remote_message", message_dict(payload)

# {:noreply, socket}
# end



# Turns returned message information in a format the front-end understands.
defp message_dict(message) do
%{
"uuid" => message.uuid,
"name" => message.sender.name,
"content" => message.content |> Phoenix.HTML.html_escape |> Phoenix.HTML.safe_to_string,
"name" => message.sender.name |> html_escape,
"content" => message.content |> html_escape,
"sent_at" => message.inserted_at
}
end

defp html_escape(unsafe_string) do
unsafe_string
|> Phoenix.HTML.html_escape
|> Phoenix.HTML.safe_to_string
end
end
2 changes: 1 addition & 1 deletion mix.exs
Expand Up @@ -4,7 +4,7 @@ defmodule Planga.Mixfile do
def project do
[
app: :planga,
version: "0.3.17",
version: "0.3.18",
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
Expand Down

0 comments on commit bb13159

Please sign in to comment.