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

Content type params utf8 #235

Merged
merged 2 commits into from
Jan 27, 2022
Merged

Conversation

kape1395
Copy link
Contributor

No description provided.

@mworrell
Copy link
Collaborator

mworrell commented Jan 6, 2021

Looks ok to me, especially with the added test case. Wondering if the encode_paramater changes are affecting other headers.

@seriyps what do you think?

Copy link
Collaborator

@seriyps seriyps left a comment

Choose a reason for hiding this comment

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

I, honestly, don't remember how exactly this part works. Would be nice to get some comments with explanation from @kape1395. But, since no tests were broken, I think it's ok

@kape1395
Copy link
Contributor Author

kape1395 commented Jan 7, 2021

I tried to keep the other headers unchanged. As I understand, ContentTypeParams are only used to construct the ContentType and the ContentDisposition headers. Other headers are used as provided by the user, therefore the user is responsible for formatting their values properly.

@mworrell
Copy link
Collaborator

@kape1395 could you rebase this on the newest master?

@kape1395
Copy link
Contributor Author

I have rebased my changes on the master. But this test is failing, maybe because it tries to access external server.

					{"Erlang 23.2.7 compatibility",
					 fun() ->
							 Receipt = gen_smtp_client:send_blocking({<<"Info.ContactTracing@sg.ch">>, [<<"maennchen@joshmartin.ch">>], <<"test">>},
																	 [{relay, <<"joshmartin.ch">>},
																	  {port, 25},
																	  {hostname, "smtp.covid19-tracing.ch"},
																	  {retries, 10}]
																	),
							 ?assertMatch({error, send, _}, Receipt),
							 ok
					 end
					}

All tests are passing, if this one is removes.

And, maybe this one should be added to a list with the previous testcase, because the former is currently ignored.

@seriyps
Copy link
Collaborator

seriyps commented Apr 1, 2021

So, did I get it correctly that before your change, if one passes UTF-8 encoded binary as, eg, content_type_params => [{<<"name">>, Name}], it will be encoded in some incorrect way?

@kape1395
Copy link
Contributor Author

kape1395 commented Apr 1, 2021

Yes, the MIME message was corrupted in the case of some letters in the filename. Two newlines were inserted instead of that letter (not sure was that by SMTP or Gmail client), so the attachment was corrupted and half of the headers were shown as a mail text body. With this change the filenames with UTF8 letters are processed correctly.

@mworrell
Copy link
Collaborator

@seriyps Shall we remove that test with smtp.covid19-tracing.ch ? I am not happy about using some external server to test our code. Especially as this also seems to be something that won't be there forever.

@mworrell
Copy link
Collaborator

mworrell commented Sep 21, 2021

@kape1395 I am terribly sorry, but could you rebase once again?

Ping me when you are done, then I wil merge.

@mworrell
Copy link
Collaborator

@kape1395 In #281 I have removed the test that relied on the external server. So after rebasing everything should pass.

@mworrell mworrell mentioned this pull request Jan 27, 2022
@mworrell
Copy link
Collaborator

@kape1395 could you rebase this? Then we can merge.

@kape1395
Copy link
Contributor Author

looking at it.

@kape1395
Copy link
Contributor Author

It looks like it will be easier to reimplement my stuff than rebase it.
In the new master there is

rfc2047_q_encode(<<$\s, More/binary>>) ->
	% SPACE -> _
	<<$_, (rfc2047_q_encode(More))/binary>>;

It replaces space with "_". The proper approach is to replace it with "=20".
Is that accidental, or intended? If I change it to

rfc2047_q_encode(<<$\s, More/binary>>) ->
	% SPACE -> _
	<<"=20", (rfc2047_q_encode(More))/binary>>;

then other tests fail, but I think those tests are incorrect (because they expect an underscore instead of space).

@seriyps
Copy link
Collaborator

seriyps commented Jan 27, 2022

@kape1395 I think it was explained in the PR thatintroduced this change #294 (comment)

@Maria-12648430 do you have some more comments about it?

@kape1395
Copy link
Contributor Author

I updated my changes to work with _ instead of =%20 and all the other changes in the master branch. I hope that looks good.

@seriyps seriyps requested a review from mworrell January 27, 2022 18:24
@juhlig
Copy link
Contributor

juhlig commented Jan 27, 2022

@Maria-12648430 is currently not available, but I can answer that: see RFC 2047 Section 4.2 (2). Though it says some mail gateways may not understand the underscore, I never saw any problems with that (I work in the E-Mail business), which is not surprising given the RFC dates back to 1996.

@mworrell
Copy link
Collaborator

Thanks @kape1395 !

@mworrell mworrell merged commit 84940fa into gen-smtp:master Jan 27, 2022
@seriyps seriyps mentioned this pull request Feb 15, 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.

4 participants