Skip to content

fix(mail): escape rich-object link when building HTML email subject - #2811

Open
karlitschek wants to merge 1 commit into
masterfrom
fix/escape-rich-object-link-in-emails
Open

fix(mail): escape rich-object link when building HTML email subject#2811
karlitschek wants to merge 1 commit into
masterfrom
fix/escape-rich-object-link-in-emails

Conversation

@karlitschek

@karlitschek karlitschek commented Jul 22, 2026

Copy link
Copy Markdown
Member

The link parameter of rich subject parameters was interpolated into the href attribute of notification and digest emails without escaping, allowing attribute/markup injection into outgoing mail by any activity provider or federated source whose link contains a double quote.

Escape the link with htmlspecialchars(ENT_QUOTES), matching the escaping already applied to the link text.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The link parameter of rich subject parameters was interpolated into the
href attribute of notification and digest emails without escaping,
allowing attribute/markup injection into outgoing mail by any activity
provider or federated source whose link contains a double quote.

Escape the link with htmlspecialchars(ENT_QUOTES), matching the
escaping already applied to the link text.

Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@karlitschek

Copy link
Copy Markdown
Member Author

@nickvergessen

@karlitschek
karlitschek requested a review from miaulalala July 22, 2026 18:00

@nickvergessen nickvergessen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENT_QUOTES is not needed on our supported php versions

Comment thread lib/DigestSender.php

if (isset($parameter['link'])) {
$replacements[] = '<a href="' . $parameter['link'] . '">' . htmlspecialchars($replacement) . '</a>';
$replacements[] = '<a href="' . htmlspecialchars((string)$parameter['link'], ENT_QUOTES) . '">' . htmlspecialchars($replacement) . '</a>';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$replacements[] = '<a href="' . htmlspecialchars((string)$parameter['link'], ENT_QUOTES) . '">' . htmlspecialchars($replacement) . '</a>';
$replacements[] = '<a href="' . htmlspecialchars($parameter['link']) . '">' . htmlspecialchars($replacement) . '</a>';

Comment thread lib/MailQueueHandler.php

if (isset($parameter['link'])) {
$replacements[] = '<a href="' . $parameter['link'] . '">' . htmlspecialchars($replacement) . '</a>';
$replacements[] = '<a href="' . htmlspecialchars((string)$parameter['link'], ENT_QUOTES) . '">' . htmlspecialchars($replacement) . '</a>';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$replacements[] = '<a href="' . htmlspecialchars((string)$parameter['link'], ENT_QUOTES) . '">' . htmlspecialchars($replacement) . '</a>';
$replacements[] = '<a href="' . htmlspecialchars($parameter['link']) . '">' . htmlspecialchars($replacement) . '</a>';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants