fix malformed input issue when there is nothing malformed

This commit is contained in:
biglyderv 2025-04-12 23:59:47 -04:00
parent 5e58deb712
commit e3669e8d42
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
3 changed files with 14 additions and 12 deletions

View file

@ -45,17 +45,18 @@ app.post('/', async function (req, res) {
}) })
} }
channels[id] = res;
let fsession = channels[id];
setTimeout(async function () { setTimeout(async function () {
if (!sessions[id]) return; if (fsession != channels[id]) return;
if (channels[id].headersSent) return; if (channels[id].headersSent) return;
try { try {
channels[id].send('Input is possibly malformed.').header('access-allow-control-origin', '*') channels[id].send('Input is possibly malformed.').header('access-allow-control-origin', '*')
} catch (err) { } catch (err) {
} }
}, 1000); }, 600);
channels[id] = res;
let msgs = req.body.data.split('\n'); let msgs = req.body.data.split('\n');
@ -66,6 +67,7 @@ app.post('/', async function (req, res) {
} }
setTimeout(async function () { setTimeout(async function () {
sessions[id].lastBusy = new Date();
sessions[id].stdin.write(msg + '\n'); sessions[id].stdin.write(msg + '\n');
}, 100); }, 100);
}); });

View file

@ -6,18 +6,20 @@ button {
body { body {
margin: 0; margin: 0;
padding-bottom: 3rem; display: flex;
flex-direction: column;
justify-content: space-between;
height: 100vh;
} }
#form { #form {
background: rgba(0, 0, 0, 0.15); background: rgba(0, 0, 0, 0.15);
padding: 0.25rem; padding: 0.25rem;
position: fixed;
bottom: 0;
left: 0;
right: 0;
box-sizing: border-box; box-sizing: border-box;
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
position: sticky;
bottom: 0;
} }
.inner-form { .inner-form {

View file

@ -33,6 +33,4 @@ async function main(e) {
form.addEventListener('submit', main); form.addEventListener('submit', main);
document.querySelector('.send').addEventListener('click',function() { document.querySelector('.send').addEventListener('click',main);
main({preventDefault: () => {}})
})