From f2674e1627512c83d15995b48a4beee8cc3c89aa Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Mon, 1 Feb 2016 14:07:16 +0100 Subject: [PATCH] Bug 377052 - nsBaseURLParser::ParseURL doesn't handle spaces embedded in the scheme properly r=mcmanus --- netwerk/base/nsURLParsers.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/netwerk/base/nsURLParsers.cpp b/netwerk/base/nsURLParsers.cpp index a024174f04c..ac22ae7540d 100644 --- a/netwerk/base/nsURLParsers.cpp +++ b/netwerk/base/nsURLParsers.cpp @@ -62,17 +62,21 @@ nsBaseURLParser::ParseURL(const char *spec, int32_t specLen, 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)