Skip to content

Claude/fix article link navigation#7

Merged
EthanThePhoenix38 merged 4 commits intomainfrom
claude/fix-article-link-navigation-eJWZa
Jan 8, 2026
Merged

Claude/fix article link navigation#7
EthanThePhoenix38 merged 4 commits intomainfrom
claude/fix-article-link-navigation-eJWZa

Conversation

@EthanThePhoenix38
Copy link
Member

Copilot AI review requested due to automatic review settings January 8, 2026 02:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances security by implementing XSS protection through DOMPurify sanitization and URL validation. The changes focus on preventing malicious script injection and ensuring only valid HTTP/HTTPS URLs are processed.

  • Added DOMPurify library (version 3.0.8) for XSS protection across all HTML files
  • Implemented URL scheme validation to prevent javascript: and other malicious protocols
  • Applied sanitization to user-generated content including article titles, sources, tags, and chart labels

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
stats.html Added DOMPurify CDN script and sanitization for chart labels and article data
reader.html Added DOMPurify CDN script, URL validation function, and sanitization for article metadata
portfolio.html Added DOMPurify CDN script, replaced escapeHtml with DOMPurify, added URL validation for repository links
README.md Removed log messages from aggregation process

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

</script>

<!-- DOMPurify for XSS protection -->
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.8/dist/purify.min.js"></script>
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

There is a version mismatch between the DOMPurify CDN version (3.0.8) being loaded and the package.json dependency version (3.3.1). This inconsistency could lead to unexpected behavior or missing security patches. Consider updating the CDN URL to use version 3.3.1 or use a caret/tilde version specifier to automatically get the latest patch version.

Suggested change
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.8/dist/purify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.3.1/dist/purify.min.js"></script>

Copilot uses AI. Check for mistakes.
Comment on lines +448 to +460
// Validate URL scheme to prevent XSS
function isValidHttpUrl(string) {
if (!string) return false;
try {
const url = new URL(string);
return url.protocol === 'http:' || url.protocol === 'https:';
} catch (_) {
return false;
}
}

// If article parameters exist and URL is valid, show article view
if (articleUrl && isValidHttpUrl(articleUrl)) {
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The URL validation logic only checks for http: and https: protocols, but does not protect against other XSS vectors. While the validation prevents javascript: URLs from being used, the validated articleUrl is still used directly in href and iframe.src assignments (lines 488-489, 496) without further sanitization. The validation should be followed by using the validated URL object's href property to ensure the URL is properly normalized.

Copilot uses AI. Check for mistakes.
try {
const urlObj = new URL(repo.html_url);
if (urlObj.protocol === 'http:' || urlObj.protocol === 'https:') {
url = DOMPurify.sanitize(repo.html_url);
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

Sanitizing URLs with DOMPurify.sanitize is ineffective for URL validation. DOMPurify is designed to sanitize HTML content, not validate URL schemes. The URL has already been validated by the URL constructor check above. Instead, use the validated URL object's href property directly, or simply use repo.html_url after successful validation without DOMPurify sanitization.

Suggested change
url = DOMPurify.sanitize(repo.html_url);
url = urlObj.href;

Copilot uses AI. Check for mistakes.
</script>

<!-- DOMPurify for XSS protection -->
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.8/dist/purify.min.js"></script>
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

There is a version mismatch between the DOMPurify CDN version (3.0.8) being loaded and the package.json dependency version (3.3.1). This inconsistency could lead to unexpected behavior or missing security patches. Consider updating the CDN URL to use version 3.3.1 or use a caret/tilde version specifier to automatically get the latest patch version.

Suggested change
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.8/dist/purify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.3.1/dist/purify.min.js"></script>

Copilot uses AI. Check for mistakes.
</script>

<!-- DOMPurify for XSS protection -->
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.8/dist/purify.min.js"></script>
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

There is a version mismatch between the DOMPurify CDN version (3.0.8) being loaded and the package.json dependency version (3.3.1). This inconsistency could lead to unexpected behavior or missing security patches. Consider updating the CDN URL to use version 3.3.1 or use a caret/tilde version specifier to automatically get the latest patch version.

Suggested change
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.8/dist/purify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.3.1/dist/purify.min.js"></script>

Copilot uses AI. Check for mistakes.
@EthanThePhoenix38 EthanThePhoenix38 merged commit df09e02 into main Jan 8, 2026
10 of 12 checks passed
@EthanThePhoenix38 EthanThePhoenix38 deleted the claude/fix-article-link-navigation-eJWZa branch January 8, 2026 03:13
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