mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-10-27 07:52:03 +00:00
Fix XSS vulnerability in docs search highlighting
- Implement `escapeHtml` function in `docs/assets/theme.js` - Update `highlight` function to safely escape content before wrapping matches in `<mark>` tags - Update `torch/src/todo/TODO_2026-02-16T11:47:38Z.md` to mark task as completed Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
c6560305a9
commit
f38bbe57d2
2 files changed
+23
-1
No files matched your search
+18
-1
@@ -46,9 +46,26 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
if (!text) return text;
|
||||
return text
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
function highlight(text, q) {
|
||||
if (!q) return escapeHtml(text);
|
||||
const re = new RegExp('(' + q.replace(/[.*+?^${}()|[\\]\\]/g, '\\$&') + ')', 'gi');
|
||||
return text.replace(re, '<mark>$1</mark>');
|
||||
return text.split(re).map((part, index) => {
|
||||
if (index % 2 === 1) {
|
||||
return '<mark>' + escapeHtml(part) + '</mark>';
|
||||
} else {
|
||||
return escapeHtml(part);
|
||||
}
|
||||
}).join('');
|
||||
}
|
||||
|
||||
searchInput?.addEventListener('input', async e => {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# TODO: bug-reproducer-agent run 2026-02-16T11:47:38Z
|
||||
|
||||
- Agent: bug-reproducer-agent
|
||||
- Status: Completed
|
||||
- Resolution: Fixed XSS vulnerability in docs/assets/theme.js
|
||||
Reference in new issue
Block a user