ExMCP.Internal.AtomUtils (ex_mcp v1.0.0-rc.1)
View SourceInternal utilities for safe atom handling.
This module provides functions to safely convert strings to atoms without risking atom table exhaustion from untrusted input.
Summary
Functions
Safely converts a binary string to an atom if the atom already exists. Otherwise, returns a generic :unknown_key atom. Prevents atom exhaustion attacks and ensures consistent map key types.
Functions
Safely converts a binary string to an atom if the atom already exists. Otherwise, returns a generic :unknown_key atom. Prevents atom exhaustion attacks and ensures consistent map key types.
Examples
iex> ExMCP.Internal.AtomUtils.safe_string_to_atom("name")
:name # if :name already exists
iex> ExMCP.Internal.AtomUtils.safe_string_to_atom("unknown_key_12345")
:__unknown_key__ # returns generic atom for unknown keys