summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorhackademix2020-02-29 19:01:45 +0100
committerhackademix2020-02-29 19:01:45 +0100
commit9a664f7b3b6a5315983317b0e47128b809bc5531 (patch)
tree057ff4d7b4cd7c00634c2655c44774e6a9c8a01c /src/lib
parente48c2053dfef4fb9209e3d432738b8fef6b8d507 (diff)
downloadnoscript-9a664f7b3b6a5315983317b0e47128b809bc5531.tar.gz
noscript-9a664f7b3b6a5315983317b0e47128b809bc5531.tar.xz
noscript-9a664f7b3b6a5315983317b0e47128b809bc5531.zip
Refactored XSS filter into an asynchronous worker to better handle DOS attempts.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Timing.js4
-rw-r--r--src/lib/log.js4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/Timing.js b/src/lib/Timing.js
index 997ebd3..dd4fa06 100644
--- a/src/lib/Timing.js
+++ b/src/lib/Timing.js
@@ -15,7 +15,7 @@ class Timing {
}
async pause() {
- if (this.interrupted) throw new TimingException("Interrupted");
+ if (this.interrupted) throw new TimingException("Timing: interrupted");
let now = Date.now();
this.calls++;
let sinceLastCall = now - this.lastCall;
@@ -28,7 +28,7 @@ class Timing {
if (now - this.lastPause > this.workSlot || this.calls > this.maxCalls) {
this.tooLong = this.elapsed >= this.longTime;
if (this.tooLong && this.fatalTimeout) {
- throw new TimingException(`Exceeded ${this.longTime}ms timeout`);
+ throw new TimingException(`Timing: exceeded ${this.longTime}ms timeout`);
}
this.calls = 0;
await Timing.sleep(this.pauseTime);
diff --git a/src/lib/log.js b/src/lib/log.js
index f548c49..a30a5a6 100644
--- a/src/lib/log.js
+++ b/src/lib/log.js
@@ -1,6 +1,8 @@
{
- let PREFIX = `[${browser.runtime.getManifest().name}]`;
+ let PREFIX = typeof browser === "object"
+ ? `[${browser.runtime.getManifest().name}]` : '';
+
let debugCount = 0;
function log(msg, ...rest) {