Skip to content

Commit

Permalink
Reject $ from cookies. Resolves bitwalker#727
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseshieh committed Apr 27, 2020
1 parent 6700edb commit a63df53
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/distillery/cookies.ex
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 a63df53

Please sign in to comment.