Bug 1221444, r=bz, a=sylvestre
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 04 Nov 2015 16:54:44 +0000
changeset 305419 e96670656f90d7c5e03a46e23dac7ac1ff39e59e
parent 305418 779eec6a0b9e9e3a7168dc2ed11842c6430eeef2
child 305420 44ce9fe80d5d342a6d26318b5086dda30f130d23
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sylvestre
bugs1221444
milestone44.0a2
Bug 1221444, r=bz, a=sylvestre
netwerk/protocol/data/nsDataHandler.cpp
--- a/netwerk/protocol/data/nsDataHandler.cpp
+++ b/netwerk/protocol/data/nsDataHandler.cpp
@@ -164,17 +164,18 @@ nsDataHandler::ParseURI(nsCString& spec,
     if (!buffer) {
         // malformed uri
         return NS_ERROR_MALFORMED_URI;
     }
     buffer += 5;
 
     // First, find the start of the data
     char *comma = strchr(buffer, ',');
-    if (!comma)
+    char *hash = strchr(buffer, '#');
+    if (!comma || (hash && hash < comma))
         return NS_ERROR_MALFORMED_URI;
 
     *comma = '\0';
 
     // determine if the data is base64 encoded.
     char *base64 = PL_strcasestr(buffer, BASE64_EXTENSION);
     if (base64) {
         char *beyond = base64 + strlen(BASE64_EXTENSION);
@@ -219,17 +220,16 @@ nsDataHandler::ParseURI(nsCString& spec,
     if (isBase64)
         *base64 = ';';
 
     contentType.StripWhitespace();
     contentCharset.StripWhitespace();
 
     // Split encoded data from terminal "#ref" (if present)
     char *data = comma + 1;
-    char *hash = strchr(data, '#');
     if (!hash) {
         dataBuffer.Assign(data);
         hashRef.Truncate();
     } else {
         dataBuffer.Assign(data, hash - data);
         hashRef.Assign(hash);
     }