Repository navigation
Do not sanitize the plain-text organization invitation email - #52461
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression lacks automated coverage for both plain-text invitation paths.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Removes HTML sanitization from plain-text organization invitation emails so invitation URLs remain usable.
Changes:
- Directly renders localized invitation messages in both template branches.
- Automated coverage is needed for unescaped links in anonymous and personalized plain-text invitations.
File summaries
| File | Description |
|---|---|
themes/src/main/resources/theme/base/email/text/org-invite.ftl |
Prevents HTML encoding of plain-text invitation URLs. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
martin-kanis
suggested changes
Sep 29, 2026
martin-kanis
left a comment
Member
There was a problem hiding this comment.
@sashalab Thank you for the PR. You are right that a plain-text emails templates do not need sanitization, same as i.e password-reset.ftl, email-verification.ftl. Therefore the fix is correct.
You just need to sign your commit with -s before this PR is merged.
Thanks!
martin-kanis
approved these changes
Sep 30, 2026
pedroigor
approved these changes
Sep 30, 2026
kcSanitize HTML-encodes the invitation link (= becomes &keycloak#61;, & becomes &) in a template whose output format is plainText, which leaves the link in the text/plain part of the message unusable. Closes keycloak#52449
pedroigor
force-pushed
the
fix-org-invite-plaintext-link
branch
from
September 30, 2026 18:11
9330d90 to
ea4ac6a
Compare
PadzerButch
pushed a commit
to PadzerButch/keycloak
that referenced
this pull request
Oct 2, 2026
…k#52461) kcSanitize HTML-encodes the invitation link (= becomes &keycloak#61;, & becomes &) in a template whose output format is plainText, which leaves the link in the text/plain part of the message unusable. Closes keycloak#52449
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.

Closes #52449
base/email/text/org-invite.ftldeclaresoutput_format="plainText"but still passesthe message through
kcSanitize. The sanitizer HTML-encodes the invitation URL —=becomes
=and&becomes&— so the link in thetext/plainpart of theinvitation cannot be used. The
text/htmlpart is unaffected.Both branches of the template are affected (with and without the invitee's name), and
so are both endpoints,
invite-userandinvite-existing-user.No other plain-text email template sanitizes a message containing a link:
password-reset.ftl,email-verification.ftl,executeActions.ftl,identity-provider-link.ftlandemail-update-confirmation.ftlinterpolatemsg(...)directly. (
text/workflow-notification.ftlalso callskcSanitize, but it carries nolink.)
Verification
Manual, against 26.7.2 with a local mail catcher, following the reproduction in #52449:
before the change the
text/plainpart contained.../login-actions/action-token?key=eyJhbGciOi...; after it, the same URL as thetext/htmlpart.I did not add an automated test: I could not run the integration suite in my
environment, and I would rather not submit a test I have not executed. Happy to add one
if you point me at the right test class.