Bug 1319009 - View Source shows a blank New Tab with a forced charset. r=standard8 draft
authorMarco Bonardo <mbonardo@mozilla.com>
Mon, 21 Nov 2016 18:32:27 +0100
changeset 442084 fd4b7e74a4b5769a7f38c1c0ad14543649e43683
parent 441589 57a8cde3f08ca9d60bcd8bdd698ceec687f0aed2
child 537691 ffa1119aac30a9e7dfb25aed51f54a9a9b3571f2
push id36577
push usermak77@bonardo.net
push dateMon, 21 Nov 2016 17:36:01 +0000
reviewersstandard8
bugs1319009
milestone53.0a1
Bug 1319009 - View Source shows a blank New Tab with a forced charset. r=standard8 MozReview-Commit-ID: 7P7gdH8Ltmm
toolkit/components/viewsource/content/viewSource-content.js
--- a/toolkit/components/viewsource/content/viewSource-content.js
+++ b/toolkit/components/viewsource/content/viewSource-content.js
@@ -286,17 +286,19 @@ var ViewSourceContent = {
    *        loading.
    * @param forcedCharSet (optional)
    *        The document character set to use instead of the default one.
    */
   loadSource(URL, pageDescriptor, lineNumber, forcedCharSet) {
     const viewSrcURL = "view-source:" + URL;
 
     if (forcedCharSet) {
-      docShell.charset = forcedCharSet;
+      try {
+        docShell.charset = forcedCharSet;
+      } catch (e) { /* invalid charset */ }
     }
 
     if (lineNumber && lineNumber > 0) {
       let doneLoading = (event) => {
         // Ignore possible initial load of about:blank
         if (this.isAboutBlank ||
             !content.document.body) {
           return;