Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces DOMPurify into the codebase to sanitize HTML content in posts, comments, and error messages. It adds the dependency to package.json, updates components to use DOMPurify for sanitization, and documents the sanitization process in the README.
- Sanitize post content in pages/posts/[slug].js.
- Sanitize login error messages in components/Login.js.
- Sanitize comment content and reply messages in components/Comment.js.
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pages/posts/[slug].js | Wraps post HTML content with DOMPurify.sanitize |
| package.json | Adds the DOMPurify dependency |
| components/Login.js | Sanitizes error message HTML using DOMPurify |
| components/Comment.js | Sanitizes comment content and reply message HTML |
| README.md | Documents the HTML sanitization process |
| if (replyMessageElement) { | ||
| replyMessageElement.classList.add('bg-slate-200', 'flex', 'gap-3', 'p-5', 'inline-block', 'w-full', 'rounded'); | ||
| replyMessageElement.innerHTML = `<strong>Replying to comment:</strong> ${comment.content.rendered}`; | ||
| replyMessageElement.innerHTML = `<strong>Replying to comment:</strong> ${DOMPurify.sanitize(comment.content.rendered)}`; |
There was a problem hiding this comment.
[nitpick] Consider centralizing the DOMPurify.sanitize calls in a utility function (e.g., a helper like sanitizeHTML) to reduce duplication and simplify future updates to sanitization behavior.
Suggested change
| replyMessageElement.innerHTML = `<strong>Replying to comment:</strong> ${DOMPurify.sanitize(comment.content.rendered)}`; | |
| replyMessageElement.innerHTML = `<strong>Replying to comment:</strong> ${sanitizeHTML(comment.content.rendered)}`; |
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.
Summary
Testing
SITE_DOMAIN=example.com npm run linthttps://chatgpt.com/codex/tasks/task_e_686354f4a7ac8328bead2d96edf07e87