summaryrefslogtreecommitdiffstats
path: root/src/js/traffic.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:18 +0000
commit55a5d29a66503248916f249ad2a1d8b37cde5a03 (patch)
treea3beb6a90dd3bdaaf67ecb05d42152a494aff946 /src/js/traffic.js
parentAdding upstream version 1.55.0+dfsg. (diff)
downloadublock-origin-55a5d29a66503248916f249ad2a1d8b37cde5a03.tar.xz
ublock-origin-55a5d29a66503248916f249ad2a1d8b37cde5a03.zip
Adding upstream version 1.57.0+dfsg.upstream/1.57.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/js/traffic.js')
-rw-r--r--src/js/traffic.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/js/traffic.js b/src/js/traffic.js
index bf34fd4..df86a86 100644
--- a/src/js/traffic.js
+++ b/src/js/traffic.js
@@ -551,7 +551,7 @@ const onHeadersReceived = function(details) {
}
}
if ( jobs.length !== 0 ) {
- bodyFilterer.doFilter(fctxt, jobs);
+ bodyFilterer.doFilter(details.requestId, fctxt, jobs);
}
}
@@ -590,7 +590,7 @@ const onHeadersReceived = function(details) {
}
};
-const reMediaContentTypes = /^(?:audio|image|video)\//;
+const reMediaContentTypes = /^(?:audio|image|video)\/|(?:\/ogg)$/;
/******************************************************************************/
@@ -749,7 +749,7 @@ const bodyFilterer = (( ) => {
/* t */ if ( bytes[i+6] !== 0x74 ) { continue; }
break;
}
- if ( (i - 40) >= 65536 ) { return; }
+ if ( (i + 40) >= 65536 ) { return; }
i += 8;
// find first alpha character
let j = -1;
@@ -827,13 +827,17 @@ const bodyFilterer = (( ) => {
}
if ( this.status !== 'finishedtransferringdata' ) { return; }
- // If encoding is still unknown, try to extract from stream data
+ // If encoding is still unknown, try to extract from stream data.
+ // Just assume utf-8 if ultimately no encoding can be looked up.
if ( session.charset === undefined ) {
const charsetFound = charsetFromStream(session.buffer);
- if ( charsetFound === undefined ) { return streamClose(session); }
- const charsetUsed = textEncode.normalizeCharset(charsetFound);
- if ( charsetUsed === undefined ) { return streamClose(session); }
- session.charset = charsetUsed;
+ if ( charsetFound !== undefined ) {
+ const charsetUsed = textEncode.normalizeCharset(charsetFound);
+ if ( charsetUsed === undefined ) { return streamClose(session); }
+ session.charset = charsetUsed;
+ } else {
+ session.charset = 'utf-8';
+ }
}
while ( session.jobs.length !== 0 ) {
@@ -886,10 +890,10 @@ const bodyFilterer = (( ) => {
this.str = s;
this.modified = true;
}
- static doFilter(fctxt, jobs) {
+ static doFilter(requestId, fctxt, jobs) {
if ( jobs.length === 0 ) { return; }
const session = new Session(fctxt, mime, charset, jobs);
- session.stream = browser.webRequest.filterResponseData(session.id);
+ session.stream = browser.webRequest.filterResponseData(requestId);
session.stream.ondata = onStreamData;
session.stream.onstop = onStreamStop;
session.stream.onerror = onStreamError;