Fix decoding of multi-segment RFC2231 extended attachment filenames - #10268
Merged
Conversation
Member
|
@MiMoHo adding an entry to the Changelog is problematic because it's a conflict whenever any other entry is added there. So, better is to not include Changelog entry in a PR. |
Co-Authored-By: Claude Fable 5 <[email protected]>
MiMoHo
force-pushed
the
held-mime-rfc2231
branch
from
July 16, 2026 08:13
e451017 to
f3ec5f5
Compare
Contributor
Author
|
Good point — thanks. I've dropped the Changelog entry from this PR and from my other open PRs, and I'll leave the Changelog additions to you on merge going forward. |
alecpl
pushed a commit
that referenced
this pull request
Jul 25, 2026
…10268) Co-authored-by: Claude Fable 5 <[email protected]>
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.
Problem
An attachment whose filename is split across multiple RFC2231 extended (percent-encoded) parameters is decoded only in its first segment; the continuation segments remain percent-encoded, producing a corrupted filename.
Example header:
was decoded to
€%e2%82%acinstead of€€.Root cause
rcube_mime_decode::parseHeaderValue()(program/lib/Roundcube/rcube_mime_decode.php:295-307) appliedrawurldecode()only when a segment carried thecharset'lang'prefix (matched at line 299), which is present only on the first segment (filename*0*). Continuation segments (filename*1*,filename*2*, …) have no such prefix and fell through with their value appended raw, still percent-encoded.Fix
The parameter regex now captures the trailing
*that marks an extended (percent-encoded) parameter. Continuation segments of an extended parameter arerawurldecode()'d before concatenation. Plain (non-extended) continuations (filename*0=, no trailing star) are still treated as literal and are not decoded, per RFC2231.Testing
Added
tests/Framework/MimeDecodeTest.phpcases:test_decode_rfc2231_extended_continuation: multi-segmentfilename*0*/filename*1*assembles to the fully decoded value (fails before the fix, passes after).test_decode_rfc2231_plain_continuation: plainfilename*0/filename*1continuation stays literal (%20not decoded).Full
MimeDecodeTestpasses (3 tests, 14 assertions); phpstan level 4 on the changed file reports no errors.