mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-15 20:05:13 +02:00
31 lines
593 B
TypeScript
31 lines
593 B
TypeScript
|
|
import { execSync } from "child_process";
|
||
|
|
|
||
|
|
function getUserInput(): string {
|
||
|
|
return process.env.USER_INPUT || "";
|
||
|
|
}
|
||
|
|
|
||
|
|
function sanitizeHtml(input: string): string {
|
||
|
|
return input.replace(/[<>&"']/g, "");
|
||
|
|
}
|
||
|
|
|
||
|
|
function renderPage(data: string): void {
|
||
|
|
document.body.innerHTML = data;
|
||
|
|
}
|
||
|
|
|
||
|
|
function runCommand(cmd: string): void {
|
||
|
|
execSync(cmd);
|
||
|
|
}
|
||
|
|
|
||
|
|
function safeRender(): void {
|
||
|
|
const input = getUserInput();
|
||
|
|
const clean = sanitizeHtml(input);
|
||
|
|
renderPage(clean);
|
||
|
|
}
|
||
|
|
|
||
|
|
function unsafeExec(): void {
|
||
|
|
const input = getUserInput();
|
||
|
|
runCommand(input);
|
||
|
|
}
|
||
|
|
|
||
|
|
export { safeRender, unsafeExec };
|