Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,17 @@ <h4>On this page</h4>
return text.toLowerCase().replace(/[^\w]+/g, '-').replace(/^-|-$/g, '');
}

// Basic HTML escaping to prevent XSS when inserting untrusted values
function escapeHtml(str) {
return String(str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/\//g, '&#x2F;');
}

// Simple markdown to HTML parser with anchor generation
function parseMarkdown(md) {
let html = md;
Expand Down Expand Up @@ -389,10 +400,11 @@ <h4>On this page</h4>

// Fetch and display documentation
async function loadDoc(filename) {
const safeFilename = escapeHtml(filename);
Comment on lines 402 to +403
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While HTML escaping prevents XSS in the displayed content, the filename parameter still comes from user-controlled input (window.location.hash via init()) without validation. Consider adding explicit validation at the start of this function to ensure the filename matches one of the allowed documents. For example, you could define an allowlist of valid filenames (TECHNIQUE.md, READER_MODE_PLAN.md, SUPABASE_MIGRATION.md, ACTION_README.md) and reject any filename that's not in the list. This would provide defense in depth against potential SSRF or path traversal issues when constructing the GitHub API URL on line 413.

Copilot uses AI. Check for mistakes.
docsContent.innerHTML = `
<div class="loading-docs">
<div class="loading-spinner"></div>
<p>Loading ${filename}...</p>
<p>Loading ${safeFilename}...</p>
</div>
`;

Expand All @@ -417,9 +429,9 @@ <h4>On this page</h4>
console.error('Error loading doc:', error);
docsContent.innerHTML = `
<h1>Error Loading Documentation</h1>
<p>Failed to load ${filename}. Please try again later.</p>
<p>Failed to load ${safeFilename}. Please try again later.</p>
<p style="margin-top: 20px;">
<a href="https://github.com/${DOCS_CONFIG.owner}/${DOCS_CONFIG.repo}/blob/${DOCS_CONFIG.branch}/${DOCS_CONFIG.docsPath}/${filename}" target="_blank">
<a href="https://github.com/${DOCS_CONFIG.owner}/${DOCS_CONFIG.repo}/blob/${DOCS_CONFIG.branch}/${DOCS_CONFIG.docsPath}/${safeFilename}" target="_blank">
View on GitHub
</a>
</p>
Expand Down