Skip to content

Commit cdb056e

Browse files
committed
Merge branch 'experiment/github-pages-website' of https://github.com/github/awesome-copilot into experiment/github-pages-website
2 parents bd7209a + a424744 commit cdb056e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

website/src/scripts/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ export function setupDropdownCloseHandlers(): void {
298298
export function getActionButtonsHtml(filePath: string, small = false): string {
299299
const btnClass = small ? 'btn-small' : '';
300300
const iconSize = small ? 14 : 16;
301-
const escapedPath = filePath.replace(/'/g, "\\'");
301+
// Escape backslashes first, then single quotes to prevent breaking out of the JavaScript string literal in the onclick attribute
302+
const escapedPath = filePath.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
302303

303304
return `
304305
<button class="btn btn-secondary ${btnClass} action-download" data-path="${escapeHtml(filePath)}" onclick="event.stopPropagation(); window.__downloadFile && window.__downloadFile('${escapedPath}')" title="Download file">

0 commit comments

Comments
 (0)