From c45be92b7675a1c73b86b1eba6112163246bee3f Mon Sep 17 00:00:00 2001 From: ketmar Date: Fri, 9 Sep 2016 10:46:38 +0000 Subject: [PATCH] cosmetic fix FossilOrigin-Name: 0ecb8badee47a54c0e080f3e59a714de16620a942b9980341d999290fd3407d9 --- code/modules/httpobserver.js | 23 ++++++++++++++--------- install.rdf | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/code/modules/httpobserver.js b/code/modules/httpobserver.js index 1e1ba6f..347d84d 100644 --- a/code/modules/httpobserver.js +++ b/code/modules/httpobserver.js @@ -101,16 +101,21 @@ let httpRequestObserver = { if (host in BLACK_HOSTS) blacklisted = BLACK_HOSTS[host]; } if (!blacklisted && dw && PREFS.maxTotalBytesForDoc > 0) { - let ctlen = parseInt(httpChannel.getResponseHeader("Content-Length"), 10); - if (isNaN(ctlen)) doSizeBlockInTamper = true; - if (!isNaN(ctlen) && ctlen > 0) { - let isize = getByteCounterForDomWindow(dw)+ctlen; - if (isize >= PREFS.maxTotalBytesForDoc) { - if (PREFS.debugLog) conlog("*** [", httpChannel.URI.spec, "]: blacklisted due to bytes limit: isize="+isize+"; max="+PREFS.maxTotalBytesForDoc+"; ctlen="+ctlen); - blacklisted = true; - } else { - setByteCounterForDomWindow(dw, isize); + try { + let ctlen = parseInt(httpChannel.getResponseHeader("Content-Length"), 10); + if (isNaN(ctlen)) doSizeBlockInTamper = true; + if (!isNaN(ctlen) && ctlen > 0) { + let isize = getByteCounterForDomWindow(dw)+ctlen; + if (isize >= PREFS.maxTotalBytesForDoc) { + if (PREFS.debugLog) conlog("*** [", httpChannel.URI.spec, "]: blacklisted due to bytes limit: isize="+isize+"; max="+PREFS.maxTotalBytesForDoc+"; ctlen="+ctlen); + blacklisted = true; + } else { + setByteCounterForDomWindow(dw, isize); + } } + } catch (e) { + // httpChannel.getResponseHeader can throw when download is blocked (like font), just get out of here + return; } } // check rules diff --git a/install.rdf b/install.rdf index 3aa71cc..244354c 100644 --- a/install.rdf +++ b/install.rdf @@ -4,7 +4,7 @@ imago@ketmar.no-ip.org Smart Image Blocker Blocks images by dimensions and/or file size. - 0.0.2.14 + 0.0.2.15 Ketmar Dark chrome://k8-imago/content/icon.png https://ketmar.no-ip.org/palemoon/addons/updates.bin?reqversion=%REQ_VERSION%&appid=%APP_ID%&appversion=%APP_VERSION%&curappversion=%CURRENT_APP_VERSION%&os=%APP_OS%&abi=%APP_ABI%&locale=%APP_LOCALE%&type=%UPDATE_TYPE%&compat=%COMPATIBILITY_MODE%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxapp=%ITEM_MAXAPPVERSION% @@ -16,7 +16,7 @@ {8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4} 25.0 - 26.* + 27.* -- 2.11.4.GIT