LOG(("-- ParseNetscapeMIMETypesEntry\n"));
ParseNetscapeMIMETypesEntry(const nsAString& aEntry,                            nsAString::const_iterator& aMajorTypeStart,                            nsAString::const_iterator& aMajorTypeEnd,                            nsAString::const_iterator& aMinorTypeStart,                            nsAString::const_iterator& aMinorTypeEnd,                            nsAString& aExtensions,                            nsAString::const_iterator& aDescriptionStart,                            nsAString::const_iterator& aDescriptionEnd) {  NS_ASSERTION(!aEntry.IsEmpty(), "Empty Netscape MIME types entry being parsed.");    nsAString::const_iterator start_iter, end_iter, match_start, match_end;  aEntry.BeginReading(start_iter);  aEntry.EndReading(end_iter);    // skip trailing whitespace  do {    --end_iter;  } while (end_iter != start_iter &&           nsCRT::IsAsciiSpace(*end_iter));  // if we're pointing to a quote, don't advance -- we don't want to  // include the quote....  if (*end_iter != '"')    ++end_iter;  match_start = start_iter;  match_end = end_iter;    // Get the major and minor types  // First the major type  if (! FindInReadable(NS_LITERAL_STRING("type="), match_start, match_end)) {    return NS_ERROR_FAILURE;  }    match_start = match_end;    while (match_end != end_iter &&         *match_end != '/') {    ++match_end;  }  if (match_end == end_iter) {    return NS_ERROR_FAILURE;  }    aMajorTypeStart = match_start;  aMajorTypeEnd = match_end;  // now the minor type  if (++match_end == end_iter) {    return NS_ERROR_FAILURE;  }    match_start = match_end;    while (match_end != end_iter &&         !nsCRT::IsAsciiSpace(*match_end) &&         *match_end != ';') {    ++match_end;  }  if (match_end == end_iter) {    return NS_ERROR_FAILURE;  }    aMinorTypeStart = match_start;  aMinorTypeEnd = match_end;    // ignore everything up to the end of the mime type from here on  start_iter = match_end;    // get the extensions  match_start = match_end;  match_end = end_iter;  if (FindInReadable(NS_LITERAL_STRING("exts="), match_start, match_end)) {    nsAString::const_iterator extStart, extEnd;    if (match_end == end_iter ||        (*match_end == '"' && ++match_end == end_iter)) {      return NS_ERROR_FAILURE;    }      extStart = match_end;    match_start = extStart;    match_end = end_iter;    if (FindInReadable(NS_LITERAL_STRING("desc=\""), match_start, match_end)) {      // exts= before desc=, so we have to find the actual end of the extensions      extEnd = match_start;      if (extEnd == extStart) {        return NS_ERROR_FAILURE;      }          do {        --extEnd;      } while (extEnd != extStart &&               nsCRT::IsAsciiSpace(*extEnd));            if (extEnd != extStart && *extEnd == '"') {        --extEnd;      }    } else {      // desc= before exts=, so we can use end_iter as the end of the extensions      extEnd = end_iter;    }    aExtensions = Substring(extStart, extEnd);  } else {    // no extensions    aExtensions.Truncate();  }  // get the description  match_start = start_iter;  match_end = end_iter;  if (FindInReadable(NS_LITERAL_STRING("desc=\""), match_start, match_end)) {    aDescriptionStart = match_end;    match_start = aDescriptionStart;    match_end = end_iter;    if (FindInReadable(NS_LITERAL_STRING("exts="), match_start, match_end)) {      // exts= after desc=, so have to find actual end of description      aDescriptionEnd = match_start;      if (aDescriptionEnd == aDescriptionStart) {        return NS_ERROR_FAILURE;      }            do {        --aDescriptionEnd;      } while (aDescriptionEnd != aDescriptionStart &&               nsCRT::IsAsciiSpace(*aDescriptionEnd));            if (aDescriptionStart != aDescriptionStart && *aDescriptionEnd == '"') {        --aDescriptionEnd;      }    } else {      // desc= after exts=, so use end_iter for the description end      aDescriptionEnd = end_iter;    }  } else {    // no description    aDescriptionStart = start_iter;    aDescriptionEnd = start_iter;  }  return NS_OK;}