From b0e7781a26a3769025c144b26dfe1f7ca9816ec9 Mon Sep 17 00:00:00 2001 From: falc1 Date: Wed, 9 Apr 2025 22:55:33 +0400 Subject: [PATCH] Add JS code detection to prevent misuse of SimpleScript interpreter --- script.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/script.js b/script.js index 9c679a7..40a59cb 100644 --- a/script.js +++ b/script.js @@ -373,6 +373,17 @@ function runSimpleScript() { const code = editor.getValue(); const outputEl = document.getElementById('output'); outputEl.textContent = ''; + + try { + new Function(code); + outputEl.textContent = 'Error: HEY! Stop putting JS here, we are learning SimpleScript! Enter VALID SimpleScript code.'; + return; + } catch (e) { + // Continue to SimpleScript parsing + } + + + try { const lexer = new Lexer(code); const parser = new Parser(lexer);