~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/console/console.js

  • Committer: mattgiuca
  • Date: 2008-07-21 04:21:18 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:917
interpret.py: Removed the code which removes HTTP_COOKIE from the CGI
    environment. Student code can now access cookies.
Note: This was previously a security risk because malicious code could
steal IVLE cookies. Now that we have separate domain space for other users,
the worst you can do is:
    a) Steal your own IVLE cookie.
    b) Steal other user's non-IVLE cookies (ie. other public cookies).

This makes all student code vulnerable to cookie theft, but that is simply a
disclaimer (if you use cookies, your apps are vulnerable). It is not a
security risk to IVLE itself.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
            if (callback != null)
64
64
                callback();
65
65
        }
66
 
    ajax_call(callback1, "consoleservice", "start", {}, "POST");
 
66
 
 
67
    //var current_path;
 
68
    if(typeof(current_path) != 'undefined')
 
69
    {
 
70
        // We have a current_path - give a suggestion to the server
 
71
        var path;
 
72
        if (current_file.isdir)
 
73
        {
 
74
            // Browser
 
75
            path = path_join("/home", current_path);
 
76
        }
 
77
        else
 
78
        {
 
79
            // Editor - need to chop off filename
 
80
            var tmp_path = current_path.split('/');
 
81
            tmp_path.pop();
 
82
            path = path_join("/home", tmp_path.join('/'));
 
83
        }
 
84
        ajax_call(callback1, "consoleservice", "start", {"startdir": path}, "POST");
 
85
    }
 
86
    else
 
87
    {
 
88
        // No current_path - let the server decide
 
89
        ajax_call(callback1, "consoleservice", "start", {}, "POST");
 
90
    }
67
91
}
68
92
 
69
93
/** Initialises the console. All apps which import console are required to
279
303
    var output = document.getElementById("console_output");
280
304
    if (res.hasOwnProperty('okay'))
281
305
    {
282
 
        // Success!
283
 
        if (res.okay)
284
 
        {
285
 
            output.appendChild(document.createTextNode(res.okay + "\n"));
286
 
            output.appendChild(span);
287
 
        }
288
306
        // set the prompt to >>>
289
307
        var prompt = document.getElementById("console_prompt");
290
308
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
301
319
        var prompt = document.getElementById("console_prompt");
302
320
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
303
321
    }
 
322
    else if (res.hasOwnProperty('restart') && res.hasOwnProperty('key'))
 
323
    {
 
324
        // Server has indicated that the console should be restarted
 
325
        
 
326
        // Get the new key (host, port, magic)
 
327
        server_key = res.key;
 
328
 
 
329
        // Print a reason to explain why we'd do such a horrible thing
 
330
        // (console timeout, server error etc.)
 
331
        var span = document.createElement("span");
 
332
        span.setAttribute("class", "errorMsg");
 
333
        span.appendChild(document.createTextNode("Console Restart: " + res.restart + "\n"));
 
334
        output.appendChild(span);
 
335
        // set the prompt to >>>
 
336
        var prompt = document.getElementById("console_prompt");
 
337
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
 
338
 
 
339
    }
304
340
    else if (res.hasOwnProperty('more'))
305
341
    {
306
342
        // Need more input, so set the prompt to ...