Bug 1536387 - Part 2: enhance the range for allowed http cache storage key tag character values, r=michal
authorHonza Bambas <honzab.moz@firemni.cz>
Fri, 22 Mar 2019 23:22:37 +0000
changeset 465807 0f9137f0f5d5335c3b6d735fd54ef650bd4e77b0
parent 465806 7c50648e40f620a6fe09df9b8efd36b32453155f
child 465808 2a3ae619335c3e327de2eb3ad0bb752e080c5a98
push id35746
push usershindli@mozilla.com
push dateSat, 23 Mar 2019 09:46:24 +0000
treeherdermozilla-central@02b7484f316b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1536387
milestone68.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 1536387 - Part 2: enhance the range for allowed http cache storage key tag character values, r=michal Differential Revision: https://phabricator.services.mozilla.com/D24342
netwerk/cache2/CacheFileUtils.cpp
--- a/netwerk/cache2/CacheFileUtils.cpp
+++ b/netwerk/cache2/CacheFileUtils.cpp
@@ -42,18 +42,23 @@ class KeyParser : protected Tokenizer {
   OriginAttributes originAttribs;
   bool isAnonymous;
   nsCString idEnhance;
   nsDependentCSubstring cacheKey;
 
   // Keeps the last tag name, used for alphabetical sort checking
   char lastTag;
 
-  // Classifier for the 'tag' character valid range
-  static bool TagChar(const char aChar) { return aChar >= ' ' && aChar <= '~'; }
+  // Classifier for the 'tag' character valid range.
+  // Explicitly using unsigned char as 127 is -1 when signed and it would only
+  // produce a warning.
+  static bool TagChar(const char aChar) {
+    unsigned char c = static_cast<unsigned char>(aChar);
+    return c >= ' ' && c <= '\x7f';
+  }
 
   bool ParseTags() {
     // Expects to be at the tag name or at the end
     if (CheckEOF()) {
       return true;
     }
 
     char tag;