fix: use DOM parser for heading slug generation to prevent XSS#3290
fix: use DOM parser for heading slug generation to prevent XSS#3290jeanfbrito merged 1 commit intodevfrom
Conversation
Replace regex-based HTML stripping with document.createElement + textContent for safe text extraction. Fixes CodeQL incomplete multi-character sanitization warning.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📓 Common learnings🔇 Additional comments (1)
WalkthroughThe markdown heading slug generation in MarkdownContent.tsx was updated to extract heading text using a temporary DOM element with Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
/<[^>]*>/g) withdocument.createElement('div')+.textContentfor safe text extraction in heading slug generationContext
The previous regex could leave partial HTML tags (e.g.,
<scriptwithout closing>) in the slug, which CodeQL flagged as a potential injection vector. Using the browser's DOM parser eliminates this class of vulnerability entirely.Test plan
Summary by CodeRabbit