Repository navigation
[2.x] fix: Restore held-back email values on every message, and protect core mail - #4988
Merged
Merged
Conversation
The mail translator replaces parameter values with markers before an email is rendered, so a discussion title or display name cannot be parsed as markup, and puts them back afterwards. Restoring only happened inside MailFormatter::convert(), so any template that printed a translated value without the formatter - flarum/gdpr's erasure emails, for one - sent the raw marker to the reader. Restore the values on the finished message instead, in MutateEmail, so it happens for every email whatever template or extension produced it, and no template has to change. HTML parts are escaped as before; plain text parts are put back verbatim, since there is no markup to guard against there and escaping would show entities to the reader. Also mark core's own 'mail::' views, which the previous name check missed - so core notifications get the same protection, not only extension mail.
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.
Changes proposed in this pull request:
The mail translator replaces parameter values (a discussion title, a display name) with opaque markers before an email is rendered, so they cannot be parsed as markup, and puts them back once rendering is done. That restore only ran inside
MailFormatter::convert()— so any template that prints a translated value directly, without the formatter, sent the raw marker to the reader. flarum/gdpr's erasure emails do exactly that, and reported it: the account name and confirmation link arrived asflarumsafevalue…endflarumsafevalue.This moves the restore onto the finished message, in
MutateEmail:MessageSendingbody, so it happens for every email regardless of which template or extension produced it — and no template has to change, including ones in extensions that will never be updated.&to the reader.It also fixes a gap in the original change: the view composer keyed on the view name containing
email, which core's ownmail::views don't — so core notifications were never marked, and the markup-injection protection didn't apply to them at all. Bothmail::views and the extensionemail/emailsconvention are now covered.Reviewers should focus on:
mail::views doesn't double-process values that already go through the formatter (it doesn't — the markers are gone by then, so the message-level restore has nothing to do).Necessity
Confirmed
composer test).mail::view is protected.Required changes: