Skip to content

Commit

Permalink
Only save Process keys that are atoms starting with $ (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwinchester authored May 10, 2024
1 parent 53fdf06 commit e1a34f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/bandit/http1/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ defmodule Bandit.HTTP1.Handler do
end

defp clear_process_dict do
Enum.each(Process.get_keys(), fn key ->
if !match?("$" <> _, to_string(key)), do: Process.delete(key)
Enum.each(Process.get_keys(), fn
key when is_atom(key) ->
if !match?("$" <> _, to_string(key)), do: Process.delete(key)

key ->
Process.delete(key)
end)
end

Expand Down
1 change: 1 addition & 0 deletions test/bandit/http1/request_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ defmodule HTTP1RequestTest do
Process.get() |> Keyword.drop(~w[$ancestors $initial_call]a)

Process.put(:garbage, :garbage)
Process.put({:garbage, :test}, :garbage)
send_resp(conn, 200, inspect(existing_pdict))
end

Expand Down

0 comments on commit e1a34f9

Please sign in to comment.