Skip to content

Add HTML sanitization and error handling to MarkdownPreview#27

Merged
naheel0 merged 2 commits intotestfrom
copilot/sub-pr-24-another-one
Feb 12, 2026
Merged

Add HTML sanitization and error handling to MarkdownPreview#27
naheel0 merged 2 commits intotestfrom
copilot/sub-pr-24-another-one

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

Addresses two security and robustness issues in the MarkdownPreview component:

Changes

  • HTML Sanitization: Added rehype-sanitize to the ReactMarkdown rehypePlugins chain after rehypeRaw to prevent XSS from AI-generated content
  • Clipboard Error Handling: Wrapped navigator.clipboard.writeText() in try/catch to handle permission errors and prevent unhandled rejections
// Before
rehypePlugins={[rehypeRaw]}

// After  
rehypePlugins={[rehypeRaw, rehypeSanitize]}
// Before
const handleCopy = async () => {
  await navigator.clipboard.writeText(content);
  setCopied(true);
  setTimeout(() => setCopied(false), 2000);
};

// After
const handleCopy = async () => {
  try {
    await navigator.clipboard.writeText(content);
    setCopied(true);
    setTimeout(() => setCopied(false), 2000);
  } catch (error) {
    console.error('Failed to copy to clipboard:', error);
    setCopied(false);
  }
};

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI mentioned this pull request Feb 12, 2026
10 tasks
@vercel
Copy link

vercel bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
readme-gen-ai Ready Ready Preview, Comment Feb 12, 2026 4:31pm

Co-authored-by: naheel0 <191262736+naheel0@users.noreply.github.com>
@autofix-troubleshooter
Copy link

Hi! I'm the autofix logoautofix.ci troubleshooter bot.

It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! 😃

Copy link
Contributor Author

Copilot AI commented Feb 12, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/ReadmeGenAI/ReadmeGenAI/node_modules/.bin/next build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Add preview option for enhanced functionality Add HTML sanitization and error handling to MarkdownPreview Feb 12, 2026
Copilot AI requested a review from naheel0 February 12, 2026 16:33
@naheel0 naheel0 marked this pull request as ready for review February 12, 2026 16:38
@naheel0 naheel0 requested a review from adithyanmkd as a code owner February 12, 2026 16:38
@naheel0 naheel0 merged commit 2f7dd53 into test Feb 12, 2026
2 of 3 checks passed
@naheel0 naheel0 deleted the copilot/sub-pr-24-another-one branch February 12, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants