GPU benchmark: answer only its own page, and print what it sends as plain text

Any site open in the same browser could POST results (printed to the
terminal, escape sequences included, and written to --out), and DNS
rebinding could read the save. The server now checks the Host header and
the origin of a POST, caps the body at 2 MB, drops control characters,
and no longer sends stack traces. The panel no longer shows <sub> tags.
This commit is contained in:
Frederic Jung 2026-11-05 10:30:37 +01:00
parent 57c0594a90
commit f9c85ab0c3
No known key found for this signature in database
3 changed files with 73 additions and 4 deletions

View file

@ -130,7 +130,7 @@
mapGl(want0, false); await reset();
MD = table(res, env);
st(glOk ? 'Done. The results are also in the terminal.' : 'Done (no WebGL2 here: 2D only).');
box.querySelector('#bout').innerHTML = '<pre style="white-space:pre-wrap;font:11px/1.35 ui-monospace,monospace;margin:8px 0 0">' + MD.replace(/&/g, '&amp;').replace(/</g, '&lt;') + '</pre>';
box.querySelector('#bout').innerHTML = '<pre style="white-space:pre-wrap;font:11px/1.35 ui-monospace,monospace;margin:8px 0 0">' + MD.replace(/<\/?sub>/g, '').replace(/&/g, '&amp;').replace(/</g, '&lt;') + '</pre>';
box.querySelector('#bcp').hidden = false; go.disabled = false; go.textContent = 'Run again';
try { await fetch('/__bench/results', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ env, res, md: MD }) }); } catch (e) { /* the panel has them */ }
}