content/media/test/redirect.sjs

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 function parseQuery(request, key) {
     2   var params = request.queryString.split('&');
     3   for (var j = 0; j < params.length; ++j) {
     4     var p = params[j];
     5 	if (p == key)
     6 	  return true;
     7     if (p.indexOf(key + "=") == 0)
     8 	  return p.substring(key.length + 1);
     9 	if (p.indexOf("=") < 0 && key == "")
    10 	  return p;
    11   }
    12   return false;
    13 }
    15 // Return file content for the first request with a given key.
    16 // All subsequent requests return a redirect to a different-origin resource.
    17 function handleRequest(request, response)
    18 {
    19   var domain = parseQuery(request, "domain");
    20   var file = parseQuery(request, "file");
    21   var allowed = parseQuery(request, "allowed");
    23   response.setStatusLine(request.httpVersion, 303, "See Other");
    24   response.setHeader("Location", "http://" + domain + "/tests/content/media/test/" + (allowed ? "allowed.sjs?" : "") + file);
    25   response.setHeader("Content-Type", "text/html");
    26 }

mercurial