am 208360b2: Fix for b/2164520: Download manager should handle video/m4v MIME type.

Merge commit '208360b22db7bdd940a7005fd44135e8916742af' into eclair-mr2-plus-aosp

* commit '208360b22db7bdd940a7005fd44135e8916742af':
  Fix for b/2164520: Download manager should handle video/m4v MIME type.
This commit is contained in:
Ben Murdoch
2009-10-19 09:42:07 -07:00
committed by Android Git Automerger
2 changed files with 7 additions and 2 deletions

View File

@@ -483,6 +483,7 @@ public class MimeTypeMap {
sMimeTypeMap.loadEntry("video/dv", "dif");
sMimeTypeMap.loadEntry("video/dv", "dv");
sMimeTypeMap.loadEntry("video/fli", "fli");
sMimeTypeMap.loadEntry("video/m4v", "m4v");
sMimeTypeMap.loadEntry("video/mpeg", "mpeg");
sMimeTypeMap.loadEntry("video/mpeg", "mpg");
sMimeTypeMap.loadEntry("video/mpeg", "mpe");

View File

@@ -367,19 +367,23 @@ public final class URLUtil {
/** Regex used to parse content-disposition headers */
private static final Pattern CONTENT_DISPOSITION_PATTERN =
Pattern.compile("attachment;\\s*filename\\s*=\\s*\"([^\"]*)\"");
Pattern.compile("attachment;\\s*filename\\s*=\\s*(\"?)([^\"]*)\\1\\s*$",
Pattern.CASE_INSENSITIVE);
/*
* Parse the Content-Disposition HTTP Header. The format of the header
* is defined here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html
* This header provides a filename for content that is going to be
* downloaded to the file system. We only support the attachment type.
* Note that RFC 2616 specifies the filename value must be double-quoted.
* Unfortunately some servers do not quote the value so to maintain
* consistent behaviour with other browsers, we allow unquoted values too.
*/
static String parseContentDisposition(String contentDisposition) {
try {
Matcher m = CONTENT_DISPOSITION_PATTERN.matcher(contentDisposition);
if (m.find()) {
return m.group(1);
return m.group(2);
}
} catch (IllegalStateException ex) {
// This function is defined as returning null when it can't parse the header