diff options
author | Matt A. Tobin <email@mattatobin.com> | 2019-11-11 01:15:16 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2019-11-11 01:15:16 -0500 |
commit | 3c41580e7182a23bf149a68a31cb51c6fb0a3008 (patch) | |
tree | bc5dd6a79cc74dc39293fa3ee7742cfdbe50a35d /mailnews/extensions/newsblog/content | |
parent | 20aab9e0c3de593758ef9f7bf78c907e27857506 (diff) | |
download | UXP-3c41580e7182a23bf149a68a31cb51c6fb0a3008.tar UXP-3c41580e7182a23bf149a68a31cb51c6fb0a3008.tar.gz UXP-3c41580e7182a23bf149a68a31cb51c6fb0a3008.tar.lz UXP-3c41580e7182a23bf149a68a31cb51c6fb0a3008.tar.xz UXP-3c41580e7182a23bf149a68a31cb51c6fb0a3008.zip |
Bug 1554098 - deduce RSS media enclosures type from extension when missing.
Tag #1273
Diffstat (limited to 'mailnews/extensions/newsblog/content')
-rw-r--r-- | mailnews/extensions/newsblog/content/FeedItem.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/mailnews/extensions/newsblog/content/FeedItem.js b/mailnews/extensions/newsblog/content/FeedItem.js index c3f9691f8..25fc8ac30 100644 --- a/mailnews/extensions/newsblog/content/FeedItem.js +++ b/mailnews/extensions/newsblog/content/FeedItem.js @@ -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; } } |