Skip to content

Commit

Permalink
Prevents generating cookies that contain commas (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
heymackey authored and bitwalker committed May 16, 2019
1 parent 47ac647 commit 4776b59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/distillery/lib/cookies.ex
Expand Up @@ -31,7 +31,7 @@ defmodule Distillery.Cookies do
Stream.unfold(nil, fn _ -> {:crypto.strong_rand_bytes(1), nil} end)
|> Stream.filter(fn <<b>> -> b >= ?! && b <= ?~ end)
# special when erlexec parses vm.args
|> Stream.reject(fn <<b>> -> b in [?-, ?+, ?', ?\", ?\\, ?\#] end)
|> Stream.reject(fn <<b>> -> b in [?-, ?+, ?', ?\", ?\\, ?\#, ?,] end)
|> Enum.take(64)
|> Enum.join()
|> String.to_atom()
Expand Down
2 changes: 1 addition & 1 deletion test/cases/cookies_test.exs
Expand Up @@ -23,7 +23,7 @@ defmodule Distillery.Test.CookiesTest do
str = Atom.to_string(x)
chars = String.to_charlist(str)

with false <- String.contains?(str, ["-", "+", "'", "\"", "\\", "#"]),
with false <- String.contains?(str, ["-", "+", "'", "\"", "\\", "#", ","]),
false <- Enum.any?(chars, fn b -> not (b >= ?! && b <= ?~) end),
64 <- byte_size(str) do
true
Expand Down

0 comments on commit 4776b59

Please sign in to comment.