[2.14]: Fix: Fold long lines during SMTP communication#140
[2.14]: Fix: Fold long lines during SMTP communication#140Slamdunk merged 16 commits intolaminas:2.14.xfrom
Conversation
21ff841 to
2acf481
Compare
e80773f to
e88b6f6
Compare
|
I would move |
9a04d14 to
cccf126
Compare
|
I honestly believe that too much PHP force has been used :) |
That was an impressive technique :) Wouldn't be simpler to move "escaping, rtrim'ing and folding" a line into a function? |
what do you mean by "simpler", simpler to whom? to what? i offered to move the generator to class method, but not doing 'jus for that', as maybe maintainers accept it as is now. also, I would be against putting three different logics to the same code block, it would make code more difficult to understand and follow the code flow. currently, it's distinct, reading and unfolding in one place, the rest in the other loop. the code gets smelly if they all done in the same loop (as you can see from commit history). need multiple state variables that are unrelated to each other but used in the same loop. |
c09daa0 to
837a417
Compare
For the maintainers to review the PR. |
In the end, the resulting code is simpler, and only the aggregated diff is messy, but individual commit diffs are okay. |
|
Created reproducer of the bug I discovered that prevented of making more reasonable tests: Wanted to test like this: $raw = substr($data, strpos($data, "DATA\r\n") + 6);
$message = new StorageMessage(['raw' => $raw]);
$headers = $message->getHeaders()->toArray();
$this->assertEquals($bufferSizeHeaderValue, $headers['X-Exact-Length']);
$this->assertEquals($headerValue, $headers['X-Ms-Exchange-Antispam-Messagedata']);That's what I get when captured SMTP from this PR. It does look correct, so it's a bug in parsing of this library/ |
5459b48 to
ea01167
Compare
To deal with the 998/78 character limitations per line, long lines can be split into a multiple-line representation separated by CRLF + WSP; this is called "folding". Correct folding is particularly important for long header fields. Signed-off-by: Vlad Safronov <vladislav.safronov@oracle.com>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
This isolates the logic of handling incomplete reads to own unit. Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
As the buffer max size is known, can check last byte with isset Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
he method has no state, so therefore declared static. Ideally this should be a standalone class, perhaps in laminas-stdlib. Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
e2aa574 to
74f4242
Compare
|
@Slamdunk made a fresh rebase against |
|
Thank you @glensc, I'm going to squash this PR to reduce |
|
@Slamdunk perhaps you should have asked first from authors for permission to squash! This PR has waited for two weeks+ being idle! If this was an issue, should have said it in that time period! I (try to) follow the atomic commits principle: As I see it, you made the opposite: more difficult to git blame/bisect with squashing. And losing commit author information is not very friendly either. |
|
Update: seems this got merged without squashing, at least the 542686a merge commit. So far so good. |
|
@Slamdunk thank you for the 2.14.0 release! |
[2.14]: Fix: Fold long lines during SMTP communication
Description
It seems, the underlying problem of the bug is that currently, the loop reads up to 1000 bytes, and if the input is longer than that, then everything over 1000 bytes will appear as the next line in mail headers, resulting in corruption. And depending on MTA, such corruption is treated as the end of headers input or adds another mail header.
Updates #138 by @vladsf with the solution described in #138 (comment) and adds unit test.