Don't propagate error getting a Unicode decoder to caller. Bug 603423, r=hsivonen, a=bsmedberg
authorSimon Montagu <smontagu@smontagu.org>
Sun, 14 Nov 2010 06:40:14 -0800
changeset 57467 174f235f76ed07519eb580d334a3f26a8a7d9e21
parent 57466 2213446a018b4e943363a0e5180a1b477b98adfa
child 57468 7034c271ebd2d39a6df3f7a9f749601f03ffd3bb
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewershsivonen, bsmedberg
bugs603423
milestone2.0b8pre
Don't propagate error getting a Unicode decoder to caller. Bug 603423, r=hsivonen, a=bsmedberg
parser/html/nsHtml5StreamParser.cpp
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -593,18 +593,23 @@ nsHtml5StreamParser::OnStartRequest(nsIR
     // we aren't ready to commit to an encoding yet
     // leave converter uninstantiated for now
     return NS_OK;
   }
   
   nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
-  NS_ENSURE_SUCCESS(rv, rv);
-  mUnicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Recover);
+  // if we failed to get a decoder, there will be fallback, so don't propagate
+  //  the error.
+  if (NS_SUCCEEDED(rv)) {
+    mUnicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Recover);
+  } else {
+    mCharsetSource = kCharsetFromWeakDocTypeDefault;
+  }
   return NS_OK;
 }
 
 void
 nsHtml5StreamParser::DoStopRequest()
 {
   NS_ASSERTION(IsParserThread(), "Wrong thread!");
   NS_PRECONDITION(STREAM_BEING_READ == mStreamState,