Skip to content

fix(hanko): use markdown media type for profile modal#139

Merged
markdumay merged 1 commit into
mainfrom
fix/hanko-modal-media-type
Jun 26, 2026
Merged

fix(hanko): use markdown media type for profile modal#139
markdumay merged 1 commit into
mainfrom
fix/hanko-modal-media-type

Conversation

@markdumay

Copy link
Copy Markdown
Contributor

Hugo v0.162.0 added the security.allowContent policy, which denies the text/html content 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:

access denied: "text/html" is not whitelisted in policy "security.allowContent"
  allowContent = ['! ^text/html$']

Fix

Rename content/_modals/profile.htmlcontent/_modals/profile.md (no content change). A .md page declares the text/markdown media type, which is whitelisted. The {{< ModalProfile >}} shortcode output still passes through verbatim — shortcode placeholders are substituted after Goldmark, so they are not subject to markup.goldmark.renderer.unsafe. This mirrors how mod-flexsearch already handles its search modal (a text/markdown content adapter wrapping {{< ModalSearch >}}).

Verification

Tested against infusal/app on Hugo v0.162.1 using a Hugo module replace pointing at this branch:

  • Before: build fails with the allowContent error above.
  • After: build succeeds (472 pages); the profile modal renders verbatim into all pages (<div id="profile-modal" class="modal fade profile-modal" …><hanko-profile></div>), with 0 <p>-wrapping, 0 escaped/stripped HTML, and no standalone /_modals/profile page leaked (the render: never cascade is respected). Rendered output is identical to the previous .html version.

The module's own exampleSite build (pre-commit npm test) also passes.

🤖 Generated with Claude Code

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>
@markdumay markdumay merged commit 35f34ed into main Jun 26, 2026
8 checks passed
@markdumay markdumay deleted the fix/hanko-modal-media-type branch June 26, 2026 06:15
@markdumay

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 2.2.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant