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
addCustomHeader corrupts header value #1854
Comments
That header is correctly Q-encoded according to RFC2047 section 4.2(2), so this looks like a bug in You could work around it by doing:
Though note that you should not do that blindly, as the header may not be Q-encoded, so check for that first. |
Someone in the PHP project confirmed the bug (quick work!), and also pointed out a better workaround - |
|
but it would still be nice to pass an extra bool argument to |
or at least check the value before encoding it if it contains "invalid" chars |
I think that's a pretty terrible idea. If you don't encode the headers when it's needed, you will have corrupted headers. I'm not doing that. You can always subclass if you want to break things on purpose. |
What about checking if the header value contains any illegal chars before encoding? |
Have you tried reading the source? That's exactly what it does. |
I have.. :) The example |
Look at the encoder - it will apply Q encoding if the line contains non-ascii chars, or if its length means it needs folding (even if it only contains ascii). The reason for that is that the PHP In short, if you don't encode the header correctly, you're asking for all kinds of other trouble. Avoiding encoding it on the basis that your decoder is broken isn't really a good reason. |
Ok, you're the expert :) The headers are just alot prettier when not encoded (readability) |
🤷♂️ We're not here for pretty, we're here for functional and compliant! |
addCustomHeader
corrupts the header valueOriginal header
X-My-Header: document/supplier_order block/4431 id/12589 email/alias@mail.com log/21288
Encoded header (PHPMailer)
X-My-Header: =?us-ascii?Q?document/supplier=5Forder_block/4431_id/12589_email/alias@mail?= =?us-ascii?Q?.com_log/21288?=
Decoded header
X-My-Header: document/supplier_order_block/4431_id/12589_email/alias@mail.com_log/21288
The Original header and the decoded header are not identical. Spaces are translated to _ (underscore)
The header is decoded with
mb_decode_mimeheader()
The text was updated successfully, but these errors were encountered: