Bug 1554098 - deduce RSS media enclosures type from extension when missing.

Tag #1273
This commit is contained in:
Matt A. Tobin 2019-11-11 01:15:16 -05:00 • committed by Roy Tam
commit a4ab7d01df

View file

@ -452,16 +452,18 @@ function FeedEnclosure(aURL, aContentType, aLength, aTitle)
this.mTitle = aTitle;
// Generate a fileName from the URL.
if (this.mURL)
{
try
{
this.mFileName = Services.io.newURI(this.mURL, null, null).
QueryInterface(Ci.nsIURL).
fileName;
}
catch(ex)
{
if (this.mURL) {
try {
let uri = Services.io.newURI(this.mURL).QueryInterface(Ci.nsIURL);
this.mFileName = uri.fileName;
// Determine mimetype from extension if content-type is not present.
if (!aContentType) {
let contentType = Cc["@mozilla.org/mime;1"]
.getService(Ci.nsIMIMEService)
.getTypeFromExtension(uri.fileExtension);
this.mContentType = contentType;
}
} catch(ex) {
this.mFileName = this.mURL;
}
}