Skip to content

Conversation

@JeftavanderHorst
Copy link

@JeftavanderHorst JeftavanderHorst commented Jan 11, 2026

When receiving a message containing a spoiler, the desktop notification shows the spoilered text as plain text, defeating the point of the spoiler. This PR aims to fix that.

Fixes #12034

Checklist

@JeftavanderHorst JeftavanderHorst requested a review from a team as a code owner January 11, 2026 01:22
@github-actions github-actions bot added the Z-Community-PR Issue is solved by a community member's PR label Jan 11, 2026
}

try {
const parser = new DOMParser();
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to use more of the same rendering stack we use for the timeline to sanitise the HTML before processing

Copy link
Author

@JeftavanderHorst JeftavanderHorst Jan 23, 2026

Choose a reason for hiding this comment

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

My (admittedly limited) understanding is that the existing rendering stack is quite consolidated: event goes in, rendered html comes out. The problem is that we now need two different output formats:

  • The existing format where spoilers are wrapped in <span data-mx-spoiler> tags containing the actual spoilered text
  • The new format where the spoilered text is replaced with [Spoiler]

I see roughly four different solutions:

  • Break up the consolidated rendering stack to be more modular, so that call sites have more control over the ouput format. This seems more complex than what I'm comfortable with as an external contributor.
  • Add a boolean parameter to the existing rendering function, to switch between behaviors.
  • Remove the spoilers from the generated html without actually parsing html, using replaceAll or (God forbid) some regex-based solution.

None of these are appealing to me, which is why I chose approach I ended up with. It's quite possible I'm missing an obvious solution, though, since I'm not familiar with the code base. What are your thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think it could do with some comments around the justification, and that only the textContent is seemingly safe to use, to avoid xss injection attacks given the untrusted input html

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

Labels

T-Enhancement Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content inside spoiler blocks should be excluded from notifications

2 participants