Skip to content
Draft
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
20 changes: 19 additions & 1 deletion docs/source/_static/js/version-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,25 @@ document.addEventListener("DOMContentLoaded", function () {

// Navigate to the selected version on change
dropdown.addEventListener("change", function () {
window.location.href = this.value;
const selectedValue = this.value;
if (!selectedValue) {
return;
}

try {
// Normalize relative URLs against the current origin
const targetUrl = new URL(selectedValue, window.location.origin);

// Only allow navigation to http(s) URLs
if (targetUrl.protocol === "http:" || targetUrl.protocol === "https:") {
window.location.href = targetUrl.toString();
} else {
console.error("Blocked navigation to unsafe URL scheme:", targetUrl.href);
}
} catch (e) {
// If the value is not a valid URL, do not navigate
console.error("Invalid URL in version picker:", selectedValue, e);
}
});

// Add elements to the version picker
Expand Down
Loading