Skip to content

fix double-escaping in Slack webhook payloads#2994

Open
unasuke wants to merge 1 commit into
basecamp:mainfrom
unasuke:slack-notification-double-escape
Open

fix double-escaping in Slack webhook payloads#2994
unasuke wants to merge 1 commit into
basecamp:mainfrom
unasuke:slack-notification-double-escape

Conversation

@unasuke

@unasuke unasuke commented Jul 24, 2026

Copy link
Copy Markdown

What

Event::Description#to_plain_text HTML-escapes its output, so Slack notifications showed literal entities like &quot; and &#39;. Slack renders plain text rather than HTML and only wants &, <, and > converted to entities:

https://docs.slack.dev/messaging/formatting-message-text/#escaping

Undo the HTML escaping with CGI.unescapeHTML, then escape just the three Slack control characters.

image

Event::Description#to_plain_text HTML-escapes its output, so Slack
notifications showed literal entities like &quot; and &basecamp#39;. Slack
renders plain text rather than HTML and only wants &, <, and >
converted to entities:

https://docs.slack.dev/messaging/formatting-message-text/#escaping

Undo the HTML escaping with CGI.unescapeHTML, then escape just the
three Slack control characters.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 24, 2026 15:14

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts Slack webhook payload generation to avoid double-escaped HTML entities in event descriptions, aligning outbound Slack message text with Slack’s documented escaping rules.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Update Slack payload text generation to unescape HTML entities and then re-escape only Slack control characters (&, <, >).
  • Update/rename the Slack webhook payload test to assert quotes are preserved while Slack control characters are escaped.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
app/models/webhook/delivery.rb Changes Slack payload text escaping behavior to prevent double-escaped entities in Slack notifications.
test/models/webhook/delivery_test.rb Updates Slack payload expectation and test name to validate the new escaping behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


def slack_payload
text = event.description_for(nil).to_plain_text
text = CGI.unescapeHTML(event.description_for(nil).to_plain_text).gsub(/[&<>]/, SLACK_ESCAPE)
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