-
Notifications
You must be signed in to change notification settings - Fork 86
fix: do not escape HTML #2007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not escape HTML #2007
Conversation
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-edge-middleware ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for nextjs-plugin-custom-routes-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a suggestion, but this works great!
demos/middleware/middleware.ts
Outdated
@@ -24,7 +24,7 @@ export async function middleware(req: NextRequest) { | |||
if (pathname.startsWith('/static')) { | |||
// Unlike NextResponse.next(), this actually sends the request to the origin | |||
const res = await request.next() | |||
const message = `This was static but has been transformed in ${req.geo?.city}` | |||
const message = `This was static & old but has been transformed in ${req.geo?.city}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are great. I wonder if it makes sense to test that &
would render as the text &
? The only use case for that that I can think of is if a code example was in a prop being set. Maybe not worth it. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Summary
When
setPageProp
is called it in turn callstransformData
which pushes to thedataTransforms
array. Inside the shared edge util it gets accessed:https://github.com/netlify/next-runtime/blob/fb93b5469c570616134d53c10fbed1f7ef78e334/packages/runtime/src/templates/edge-shared/utils.ts#L203-L225
The HTML rewriter is a Deno port of https://developers.cloudflare.com/workers/runtime-apis/html-rewriter/.
By default it escapes HTML, but there is a
html
setting: https://developers.cloudflare.com/workers/runtime-apis/html-rewriter/#global-typesSo we can just set this to
true
and fix the issue of incorrectly escaping raw HTML while rewriting the HTML.Test plan
See that the changed e2e test still passes.
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal
Fixes #1629
Standard checks:
🧪 Once merged, make sure to update the version if needed and that it was published correctly.