fix(conductor): escape raw HTML before marked to block stored XSS
renderMd fed untrusted chat/log into marked → innerHTML; strip '<' so scripts/on* payloads cannot navigate (e.g. /login?from=/scriptText). Markdown links and bare URLs remain intact.
This commit is contained in:
1 parent
4570a63466
commit
a6ea3fa53c
1 file changed
+1
-1
@@ -381,7 +381,7 @@
|
|||||||
let ws, fileDir='', fileParent='';
|
let ws, fileDir='', fileParent='';
|
||||||
|
|
||||||
function esc(s){ return String(s||'').replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c])); }
|
function esc(s){ return String(s||'').replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c])); }
|
||||||
function renderMd(s){ try { return marked.parse(s||'', { breaks: true, gfm: true }); } catch(e){ return esc(s); } }
|
function renderMd(s){ try { return marked.parse(String(s||'').replace(/</g,'<'), { breaks: true, gfm: true }); } catch(e){ return esc(s); } }
|
||||||
function fileUrl(path){ return '/file?path='+encodeURIComponent(path); }
|
function fileUrl(path){ return '/file?path='+encodeURIComponent(path); }
|
||||||
function humanSize(n){ return n==null?'':n<1024?n+' B':n<1048576?(n/1024).toFixed(1)+' KB':(n/1048576).toFixed(1)+' MB'; }
|
function humanSize(n){ return n==null?'':n<1024?n+' B':n<1048576?(n/1024).toFixed(1)+' KB':(n/1048576).toFixed(1)+' MB'; }
|
||||||
async function browseFiles(path=''){
|
async function browseFiles(path=''){
|
||||||
|
|||||||
Reference in new issue
Block a user