Bug 1046500 - Fix mediagroup parsing in feed parser. r=mak, a=sledru
authorWes Johnston <wjohnston@mozilla.com>
Wed, 06 Aug 2014 20:43:47 -0700
changeset 208292 f76498a1bcbd
parent 208291 086068fe1b98
child 208293 8bf5700cb82e
push id3806
push userryanvm@gmail.com
push date2014-08-11 18:37 +0000
treeherdermozilla-beta@f76498a1bcbd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, sledru
bugs1046500
milestone32.0
Bug 1046500 - Fix mediagroup parsing in feed parser. r=mak, a=sledru
toolkit/components/feeds/FeedProcessor.js
--- a/toolkit/components/feeds/FeedProcessor.js
+++ b/toolkit/components/feeds/FeedProcessor.js
@@ -539,20 +539,26 @@ Entry.prototype = {
 
     if (!(enc.getProperty("url")))
       return;
 
     this._addToEnclosures(enc);
   },
 
   _mediaToEnclosures: function Entry_mediaToEnclosures(mediaType, contentType) {
-    var content = this.fields.getPropertyAsInterface(mediaType, Ci.nsIArray);
+    var content;
 
-    if (contentType)
-      content = content.getPropertyAsInterface(contentType, Ci.nsIArray);
+    // If a contentType is specified, the mediaType is a simple propertybag,
+    // and the contentType is an array inside it.
+    if (contentType) {
+      var group = this.fields.getPropertyAsInterface(mediaType, Ci.nsIPropertyBag2);
+      content = group.getPropertyAsInterface(contentType, Ci.nsIArray);
+    } else {
+      content = this.fields.getPropertyAsInterface(mediaType, Ci.nsIArray);
+    }
 
     for (var i = 0; i < content.length; ++i) {
       var contentElement = content.queryElementAt(i, Ci.nsIWritablePropertyBag2);
 
       // media:content don't require url, but if it's not there, we should
       // skip it.
       if (!bagHasKey(contentElement, "url"))
         continue;