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

Don't let headers contain newlines, fix fn emit_folded() #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Hocuri
Copy link

@Hocuri Hocuri commented Jan 1, 2021

The problem was:

MIME_LINE_LENGTH is 78. If a line is 78 chars long and ends with a
space, then the previous implementation would insert a line break after
the space (as the line lenghth of 78 is reached).

Then, it would forget about it and go on with the next char, which is
the existing line break.

Therefore we have two line breaks in a row, i.e. an empty line.

The easiest way I found to fix this was, not parse the input character
by character but split it using the stdlib and then work with the
individual words.

fix #59

@niax can we do this this way, or are we going to get other problems?

@Hocuri Hocuri force-pushed the upstream-no-newlines branch 2 times, most recently from e29489a to 7a1f99f Compare January 1, 2021 19:46
@Hocuri Hocuri force-pushed the upstream-no-newlines branch from 7a1f99f to 304aabf Compare January 9, 2021 10:59
Hocuri added 2 commits January 9, 2021 12:00
The problem was:

MIME_LINE_LENGTH is 78. If a line is 78 chars long and ends with a
space, then the previous implementation would insert a line break after
the space (as the line lenghth of 78 is reached).

Then, it would forget about it and go on with the next char, which is
the existing line break.

Therefore we have two line breaks in a row, i.e. an empty line.

The easiest way I found to fix this was, not parse the input character
by character but split it using the stdlib and then work with the
individual words.
current = word.to_owned();
} else {
if !current.is_empty() {
current += " "; // Separate the existing line and the new word with a space
Copy link

Choose a reason for hiding this comment

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

This will replace tabs and other whitespace in the original string with spaces, is this always correct? Should be ok in most cases I guess, but maybe there are some cases where preserving tabs and not replacing them with spaces is important?

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.

as_string() produces empty line in header that can cause MTA rejection
2 participants