Skip to content

fix(notifications): use <wbr> instead of soft-hyphens in HTML emails#107830

Draft
skylarkoo7 wants to merge 1 commit intogetsentry:masterfrom
skylarkoo7:fix/soft-hyphen-email-notifications
Draft

fix(notifications): use <wbr> instead of soft-hyphens in HTML emails#107830
skylarkoo7 wants to merge 1 commit intogetsentry:masterfrom
skylarkoo7:fix/soft-hyphen-email-notifications

Conversation

@skylarkoo7
Copy link

@skylarkoo7 skylarkoo7 commented Feb 7, 2026

Description

Notification emails insert Unicode soft-hyphens (U+00AD) into long identifiers (error messages, file paths, class names) to help with line wrapping. When users copy these strings from the email, the invisible soft-hyphen characters are included in the clipboard text, silently corrupting the identifier and causing searches in editors and tools to fail.

Related Issue

Fixes #103714

Changes Made

File Change
src/sentry/utils/strings.py Added delimiter_break parameter to soft_break() so the break character is configurable (<wbr> for HTML, \u200b for plain text)
src/sentry/templatetags/sentry_helpers.py Added soft_break_html template filter that uses <wbr> tags instead of \u00ad / \u200b, with XSS-safe HTML escaping
src/sentry/templates/sentry/emails/issue_alert_base.html Switched from soft_break to soft_break_html for HTML email rendering
src/sentry/templates/sentry/emails/_group.html Switched from soft_break to soft_break_html for HTML email rendering

How It Works

  • Before: soft_break inserts \u00ad (soft-hyphen) every N characters → copied text contains invisible characters
  • After: soft_break_html inserts <wbr> (word break opportunity) tags → identical line-break behavior in email clients, but copied text is clean

The original soft_break filter is preserved for non-HTML contexts (plain-text emails, etc.).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • Ruff check and format pass
  • Existing soft_break / soft_hyphenate behavior unchanged (backward compatible)
  • New soft_break_html filter escapes HTML input before inserting <wbr> tags (XSS safe)

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 7, 2026
The soft_break template filter inserts Unicode soft-hyphens (U+00AD) into
long identifiers in notification emails.  When users copy error messages,
file paths, or class names from these emails, the invisible soft-hyphen
characters are included in the clipboard text.  This breaks searches in
editors and tools because the copied string silently differs from the
original.

Add a new `soft_break_html` template filter that uses HTML `<wbr>` tags
instead of U+00AD soft-hyphens and U+200B zero-width spaces.  The `<wbr>`
tag provides identical line-break hints to email clients but is not
included when text is copied.  The input is HTML-escaped before break
tags are inserted to prevent XSS.

Update all HTML email templates to use the new filter while preserving
the original `soft_break` for non-HTML contexts.

Fixes getsentry#103714
@skylarkoo7 skylarkoo7 force-pushed the fix/soft-hyphen-email-notifications branch from 80bbc62 to aa5dd60 Compare February 8, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable Soft-Hyphen (&shy;) Insertion in notification emails

1 participant