Repository navigation
Fix wordwrap corrupting LF-delimited 7bit/8bit bodies > 998 bytes - #40
Merged
Merged
Conversation
Contributor
|
Could you try to change the code so it does not creates an array of lines? Something more memory efficient. |
PHP's wordwrap($data, 998, $this->eol) only treats the exact $break sequence ($this->eol, default "\r\n") as a line break. When 7bit/8bit content uses "\n" line endings (such as GnuPG ASCII-armored PGP blocks on Unix) and exceeds 998 bytes total, wordwrap() treated the entire body as a single line and wrapped at spaces inside armor headers and footers (roundcube/roundcubemail#10413). Use preg_replace_callback('/(*ANYCRLF)^[^\r\n]{999,}/m', ...) so wordwrap() is only invoked on individual lines exceeding 998 characters between CR/LF line breaks without allocating an array of lines.
duritong
force-pushed
the
fix/wordwrap-lf-lines
branch
from
November 16, 2026 12:17
ec42167 to
d6320b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PHP's wordwrap($data, 998, $this->eol) only treats the exact $break sequence ($this->eol, default "\r\n") as a line break. When 7bit/8bit content uses "\n" line endings (such as GnuPG ASCII-armored PGP blocks on Unix) and exceeds 998 bytes total, wordwrap() treated the entire body as a single line and wrapped at spaces inside armor headers and footers (roundcube/roundcubemail#10413).
Only invoke wordwrap() on individual lines that actually exceed 998 characters between CR/LF line breaks.