Skip to content

Commit b10548e

Browse files
fix(page): DOM text reinterpreted as HTML (#10)
1 parent 7f12576 commit b10548e

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

  • open-agent-auth-spring-boot-starter/src/main/resources/templates/admin

open-agent-auth-spring-boot-starter/src/main/resources/templates/admin/dashboard.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,26 @@ <h2>No Capabilities Available</h2>
349349
}
350350
});
351351

352+
function isSafeFrameUrl(rawUrl) {
353+
if (!rawUrl || typeof rawUrl !== 'string') {
354+
return false;
355+
}
356+
var url = rawUrl.trim();
357+
if (url === '') {
358+
return false;
359+
}
360+
try {
361+
var parsed = new URL(url, window.location.origin);
362+
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
363+
} catch (e) {
364+
return false;
365+
}
366+
}
367+
352368
function navigateTo(element) {
353369
var url = element.getAttribute('data-url');
354370
var frame = document.getElementById('contentFrame');
355-
if (frame) {
371+
if (frame && isSafeFrameUrl(url)) {
356372
frame.src = url;
357373
}
358374

0 commit comments

Comments
 (0)