Bug 714631. Feed converter should check HTTP channel response status before proceeding. r=gavin
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 13 Apr 2012 13:46:15 -0400
changeset 94939 5bdfc91404809ef7c9fcbd87a2b9590c9e6d39fa
parent 94938 a45e6af2cc324324d3bd6f0aac63f85da027e90c
child 94940 cdf819eedd4bc527380119a5e7ec64adfa8f9cd0
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs714631
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 714631. Feed converter should check HTTP channel response status before proceeding. r=gavin
browser/components/feeds/src/FeedConverter.js
--- a/browser/components/feeds/src/FeedConverter.js
+++ b/browser/components/feeds/src/FeedConverter.js
@@ -310,16 +310,23 @@ FeedConverter.prototype = {
    */
   onStartRequest: function FC_onStartRequest(request, context) {
     var channel = request.QueryInterface(Ci.nsIChannel);
 
     // Check for a header that tells us there was no sniffing
     // The value doesn't matter.
     try {
       var httpChannel = channel.QueryInterface(Ci.nsIHttpChannel);
+      // Make sure to check requestSucceeded before the potentially-throwing
+      // getResponseHeader.
+      if (!httpChannel.requestSucceeded) {
+        // Just give up, but don't forget to cancel the channel first!
+        request.cancel(0x804b0002); // NS_BINDING_ABORTED
+        return;
+      }
       var noSniff = httpChannel.getResponseHeader("X-Moz-Is-Feed");
     }
     catch (ex) {
       this._sniffed = true;
     }
 
     this._request = request;