summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas BrĂ¼derli2007-10-02 12:34:59 +0000
committerThomas BrĂ¼derli2007-10-02 12:34:59 +0000
commit8ddceef470edc16669317965cee69982ff0c6e35 (patch)
tree79ed08cbc8ec8114145407c6cb13e369a337f446
parentbbaf65234fc69effce584b6e6b89173693ad907a (diff)
downloaditools-8ddceef470edc16669317965cee69982ff0c6e35.tar.gz
itools-8ddceef470edc16669317965cee69982ff0c6e35.tar.bz2
itools-8ddceef470edc16669317965cee69982ff0c6e35.zip
Check script length with comment cookie
-rw-r--r--itjs.php5
-rw-r--r--itjs/boot.js20
2 files changed, 8 insertions, 17 deletions
diff --git a/itjs.php b/itjs.php
index 4e3b89c..95d6c0b 100644
--- a/itjs.php
+++ b/itjs.php
@@ -44,7 +44,10 @@ if ($checksum != $_SERVER['HTTP_IF_NONE_MATCH'])
header("Cache-Control: max-age=900");
if ($_REQUEST['boot'])
- $data .= "window.it_boot_init();";
+ {
+ $data .= "window.it_boot_init();\n";
+ $data .= sprintf("/*sln:% 8d*/", strlen($data) + 16);
+ }
echo itjs::strip($data);
}
diff --git a/itjs/boot.js b/itjs/boot.js
index 726bcd2..2efa18a 100644
--- a/itjs/boot.js
+++ b/itjs/boot.js
@@ -6,13 +6,6 @@ var it_catcherrstart = new Date().getTime();
function it_catcherr(msg, url, line)
{
- // retry it_boot if failed
- if (it_boot.doretry)
- {
- it_boot(it_boot.file, true);
- return false;
- }
-
var stacktrace = "";
for (var c = it_catcherr.caller; c != null; c = c.caller)
@@ -67,7 +60,6 @@ function it_boot_checkcss(style, key, value)
function it_boot_init()
{
- it_boot.doretry = false;
window.it_domtimer = null;
var konqueror = navigator.userAgent.match(/konqueror/i);
var doc = document;
@@ -96,7 +88,6 @@ function it_boot_init()
function it_boot(file, isretry)
{
it_boot.file = file;
- it_boot.doretry = false;
it_boot.sequence = isretry ? "r" : "b";
try
@@ -123,10 +114,11 @@ function it_boot(file, isretry)
{
if (loader.status < 400) // Opera gives back 304 if from cache
{
- if (loader.responseText.length && loader.responseText.lastIndexOf('it_boot_init()') > 0)
+ // check length cookie
+ var ln = String(loader.responseText).substr(-16).match(/\*sln:\s*([0-9]+)\*/);
+ if (ln && ln[1]-0 == loader.responseText.length)
{
it_boot.sequence += "e";
- it_boot.doretry = !isretry;
var code = "try {" + loader.responseText + "} catch (e) { it_catcherr(e.message, it_boot.file, -1); }"; // Wrapped in try/catch as Konqueror does not support window.onerror
if (window.execScript)
window.execScript(code, "javascript"); // IE work-around to get script executed in global scope
@@ -134,11 +126,7 @@ function it_boot(file, isretry)
window.setTimeout(code, 0); // Standard compliant version
}
else
- {
- error = "Incomplete script @ status " + loader.status;
- if (!isretry) // send notification for analyzing
- new Image().src = "/itjs/error.gif/" + escape(error) + "|" + escape(file) + "|-1|" + (new Date().getTime() - it_catcherrstart) + "|";
- }
+ error = (ln ? "length mismatch: "+ln[1]+" != "+loader.responseText.length : "no length cookie");
}
else
error = loader.statusText;