Bug 377052 - nsBaseURLParser::ParseURL doesn't handle spaces embedded in the scheme properly r=mcmanus
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 01 Feb 2016 14:07:16 +0100
changeset 283185 4e60a3ad8b3948dc40e04ac9e77a8dadc34b6717
parent 283184 9f7157c44c017c82e27f3d2ab77bfb4b2bea79da
child 283186 5342641913be9b90f5309a42ae226a1d340f30c6
push id71449
push uservalentin.gosu@gmail.com
push dateFri, 05 Feb 2016 13:45:54 +0000
treeherdermozilla-inbound@77f8588dad8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs377052
milestone47.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 377052 - nsBaseURLParser::ParseURL doesn't handle spaces embedded in the scheme properly r=mcmanus
netwerk/base/nsURLParsers.cpp
--- a/netwerk/base/nsURLParsers.cpp
+++ b/netwerk/base/nsURLParsers.cpp
@@ -57,27 +57,31 @@ nsBaseURLParser::ParseURL(const char *sp
     }
 
     if (specLen < 0)
         specLen = strlen(spec);
 
     const char *stop = nullptr;
     const char *colon = nullptr;
     const char *slash = nullptr;
-    const char *p;
+    const char *p = spec;
     uint32_t offset = 0;
     int32_t len = specLen;
-    for (p = spec; len && *p && !colon && !slash; ++p, --len) {
-        // skip leading whitespace
-        if (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') {
-            spec++;
-            specLen--;
-            offset++;
-            continue;
-        }
+
+    // skip leading whitespace
+    while (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') {
+        spec++;
+        specLen--;
+        offset++;
+
+        p++;
+        len--;
+    }
+
+    for (; len && *p && !colon && !slash; ++p, --len) {
         switch (*p) {
             case ':':
                 if (!colon)
                     colon = p;
                 break;
             case '/': // start of filepath
             case '?': // start of query
             case '#': // start of ref