Skip to content

Commit

Permalink
Check for unsupported unicode payload strings in add event (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicmgs committed Apr 22, 2021
1 parent e91354e commit e67e006
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/console_web/controllers/router/device_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ defmodule ConsoleWeb.Router.DeviceController do
end
end

event = case event["data"]["payload"] do
nil -> event
_ ->
case :unicode.characters_to_binary(event["data"]["payload"]) |> String.at(0) do
<<0>> -> Kernel.put_in(event["data"]["payload"], "Unsupported unicode escape sequence in payload")
_ -> event
end
end

Events.create_event(Map.put(event, "organization_id", organization.id))
end)
|> Ecto.Multi.run(:device, fn _repo, %{ event: event } ->
Expand Down

0 comments on commit e67e006

Please sign in to comment.