I would like to implement a scripting language to assist in partially automating certain tasks on a public wiki. I cannot install anything such as Google Caja on the server or modify the wiki software itself, but I can install JavaScript code for client-side execution. Because my intent is to allow ordinary users to create and post scripts, using JavaScript itself is insecure and could lead to account compromises.
Does such a scripting language implementation exist, or if not, is it relatively easy to create? My focus is on ease of text processing, Ajax requests, and implementation.
Here is an example task a script would need to perform, taken from Wikipedia's procedure for requesting article deletion:
Here's an implementation of Tcl in javascript: Tcl in Javascript.
Here's the source: tcl.js.
And here's code implementing a live console in your browser to play with: A little tcl.js console
Tcl may not be your cup of tea but the implementation looks fairly simple straightforward. This is mainly because tcl itself is such a simple language. You can use it to get ideas on how to implement variables and functions.
Hint: in tcl, control structures are functions so look at where built-in functions are implemented to see the implementation of for, while and foreach.
Douglas Crockford's ADsafe is supposed to be a secure subset of JavaScript.
It consists of a runtime library (~20 KB minified) and a verifier (included in JSLint). If Crockford were to drop "The Software shall be used for Good, not Evil" from the license, both components would be GPL-compatible open-source programs.
Because JSLint is a JavaScript program, it can verify user scripts entirely within the web browser. This is in contrast to Google Caja, which is written in Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With