Skip to content

Commit 11a70ed

Browse files
committed
sec(handlersUtil.js): Fix softvar#43, softvar#96
1 parent 15b6c97 commit 11a70ed

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Diff for: src/utils/handlersUtil.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const handlersUtil = {
1111
<button aria-label="Copy file contents to clipboard" class="js-file-clipboard btn btn-sm BtnGroup-item file-clipboard-button tooltipped tooltipped-s js-enhanced-github-copy-btn" data-copied-hint="Copied!" type="button" click="selectText()" data-clipboard-target="tbody">
1212
Copy File
1313
</button>
14-
<a href="${data.download_url}" download="${data.name}"
14+
<a href="${data.download_url}" download="${encodeURIComponent(data.name)}"
1515
aria-label="(Alt/Option/Ctrl + Click) to download File" class="js-file-download btn btn-sm BtnGroup-item file-download-button tooltipped tooltipped-s">
1616
<span style="margin-right: 5px;">${formattedFileSize}</span>
1717
<svg class="octicon octicon-cloud-download" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16">
@@ -73,23 +73,24 @@ const handlersUtil = {
7373

7474
for (var i = startIndex; i < containerItems.length; i++) {
7575
const commitElem = containerItems[i].querySelector('div:nth-of-type(3)');
76-
const isValidFile = data[actualDataIndex].type === 'file' && data[actualDataIndex].size !== 0;
76+
const fileMetadata = data[actualDataIndex];
77+
const isValidFile = fileMetadata.type === 'file' && fileMetadata.size !== 0;
7778

7879
if (commitElem) {
7980
containerItems[i].querySelector('div:nth-of-type(2)').classList.remove('col-md-2', 'mr-3');
8081
containerItems[i].querySelector('div:nth-of-type(2)').classList.add('col-md-1', 'mr-2');
8182

82-
if (isValidFile || data[actualDataIndex].type === 'symlink') {
83-
const formattedFileSize = commonUtil.getFileSizeAndUnit(data[actualDataIndex]);
83+
if (isValidFile || fileMetadata.type === 'symlink') {
84+
const formattedFileSize = commonUtil.getFileSizeAndUnit(fileMetadata);
8485

8586
const html = `
8687
<div role="gridcell" class="mr-1 text-gray-light eg-download" style="width: 95px;">
8788
<span class="css-truncate css-truncate-target d-block">
8889
<span style="margin-right: 5px;">
8990
${formattedFileSize}
9091
</span>
91-
<a style="float: right" href="${data[actualDataIndex].download_url}" title="(Alt/Option/Ctrl + Click) to download File" aria-label="(Alt/Option/Ctrl + Click) to download File" class="tooltipped tooltipped-s"
92-
download="${data[actualDataIndex].name}">
92+
<a style="float: right" href="${fileMetadata.download_url}" title="(Alt/Option/Ctrl + Click) to download File" aria-label="(Alt/Option/Ctrl + Click) to download File" class="tooltipped tooltipped-s"
93+
download="${encodeURIComponent(fileMetadata.name)}">
9394
<svg class="octicon octicon-cloud-download" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16">
9495
<path d="M9 12h2l-3 3-3-3h2V7h2v5zm3-8c0-.44-.91-3-4.5-3C5.08 1 3 2.92 3 5 1.02 5 0 6.52 0 8c0 1.53 1 3 3 3h3V9.7H3C1.38 9.7 1.3 8.28 1.3 8c0-.17.05-1.7 1.7-1.7h1.3V5c0-1.39 1.56-2.7 3.2-2.7 2.55 0 3.13 1.55 3.2 1.8v1.2H12c.81 0 2.7.22 2.7 2.2 0 2.09-2.25 2.2-2.7 2.2h-2V11h2c2.08 0 4-1.16 4-3.5C16 5.06 14.08 4 12 4z"></path>
9596
</svg>

0 commit comments

Comments
 (0)