Bug 1221444, r=bz, a=sylvestre
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 04 Nov 2015 16:54:44 +0000
changeset 296661 1692a311615d
parent 296660 9eb17d1e915c
child 296662 d681ec6fe6b2
push id5277
push usercbook@mozilla.com
push date2015-11-09 10:34 +0000
treeherdermozilla-beta@d681ec6fe6b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sylvestre
bugs1221444
milestone43.0
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);
     }