Skip to content

Conversation

@cmb69
Copy link
Member

@cmb69 cmb69 commented Aug 12, 2018

The minimum length of an encoded-word is actually the pure encoding
overhead plus the length of the output-charset plus the minimum unit
of encoded text, which is 4 for B-encoding and (for simplicity) 3 for
Q-encoding. We also cater to the possibility that we need further
encoded words, which would be split by the line-break-chars followed
by a space character. Obviously, the former out_charset_len + 12 is
too simplistic and wrong in the given case (where the magic number
would be 13).

These simplifications are somewhat wasteful, but iconv_mime_encode()
with Q-encoding is wasteful anyway (see bug 66828[1]), and the proper
solution to convert the whole input to the desired output charset
upfront, and applying the encoding afterwards appears too much a change
for the stable releases.

[1] https://bugs.php.net/66828

The minimum length of an encoded-word is actually the pure encoding
overhead plus the length of the `output-charset` plus the minimum unit
of encoded text, which is 4 for B-encoding and (for simplicity) 3 for
Q-encoding.  We also cater to the possibility that we need further
encoded words, which would be split by the `line-break-chars` followed
by a space character.  Obviously, the former `out_charset_len + 12` is
too simplistic and wrong in the given case (where the magic number
would be 13).

These simplifications are somewhat wasteful, but iconv_mime_encode()
with Q-encoding is wasteful anyway (see bug 66828[1]), and the proper
solution to convert the whole input to the desired output charset
upfront, and applying the encoding afterwards appears too much a change
for the stable releases.

[1] <https://bugs.php.net/66828>
@cmb69
Copy link
Member Author

cmb69 commented Aug 22, 2018

I'm not sure whether this fix would have unintended side effects, so unless there are objections, I'll skip the stable branches, and apply this patch to PHP-7.3+ only on the weekend.

@php-pulls
Copy link

Comment on behalf of cmb at php.net:

Applied via eb03290.

@php-pulls php-pulls closed this Aug 25, 2018
@cmb69 cmb69 deleted the fix-53891 branch August 25, 2018 12:34
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