Skip to content

Commit fd31ccb

Browse files
committed
Restrict Verify integrity file picker to .sha256 files only
Add input.accept='.sha256' to limit file picker to .sha256 files, plus an onchange guard that rejects non-.sha256 selections (fallback for browsers like macOS Safari that ignore custom extensions in accept). https://claude.ai/code/session_01HnKMFA576NFwa2RzB8vCqE
1 parent ad22bd5 commit fd31ccb

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Services/HtmlReport/diff_report.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,17 @@
149149
}
150150
var input = document.createElement('input');
151151
input.type = 'file';
152+
input.accept = '.sha256';
152153
input.style.display = 'none';
153154
document.body.appendChild(input);
154155
input.onchange = async function() {
155156
var file = input.files[0];
156157
document.body.removeChild(input);
157158
if (!file) return;
159+
if (!file.name.endsWith('.sha256')) {
160+
alert('Please select a .sha256 file.');
161+
return;
162+
}
158163
var sha256Text = await file.text();
159164
var match = sha256Text.match(/^([0-9a-f]{64})\b/i);
160165
if (!match) {

doc/samples/diff_report.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,12 +1093,17 @@ <h2 style="color:#0051c3">[ ! ] Modified Files &#x2014; Timestamps Regressed (5)
10931093
}
10941094
var input = document.createElement('input');
10951095
input.type = 'file';
1096+
input.accept = '.sha256';
10961097
input.style.display = 'none';
10971098
document.body.appendChild(input);
10981099
input.onchange = async function() {
10991100
var file = input.files[0];
11001101
document.body.removeChild(input);
11011102
if (!file) return;
1103+
if (!file.name.endsWith('.sha256')) {
1104+
alert('Please select a .sha256 file.');
1105+
return;
1106+
}
11021107
var sha256Text = await file.text();
11031108
var match = sha256Text.match(/^([0-9a-f]{64})\b/i);
11041109
if (!match) {

0 commit comments

Comments
 (0)