Skip to content

Task/multipart upload #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 11, 2025
Merged

Task/multipart upload #32

merged 4 commits into from
Jul 11, 2025

Conversation

tirthbodawala
Copy link
Member

Experiment with multipart upload

Comment on lines +151 to +157
resultMsg.innerHTML = `<b>File:</b> ${file.name}<br>
<b>Size:</b> ${(file.size / 1024 / 1024).toFixed(2)} MB<br>
<b>SHA-256:</b> ${fileHash}<br>
<b>UploadId:</b> ${uploadId}<br>
<b>Key:</b> ${key}<br>
<b>Chunks uploaded:</b> ${parts.length}<br>
<b>Final ETag:</b> ${completeResult.etag || 'N/A'}`;

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium test

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 6 days ago

To fix the issue, the file name (file.name) and other dynamic data should be safely escaped before being inserted into the DOM using innerHTML. Escaping ensures that special characters in the file name (like <, >, &, etc.) are treated as plain text rather than HTML or JavaScript.

The best way to fix this is to use textContent instead of innerHTML, as textContent safely inserts text into the DOM without interpreting it as HTML. Alternatively, you can sanitize the dynamic data before using innerHTML, but using textContent is simpler and avoids the risk of improper sanitization.

Changes to be made:

  • Replace all instances of innerHTML where untrusted data is interpolated with textContent.
  • Specifically, update line 151 to ensure file.name and other interpolated values are safely added to the DOM as plain text.

Suggested changeset 1
test.html

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test.html b/test.html
--- a/test.html
+++ b/test.html
@@ -148,13 +148,13 @@
           // --- Done ---
           statusMsg.textContent = 'Upload complete!';
           progressBar.style.width = '100%';
-          resultMsg.innerHTML = `<b>File:</b> ${file.name}<br>
-          <b>Size:</b> ${(file.size / 1024 / 1024).toFixed(2)} MB<br>
-          <b>SHA-256:</b> ${fileHash}<br>
-          <b>UploadId:</b> ${uploadId}<br>
-          <b>Key:</b> ${key}<br>
-          <b>Chunks uploaded:</b> ${parts.length}<br>
-          <b>Final ETag:</b> ${completeResult.etag || 'N/A'}`;
+          resultMsg.textContent = `File: ${file.name}\n` +
+          `Size: ${(file.size / 1024 / 1024).toFixed(2)} MB\n` +
+          `SHA-256: ${fileHash}\n` +
+          `UploadId: ${uploadId}\n` +
+          `Key: ${key}\n` +
+          `Chunks uploaded: ${parts.length}\n` +
+          `Final ETag: ${completeResult.etag || 'N/A'}`;
         } catch (err) {
           showError(err.message || err);
         }
EOF
@@ -148,13 +148,13 @@
// --- Done ---
statusMsg.textContent = 'Upload complete!';
progressBar.style.width = '100%';
resultMsg.innerHTML = `<b>File:</b> ${file.name}<br>
<b>Size:</b> ${(file.size / 1024 / 1024).toFixed(2)} MB<br>
<b>SHA-256:</b> ${fileHash}<br>
<b>UploadId:</b> ${uploadId}<br>
<b>Key:</b> ${key}<br>
<b>Chunks uploaded:</b> ${parts.length}<br>
<b>Final ETag:</b> ${completeResult.etag || 'N/A'}`;
resultMsg.textContent = `File: ${file.name}\n` +
`Size: ${(file.size / 1024 / 1024).toFixed(2)} MB\n` +
`SHA-256: ${fileHash}\n` +
`UploadId: ${uploadId}\n` +
`Key: ${key}\n` +
`Chunks uploaded: ${parts.length}\n` +
`Final ETag: ${completeResult.etag || 'N/A'}`;
} catch (err) {
showError(err.message || err);
}
Copilot is powered by AI and may make mistakes. Always verify output.
@tirthbodawala tirthbodawala merged commit 5aa7e08 into main Jul 11, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant