Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mimemail parameters fixes #304

Merged
merged 2 commits into from
Jan 25, 2022

Conversation

seriyps
Copy link
Collaborator

@seriyps seriyps commented Jan 25, 2022

Noticed that in some specific case mimemail:mimetuple()'s 4th element which is supposed to always be mimemail:parameters() map, it is actually returned as a list (of incorrect values anyway) from decode/1.

Fixed it, also added some more proper-tests validation for parameters().

Small bonus: some optimization in mimemail:get_header_value/2,3

* only lowercase the pattern once
* use `lists:search/2`
* fix bug when raw content-type params were returned instead of `parameters()` map
* better `parameters()` validation in proper test
@@ -143,9 +144,19 @@ decode(OrigHeaders, Body, Options) ->
decode_component(Headers, Body, MimeVersion, Options);
{<<"multipart">>, _SubType, _Parameters} ->
erlang:error(non_mime_multipart);
{Type, SubType, Parameters} ->
{Type, SubType, CTParameters} ->
Copy link
Collaborator Author

@seriyps seriyps Jan 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bug was here. We were returning the value of "content-type parameters" in place where we supposed to return mimemail:parameters() (combination of data extracted from content-type and content-disposition headers) map.

@mworrell
Copy link
Collaborator

Good work, thanks again! 👍

@mworrell mworrell merged commit f52ee02 into gen-smtp:master Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants