Skip to content

Commit 6cd7eee

Browse files
authored
release(v3.1.6): CodeQL fix for error handling (strip HTML safely in fileActions)
1 parent ed25237 commit 6cd7eee

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Changelog
22

3-
## Changes 01/24/2026 (v3.1.5)
3+
## Changes 01/24/2026 (v3.1.5 & v3.1.6)
44

5+
`release(v3.1.6): CodeQL fix for error handling (strip HTML safely in fileActions)`
56
`release(v3.1.5): Pro Sources adds OneDrive + Dropbox + source-aware UX fixes`
67

78
**Commit message**

public/js/fileActions.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ function getTransferTotalsForNames(names) {
5454
};
5555
}
5656

57+
function stripHtmlToText(raw) {
58+
const input = raw == null ? '' : String(raw);
59+
if (input === '') return '';
60+
if (typeof DOMParser !== 'undefined') {
61+
try {
62+
const doc = new DOMParser().parseFromString(input, 'text/html');
63+
const out = doc && doc.body ? doc.body.textContent : '';
64+
return (out || '').trim();
65+
} catch (e) {
66+
// Fall through to basic stripping.
67+
}
68+
}
69+
return input.replace(/[<>]/g, '').trim();
70+
}
71+
5772
const ARCHIVE_FORMATS = ["zip", "7z"];
5873
const ARCHIVE_NAME_SUFFIXES = ["zip", "7z", "rar"];
5974
const ARCHIVE_EXT_RE = /\.(zip|7z|rar)$/i;
@@ -600,7 +615,7 @@ export async function handleCreateFile(e) {
600615
try { js = JSON.parse(raw); } catch (e) { js = null; }
601616
}
602617
if (!res.ok || !js || !js.success) {
603-
const text = raw ? raw.replace(/<[^>]*>/g, '').trim() : '';
618+
const text = stripHtmlToText(raw);
604619
const msg = (js && (js.error || js.message)) || text || `HTTP ${res.status}`;
605620
throw new Error(msg);
606621
}

0 commit comments

Comments
 (0)