mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
36 lines
631 B
JavaScript
36 lines
631 B
JavaScript
|
|
const { execSync } = require("child_process");
|
||
|
|
|
||
|
|
function getUserInput() {
|
||
|
|
return process.env.USER_INPUT || "";
|
||
|
|
}
|
||
|
|
|
||
|
|
function sanitizeHtml(input) {
|
||
|
|
return input.replace(/[<>&"']/g, "");
|
||
|
|
}
|
||
|
|
|
||
|
|
function renderPage(data) {
|
||
|
|
document.innerHTML = data;
|
||
|
|
}
|
||
|
|
|
||
|
|
function safeRender() {
|
||
|
|
const input = getUserInput();
|
||
|
|
const clean = sanitizeHtml(input);
|
||
|
|
renderPage(clean);
|
||
|
|
}
|
||
|
|
|
||
|
|
function unsafeRender() {
|
||
|
|
const input = getUserInput();
|
||
|
|
renderPage(input);
|
||
|
|
}
|
||
|
|
|
||
|
|
function runShell(cmd) {
|
||
|
|
execSync(cmd);
|
||
|
|
}
|
||
|
|
|
||
|
|
function unsafeExec() {
|
||
|
|
const input = getUserInput();
|
||
|
|
runShell(input);
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = { safeRender, unsafeRender, unsafeExec };
|