private static Map<String, String> parseParameters(String string) {
    if (string.length() == 0) {
      return Collections.<String, String>emptyMap();
    }

    // Extracts k1=v1, k2=v2 from mime/type; k1=v1; k2=v2
    // Note - this logic isn't fully RFC2045 compliant yet, as it
    //  doesn't fully handle quoted keys or values (eg containing ; or =)
    Map<String, String> parameters = new HashMap<String, String>();
    while (string.length() > 0) {
      String key = string;
      String value = "";

      int semicolon = string.indexOf(';');
      if (semicolon != -1) {
        key = string.substring(0, semicolon);
        string = string.substring(semicolon + 1);
      } else {
        string = "";
      }

      int equals = key.indexOf('=');
      if (equals != -1) {
        value = key.substring(equals + 1);
        key = key.substring(0, equals);
      }

      key = key.trim();
      if (key.length() > 0) {
        parameters.put(key, unquote(value.trim()));
      }
    }
    return parameters;
  }
Parses the given string to a media type. The string is expected
to be of the form "type/subtype(; parameter=...)*" as defined in
RFC 2045, though we also handle "charset=xxx; type/subtype" for
broken web servers.

@param string media type string to be parsed
@return parsed media type, or <code>null</code> if parsing fails
crawler-commons/src/main/java/achecrawler/crawler/crawlercommons/util/MediaType.java