Bug 1467523 followup fix for case insensitive header name check, r=aswan,robwu
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 10 Oct 2018 16:23:46 -0400
changeset 499091 203a8e58e64c86ba7b9cf8b66aec101b10eca3ec
parent 499090 43a51bc9a77dc2f59196a644798c1911a18615a3
child 499092 ca79a952c3905158d163f06a0132b69857901be2
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, robwu
bugs1467523
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1467523 followup fix for case insensitive header name check, r=aswan,robwu
toolkit/modules/addons/WebRequest.jsm
--- a/toolkit/modules/addons/WebRequest.jsm
+++ b/toolkit/modules/addons/WebRequest.jsm
@@ -131,17 +131,17 @@ class HeaderChanger {
         value = String.fromCharCode(...binaryValue);
       }
 
       let lowerCaseName = name.toLowerCase();
       let original = origHeaders.get(lowerCaseName);
 
       if (!original || value !== original.value) {
         let shouldMerge = headersAlreadySet.has(lowerCaseName);
-        this.setHeader(name, value, shouldMerge, opts);
+        this.setHeader(name, value, shouldMerge, opts, lowerCaseName);
       }
 
       headersAlreadySet.add(lowerCaseName);
     }
   }
 }
 
 const checkRestrictedHeaderValue = (value, opts = {}) => {
@@ -153,34 +153,34 @@ const checkRestrictedHeaderValue = (valu
   }
 
   if (WebExtensionPolicy.isRestrictedURI(uri)) {
     throw new Error(`Unable to set host header to restricted url.`);
   }
 };
 
 class RequestHeaderChanger extends HeaderChanger {
-  setHeader(name, value, merge, opts = {}) {
+  setHeader(name, value, merge, opts, lowerCaseName) {
     try {
-      if (name === "host") {
+      if (value && lowerCaseName === "host") {
         checkRestrictedHeaderValue(value, opts);
       }
       this.channel.setRequestHeader(name, value, merge);
     } catch (e) {
       Cu.reportError(new Error(`Error setting request header ${name}: ${e}`));
     }
   }
 
   readHeaders() {
     return this.channel.getRequestHeaders();
   }
 }
 
 class ResponseHeaderChanger extends HeaderChanger {
-  setHeader(name, value, merge, opts = {}) {
+  setHeader(name, value, merge, opts, lowerCaseName) {
     try {
       this.channel.setResponseHeader(name, value, merge);
     } catch (e) {
       Cu.reportError(new Error(`Error setting response header ${name}: ${e}`));
     }
   }
 
   readHeaders() {