Skip to content

[PM-33153] Fix: Double HTML encoding in emergency access emails#7149

Open
boris324 wants to merge 1 commit intobitwarden:mainfrom
boris324:fix/emergency-access-email-encoding
Open

[PM-33153] Fix: Double HTML encoding in emergency access emails#7149
boris324 wants to merge 1 commit intobitwarden:mainfrom
boris324:fix/emergency-access-email-encoding

Conversation

@boris324
Copy link

@boris324 boris324 commented Mar 4, 2026

Summary

  • Fixes Emergency Access E-Mails use Wrong Encoding for Names #4845
  • Emergency access emails display special characters as HTML entities (e.g. ü instead of ü)
  • Root cause: SanitizeForEmail() defaults to htmlEncode: true, calling HttpUtility.HtmlEncode(). Handlebars {{Name}} then HTML-encodes again (double encoding)
  • Fixed by passing htmlEncode: false to all 7 emergency access email methods in HandlebarsMailService.cs
  • Matches the pattern already used by other email methods in the same file (e.g. organization emails at line ~332, ~348, ~458)

Changed methods

  • SendEmergencyAccessInviteEmailAsync
  • SendEmergencyAccessConfirmedEmailAsync
  • SendEmergencyAccessRecoveryInitiated
  • SendEmergencyAccessRecoveryApproved
  • SendEmergencyAccessRecoveryRejected
  • SendEmergencyAccessRecoveryReminder
  • SendEmergencyAccessRecoveryTimedOut

Test plan

  • Create account with special characters in name (e.g. umlauts: ü, ö, ä)
  • Invite someone for emergency access
  • Verify invitation email displays name correctly (not as HTML entities)
  • Confirm emergency access and verify confirmation email

Emergency access email methods call SanitizeForEmail() with default
htmlEncode=true, which HTML-encodes special characters. Handlebars
{{Name}} then encodes again, causing names like "Windmuller" to
appear as "Windm&bitwarden#252;ller".

Other mail methods already correctly pass htmlEncode: false. Apply
the same pattern to all 7 emergency access email methods.

Resolves bitwarden#4845
@boris324 boris324 requested a review from a team as a code owner March 4, 2026 21:01
@boris324 boris324 requested a review from djsmith85 March 4, 2026 21:01
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@bitwarden-bot
Copy link

Thank you for your contribution! We've added this to our internal tracking system for review.
ID: PM-33153
Link: https://bitwarden.atlassian.net/browse/PM-33153

Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process.

@bitwarden-bot bitwarden-bot changed the title Fix: Double HTML encoding in emergency access emails [PM-33153] Fix: Double HTML encoding in emergency access emails Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emergency Access E-Mails use Wrong Encoding for Names

3 participants