Skip to content
Merged
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/core/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@ export function Render(Base) {
sidebarToggleEl.setAttribute('aria-expanded', String(!isMobile()));

const activeElmHref = this.router.toURL(this.route.path);
const decodedHref = decodeURIComponent(activeElmHref);
const activeEl = /** @type {HTMLElement | null} */ (
dom.find(`.sidebar-nav a[href="${activeElmHref}"]`)
dom.find(
`.sidebar-nav a[href="${activeElmHref}"]${activeElmHref !== decodedHref ? `, .sidebar-nav a[href="${decodedHref}"]` : ''}`,
)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

decodeURIComponent(activeElmHref) can throw on malformed percent-encoding (e.g. a user navigates to a hash containing a raw %), which would break sidebar rendering here. Also, using the decoded value directly inside a CSS attribute selector can make querySelector throw if decoding introduces selector-breaking characters like " or \. Consider a safe decode (try/catch + fallback to original) and/or avoid interpolating unescaped URL strings into a selector (e.g., iterate anchors and compare getAttribute('href'), or escape via CSS.escape with a fallback).

Copilot uses AI. Check for mistakes.
);

this.#addTextAsTitleAttribute('.sidebar-nav a');
Expand Down