Browse Source

fix: content type in GMxhr for 'document'

tophf 4 years ago
parent
commit
7445e30e95
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/injected/web/requests.js

+ 2 - 1
src/injected/web/requests.js

@@ -45,7 +45,8 @@ function parseData(req, msg) {
   } else if (responseType === 'json') {
   } else if (responseType === 'json') {
     res = jsonParse(raw);
     res = jsonParse(raw);
   } else if (responseType === 'document') {
   } else if (responseType === 'document') {
-    const type = msg.contentType::replace(/^[^;]+/)?.[0] || 'text/html';
+    // Cutting everything after , or ; and trimming whitespace
+    const type = msg.contentType::replace(/[,;].*|\s+/g, '') || 'text/html';
     res = new DOMParser()::parseFromString(raw, type);
     res = new DOMParser()::parseFromString(raw, type);
   } else if (msg.chunked) {
   } else if (msg.chunked) {
     // arraybuffer/blob in incognito tabs is transferred as ArrayBuffer encoded in string chunks
     // arraybuffer/blob in incognito tabs is transferred as ArrayBuffer encoded in string chunks