fix(hanko): use markdown media type for profile modal#139
Merged
Conversation
Hugo v0.162.0 added the security.allowContent policy, which denies the
text/html content media type by default as XSS hardening. The profile
modal shipped as content/_modals/profile.html, so sites consuming this
module fail to build on Hugo >= 0.162:
access denied: "text/html" is not whitelisted in policy
"security.allowContent"
Rename the page to .md so it declares the text/markdown media type, which
is whitelisted. The {{< ModalProfile >}} shortcode output still passes
through verbatim (shortcode placeholders bypass goldmark), so the rendered
modal is unchanged. This mirrors the approach mod-flexsearch already uses
for its search modal.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
🎉 This PR is included in version 2.2.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Hugo v0.162.0 added the
security.allowContentpolicy, which denies thetext/htmlcontent media type by default as XSS hardening (see the v0.162.0 release notes). This module ships its profile modal as an HTML content page (content/_modals/profile.html), so every site consuming it fails to build on Hugo ≥ 0.162:Fix
Rename
content/_modals/profile.html→content/_modals/profile.md(no content change). A.mdpage declares thetext/markdownmedia type, which is whitelisted. The{{< ModalProfile >}}shortcode output still passes through verbatim — shortcode placeholders are substituted after Goldmark, so they are not subject tomarkup.goldmark.renderer.unsafe. This mirrors how mod-flexsearch already handles its search modal (atext/markdowncontent adapter wrapping{{< ModalSearch >}}).Verification
Tested against
infusal/appon Hugo v0.162.1 using a Hugo modulereplacepointing at this branch:allowContenterror above.<div id="profile-modal" class="modal fade profile-modal" …><hanko-profile></div>), with 0<p>-wrapping, 0 escaped/stripped HTML, and no standalone/_modals/profilepage leaked (therender: nevercascade is respected). Rendered output is identical to the previous.htmlversion.The module's own
exampleSitebuild (pre-commitnpm test) also passes.🤖 Generated with Claude Code