fix(notifications): use <wbr> instead of soft-hyphens in HTML emails#107830
Draft
skylarkoo7 wants to merge 1 commit intogetsentry:masterfrom
Draft
fix(notifications): use <wbr> instead of soft-hyphens in HTML emails#107830skylarkoo7 wants to merge 1 commit intogetsentry:masterfrom
skylarkoo7 wants to merge 1 commit intogetsentry:masterfrom
Conversation
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
80bbc62 to
aa5dd60
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.
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
src/sentry/utils/strings.pydelimiter_breakparameter tosoft_break()so the break character is configurable (<wbr>for HTML,\u200bfor plain text)src/sentry/templatetags/sentry_helpers.pysoft_break_htmltemplate filter that uses<wbr>tags instead of\u00ad/\u200b, with XSS-safe HTML escapingsrc/sentry/templates/sentry/emails/issue_alert_base.htmlsoft_breaktosoft_break_htmlfor HTML email renderingsrc/sentry/templates/sentry/emails/_group.htmlsoft_breaktosoft_break_htmlfor HTML email renderingHow It Works
soft_breakinserts\u00ad(soft-hyphen) every N characters → copied text contains invisible characterssoft_break_htmlinserts<wbr>(word break opportunity) tags → identical line-break behavior in email clients, but copied text is cleanThe original
soft_breakfilter is preserved for non-HTML contexts (plain-text emails, etc.).Type of Change
Testing
soft_break/soft_hyphenatebehavior unchanged (backward compatible)soft_break_htmlfilter escapes HTML input before inserting<wbr>tags (XSS safe)