Skip to content

Commit

Permalink
fix(hb_http_codec): properly parse value from signature param bare item
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Jan 18, 2025
1 parent d7d4a77 commit 1c6da3e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/hb_codec_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ from_signature(Map, RawSig, RawSigInput) ->

SigMap = lists:foldl(
fun({PName, PBareItem}, PAcc) ->
maps:put(PName, PBareItem, PAcc)
maps:put(PName, from_sf_bare_item(PBareItem), PAcc)
end,
#{ <<"signature">> => Sig, <<"inputs">> => Inputs },
% Signature parameters are converted into top-level keys on the signature Map
Expand All @@ -109,6 +109,16 @@ from_signature(Map, RawSig, RawSigInput) ->
% Finally place the Signatures as a top-level Map on the parent Map
maps:put(<<"signatures">>, Signatures, Map).

from_sf_bare_item (BareItem) ->
case BareItem of
I when is_integer(I) -> I;
B when is_boolean(B) -> B;
D = {decimal, _} -> list_to_float(hb_http_structured_fields:bare_item(D));
{string, S} -> S;
{token, T} -> binary_to_existing_atom(T);
{binary, B} -> B
end.

find_header(Headers, Name) ->
find_header(Headers, Name, []).
find_header(Headers, Name, Opts) when is_list(Headers) ->
Expand Down

0 comments on commit 1c6da3e

Please sign in to comment.