Skip to content

Commit 618a9c1

Browse files
javutoCopilot
andauthored
Update cmd/admin/static/js/query.js
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8258ede commit 618a9c1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmd/admin/static/js/query.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ function escapeHTML(value) {
124124
function safeHref(href) {
125125
const s = String(href || "").trim();
126126
const lower = s.toLowerCase();
127-
if (!s || lower.startsWith("javascript:") || lower.startsWith("data:") || lower.startsWith("vbscript:")) {
128-
return "#";
127+
// Allow relative URLs (path, hash, or query only)
128+
if (s.startsWith("/") || s.startsWith("#") || s.startsWith("?")) {
129+
return s;
129130
}
130-
return s;
131+
// Allow only http and https absolute URLs
132+
if (lower.startsWith("http://") || lower.startsWith("https://")) {
133+
return s;
134+
}
135+
// Fallback for disallowed or empty URLs
136+
return "#";
131137
}
132138

133139
function queryResultLink(link, query, url) {

0 commit comments

Comments
 (0)