browser/metro/base/content/pages/netError.xhtml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0" encoding="UTF-8"?>
michael@0 2
michael@0 3 <!DOCTYPE html [
michael@0 4 <!ENTITY % htmlDTD
michael@0 5 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
michael@0 6 "DTD/xhtml1-strict.dtd">
michael@0 7 %htmlDTD;
michael@0 8 <!ENTITY % netErrorDTD
michael@0 9 SYSTEM "chrome://global/locale/netError.dtd">
michael@0 10 %netErrorDTD;
michael@0 11 <!ENTITY % globalDTD
michael@0 12 SYSTEM "chrome://global/locale/global.dtd">
michael@0 13 %globalDTD;
michael@0 14 ]>
michael@0 15
michael@0 16 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 17 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 18 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 19
michael@0 20 <html xmlns="http://www.w3.org/1999/xhtml">
michael@0 21 <head>
michael@0 22 <meta name="viewport" content="width=device-width; user-scalable=false;" />
michael@0 23 <title>&loadError.label;</title>
michael@0 24 <link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
michael@0 25 <!-- If the location of the favicon is changed here, the FAVICON_ERRORPAGE_URL symbol in
michael@0 26 toolkit/components/places/src/nsFaviconService.h should be updated. -->
michael@0 27 <link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
michael@0 28
michael@0 29 <script type="application/javascript"><![CDATA[
michael@0 30 // Error url MUST be formatted like this:
michael@0 31 // moz-neterror:page?e=error&u=url&d=desc
michael@0 32 //
michael@0 33 // or optionally, to specify an alternate CSS class to allow for
michael@0 34 // custom styling and favicon:
michael@0 35 //
michael@0 36 // moz-neterror:page?e=error&u=url&s=classname&d=desc
michael@0 37
michael@0 38 // Note that this file uses document.documentURI to get
michael@0 39 // the URL (with the format from above). This is because
michael@0 40 // document.location.href gets the current URI off the docshell,
michael@0 41 // which is the URL displayed in the location bar, i.e.
michael@0 42 // the URI that the user attempted to load.
michael@0 43
michael@0 44 function getErrorCode()
michael@0 45 {
michael@0 46 var url = document.documentURI;
michael@0 47 var error = url.search(/e\=/);
michael@0 48 var duffUrl = url.search(/\&u\=/);
michael@0 49 return decodeURIComponent(url.slice(error + 2, duffUrl));
michael@0 50 }
michael@0 51
michael@0 52 function getCSSClass()
michael@0 53 {
michael@0 54 var url = document.documentURI;
michael@0 55 var matches = url.match(/s\=([^&]+)\&/);
michael@0 56 // s is optional, if no match just return nothing
michael@0 57 if (!matches || matches.length < 2)
michael@0 58 return "";
michael@0 59
michael@0 60 // parenthetical match is the second entry
michael@0 61 return decodeURIComponent(matches[1]);
michael@0 62 }
michael@0 63
michael@0 64 function getDescription()
michael@0 65 {
michael@0 66 var url = document.documentURI;
michael@0 67 var desc = url.search(/d\=/);
michael@0 68
michael@0 69 // desc == -1 if not found; if so, return an empty string
michael@0 70 // instead of what would turn out to be portions of the URI
michael@0 71 if (desc == -1)
michael@0 72 return "";
michael@0 73
michael@0 74 return decodeURIComponent(url.slice(desc + 2));
michael@0 75 }
michael@0 76
michael@0 77 function retryThis(buttonEl)
michael@0 78 {
michael@0 79 // Note: The application may wish to handle switching off "offline mode"
michael@0 80 // before this event handler runs, but using a capturing event handler.
michael@0 81
michael@0 82 // Session history has the URL of the page that failed
michael@0 83 // to load, not the one of the error page. So, just call
michael@0 84 // reload(), which will also repost POST data correctly.
michael@0 85 try {
michael@0 86 location.reload();
michael@0 87 } catch (e) {
michael@0 88 // We probably tried to reload a URI that caused an exception to
michael@0 89 // occur; e.g. a nonexistent file.
michael@0 90 }
michael@0 91
michael@0 92 buttonEl.disabled = true;
michael@0 93 }
michael@0 94
michael@0 95 function initPage()
michael@0 96 {
michael@0 97 var err = getErrorCode();
michael@0 98
michael@0 99 // if it's an unknown error or there's no title or description
michael@0 100 // defined, get the generic message
michael@0 101 var errTitle = document.getElementById("et_" + err);
michael@0 102 var errDesc = document.getElementById("ed_" + err);
michael@0 103 if (!errTitle || !errDesc)
michael@0 104 {
michael@0 105 errTitle = document.getElementById("et_generic");
michael@0 106 errDesc = document.getElementById("ed_generic");
michael@0 107 }
michael@0 108
michael@0 109 var title = document.querySelector(".errorTitleText");
michael@0 110 if (title)
michael@0 111 {
michael@0 112 title.parentNode.replaceChild(errTitle, title);
michael@0 113 // change id to the replaced child's id so styling works
michael@0 114 errTitle.classList.add("errorTitleText");
michael@0 115 }
michael@0 116
michael@0 117 var sd = document.getElementById("errorShortDescText");
michael@0 118 if (sd)
michael@0 119 sd.textContent = getDescription();
michael@0 120
michael@0 121 var ld = document.getElementById("errorLongDesc");
michael@0 122 if (ld)
michael@0 123 {
michael@0 124 ld.parentNode.replaceChild(errDesc, ld);
michael@0 125 // change id to the replaced child's id so styling works
michael@0 126 errDesc.id = "errorLongDesc";
michael@0 127 }
michael@0 128
michael@0 129 // remove undisplayed errors to avoid bug 39098
michael@0 130 var errContainer = document.getElementById("errorContainer");
michael@0 131 errContainer.parentNode.removeChild(errContainer);
michael@0 132
michael@0 133 var className = getCSSClass();
michael@0 134 if (className && className != "expertBadCert") {
michael@0 135 // Associate a CSS class with the root of the page, if one was passed in,
michael@0 136 // to allow custom styling.
michael@0 137 // Not "expertBadCert" though, don't want to deal with the favicon
michael@0 138 document.documentElement.className = className;
michael@0 139
michael@0 140 // Also, if they specified a CSS class, they must supply their own
michael@0 141 // favicon. In order to trigger the browser to repaint though, we
michael@0 142 // need to remove/add the link element.
michael@0 143 var favicon = document.getElementById("favicon");
michael@0 144 var faviconParent = favicon.parentNode;
michael@0 145 faviconParent.removeChild(favicon);
michael@0 146 favicon.setAttribute("href", "chrome://global/skin/icons/" + className + "_favicon.png");
michael@0 147 faviconParent.appendChild(favicon);
michael@0 148 }
michael@0 149 if (className == "expertBadCert") {
michael@0 150 showSecuritySection();
michael@0 151 }
michael@0 152
michael@0 153 if (err == "remoteXUL") {
michael@0 154 // Remove the "Try again" button for remote XUL errors given that
michael@0 155 // it is useless.
michael@0 156 document.getElementById("errorTryAgain").style.display = "none";
michael@0 157 }
michael@0 158
michael@0 159 if (err == "cspFrameAncestorBlocked") {
michael@0 160 // Remove the "Try again" button for CSP frame ancestors violation, since it's
michael@0 161 // almost certainly useless. (Bug 553180)
michael@0 162 document.getElementById("errorTryAgain").style.display = "none";
michael@0 163 }
michael@0 164
michael@0 165 if (err == "nssBadCert") {
michael@0 166 // Remove the "Try again" button for security exceptions, since it's
michael@0 167 // almost certainly useless.
michael@0 168 document.getElementById("errorTryAgain").style.display = "none";
michael@0 169 document.getElementById("errorPage").setAttribute("class", "certerror");
michael@0 170 addDomainErrorLink();
michael@0 171 }
michael@0 172 else {
michael@0 173 // Remove the override block for non-certificate errors. CSS-hiding
michael@0 174 // isn't good enough here, because of bug 39098
michael@0 175 var secOverride = document.getElementById("securityOverrideDiv");
michael@0 176 secOverride.parentNode.removeChild(secOverride);
michael@0 177 }
michael@0 178 }
michael@0 179
michael@0 180 function showSecuritySection() {
michael@0 181 // Swap link out, content in
michael@0 182 document.getElementById('securityOverrideContent').style.display = '';
michael@0 183 document.getElementById('securityOverrideLink').style.display = 'none';
michael@0 184 }
michael@0 185
michael@0 186 /* In the case of SSL error pages about domain mismatch, see if
michael@0 187 we can hyperlink the user to the correct site. We don't want
michael@0 188 to do this generically since it allows MitM attacks to redirect
michael@0 189 users to a site under attacker control, but in certain cases
michael@0 190 it is safe (and helpful!) to do so. Bug 402210
michael@0 191 */
michael@0 192 function addDomainErrorLink() {
michael@0 193 // Rather than textContent, we need to treat description as HTML
michael@0 194 var sd = document.getElementById("errorShortDescText");
michael@0 195 if (sd) {
michael@0 196 var desc = getDescription();
michael@0 197
michael@0 198 // sanitize description text - see bug 441169
michael@0 199
michael@0 200 // First, find the index of the <a> tag we care about, being careful not to
michael@0 201 // use an over-greedy regex
michael@0 202 var re = /<a id="cert_domain_link" title="([^"]+)">/;
michael@0 203 var result = re.exec(desc);
michael@0 204 if(!result)
michael@0 205 return;
michael@0 206
michael@0 207 // Remove sd's existing children
michael@0 208 sd.textContent = "";
michael@0 209
michael@0 210 // Everything up to the link should be text content
michael@0 211 sd.appendChild(document.createTextNode(desc.slice(0, result.index)));
michael@0 212
michael@0 213 // Now create the link itself
michael@0 214 var anchorEl = document.createElement("a");
michael@0 215 anchorEl.setAttribute("id", "cert_domain_link");
michael@0 216 anchorEl.setAttribute("title", result[1]);
michael@0 217 anchorEl.appendChild(document.createTextNode(result[1]));
michael@0 218 sd.appendChild(anchorEl);
michael@0 219
michael@0 220 // Finally, append text for anything after the closing </a>
michael@0 221 sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length)));
michael@0 222 }
michael@0 223
michael@0 224 var link = document.getElementById('cert_domain_link');
michael@0 225 if (!link)
michael@0 226 return;
michael@0 227
michael@0 228 var okHost = link.getAttribute("title");
michael@0 229 var thisHost = document.location.hostname;
michael@0 230 var proto = document.location.protocol;
michael@0 231
michael@0 232 // If okHost is a wildcard domain ("*.example.com") let's
michael@0 233 // use "www" instead. "*.example.com" isn't going to
michael@0 234 // get anyone anywhere useful. bug 432491
michael@0 235 okHost = okHost.replace(/^\*\./, "www.");
michael@0 236
michael@0 237 /* case #1:
michael@0 238 * example.com uses an invalid security certificate.
michael@0 239 *
michael@0 240 * The certificate is only valid for www.example.com
michael@0 241 *
michael@0 242 * Make sure to include the "." ahead of thisHost so that
michael@0 243 * a MitM attack on paypal.com doesn't hyperlink to "notpaypal.com"
michael@0 244 *
michael@0 245 * We'd normally just use a RegExp here except that we lack a
michael@0 246 * library function to escape them properly (bug 248062), and
michael@0 247 * domain names are famous for having '.' characters in them,
michael@0 248 * which would allow spurious and possibly hostile matches.
michael@0 249 */
michael@0 250 if (endsWith(okHost, "." + thisHost))
michael@0 251 link.href = proto + okHost;
michael@0 252
michael@0 253 /* case #2:
michael@0 254 * browser.garage.maemo.org uses an invalid security certificate.
michael@0 255 *
michael@0 256 * The certificate is only valid for garage.maemo.org
michael@0 257 */
michael@0 258 if (endsWith(thisHost, "." + okHost))
michael@0 259 link.href = proto + okHost;
michael@0 260 }
michael@0 261
michael@0 262 function endsWith(haystack, needle) {
michael@0 263 return haystack.slice(-needle.length) == needle;
michael@0 264 }
michael@0 265
michael@0 266 ]]></script>
michael@0 267 </head>
michael@0 268
michael@0 269 <body id="errorPage" dir="&locale.dir;">
michael@0 270
michael@0 271 <!-- ERROR ITEM CONTAINER (removed during loading to avoid bug 39098) -->
michael@0 272 <div id="errorContainer">
michael@0 273 <div id="errorTitlesContainer">
michael@0 274 <h1 id="et_generic">&generic.title;</h1>
michael@0 275 <h1 id="et_dnsNotFound">&dnsNotFound.title;</h1>
michael@0 276 <h1 id="et_fileNotFound">&fileNotFound.title;</h1>
michael@0 277 <h1 id="et_malformedURI">&malformedURI.title;</h1>
michael@0 278 <h1 id="et_unknownProtocolFound">&unknownProtocolFound.title;</h1>
michael@0 279 <h1 id="et_connectionFailure">&connectionFailure.title;</h1>
michael@0 280 <h1 id="et_netTimeout">&netTimeout.title;</h1>
michael@0 281 <h1 id="et_redirectLoop">&redirectLoop.title;</h1>
michael@0 282 <h1 id="et_unknownSocketType">&unknownSocketType.title;</h1>
michael@0 283 <h1 id="et_netReset">&netReset.title;</h1>
michael@0 284 <h1 id="et_notCached">&notCached.title;</h1>
michael@0 285 <h1 id="et_netOffline">&netOffline.title;</h1>
michael@0 286 <h1 id="et_netInterrupt">&netInterrupt.title;</h1>
michael@0 287 <h1 id="et_deniedPortAccess">&deniedPortAccess.title;</h1>
michael@0 288 <h1 id="et_proxyResolveFailure">&proxyResolveFailure.title;</h1>
michael@0 289 <h1 id="et_proxyConnectFailure">&proxyConnectFailure.title;</h1>
michael@0 290 <h1 id="et_contentEncodingError">&contentEncodingError.title;</h1>
michael@0 291 <h1 id="et_unsafeContentType">&unsafeContentType.title;</h1>
michael@0 292 <h1 id="et_nssFailure2">&nssFailure2.title;</h1>
michael@0 293 <h1 id="et_nssBadCert">&nssBadCert.title;</h1>
michael@0 294 <h1 id="et_cspFrameAncestorBlocked">&cspFrameAncestorBlocked.title;</h1>
michael@0 295 <h1 id="et_remoteXUL">&remoteXUL.title;</h1>
michael@0 296 <h1 id="et_corruptedContentError">&corruptedContentError.title;</h1>
michael@0 297 </div>
michael@0 298 <div id="errorDescriptionsContainer">
michael@0 299 <div id="ed_generic">&generic.longDesc;</div>
michael@0 300 <div id="ed_dnsNotFound">&dnsNotFound.longDesc;</div>
michael@0 301 <div id="ed_fileNotFound">&fileNotFound.longDesc;</div>
michael@0 302 <div id="ed_malformedURI">&malformedURI.longDesc;</div>
michael@0 303 <div id="ed_unknownProtocolFound">&unknownProtocolFound.longDesc;</div>
michael@0 304 <div id="ed_connectionFailure">&connectionFailure.longDesc;</div>
michael@0 305 <div id="ed_netTimeout">&netTimeout.longDesc;</div>
michael@0 306 <div id="ed_redirectLoop">&redirectLoop.longDesc;</div>
michael@0 307 <div id="ed_unknownSocketType">&unknownSocketType.longDesc;</div>
michael@0 308 <div id="ed_netReset">&netReset.longDesc;</div>
michael@0 309 <div id="ed_notCached">&notCached.longDesc;</div>
michael@0 310 <div id="ed_netOffline">&netOffline.longDesc2;</div>
michael@0 311 <div id="ed_netInterrupt">&netInterrupt.longDesc;</div>
michael@0 312 <div id="ed_deniedPortAccess">&deniedPortAccess.longDesc;</div>
michael@0 313 <div id="ed_proxyResolveFailure">&proxyResolveFailure.longDesc;</div>
michael@0 314 <div id="ed_proxyConnectFailure">&proxyConnectFailure.longDesc;</div>
michael@0 315 <div id="ed_contentEncodingError">&contentEncodingError.longDesc;</div>
michael@0 316 <div id="ed_unsafeContentType">&unsafeContentType.longDesc;</div>
michael@0 317 <div id="ed_nssFailure2">&nssFailure2.longDesc;</div>
michael@0 318 <div id="ed_nssBadCert">&nssBadCert.longDesc2;</div>
michael@0 319 <div id="ed_cspFrameAncestorBlocked">&cspFrameAncestorBlocked.longDesc;</div>
michael@0 320 <div id="ed_remoteXUL">&remoteXUL.longDesc;</div>
michael@0 321 <div id="ed_corruptedContentError">&corruptedContentError.longDesc;</div>
michael@0 322 </div>
michael@0 323 </div>
michael@0 324
michael@0 325 <!-- PAGE CONTAINER (for styling purposes only) -->
michael@0 326 <div id="errorPageContainer" class="section">
michael@0 327
michael@0 328 <!-- Error Title -->
michael@0 329 <div id="errorTitle" class="section-header">
michael@0 330 <span id="errorTitleIcon"></span>
michael@0 331 <h1 class="errorTitleText" />
michael@0 332 </div>
michael@0 333
michael@0 334 <!-- LONG CONTENT (the section most likely to require scrolling) -->
michael@0 335 <div id="errorLongContent" class="section-details">
michael@0 336
michael@0 337 <!-- Short Description -->
michael@0 338 <div id="errorShortDesc">
michael@0 339 <p id="errorShortDescText" />
michael@0 340 </div>
michael@0 341
michael@0 342 <!-- Long Description (Note: See netError.dtd for used XHTML tags) -->
michael@0 343 <div id="errorLongDesc" />
michael@0 344
michael@0 345 <!-- Override section - For ssl errors only. Removed on init for other
michael@0 346 error types. -->
michael@0 347 <div id="securityOverrideDiv">
michael@0 348 <a id="securityOverrideLink" href="javascript:showSecuritySection();" >&securityOverride.linkText;</a>
michael@0 349 <div id="securityOverrideContent" style="display: none;">&securityOverride.warningContent;</div>
michael@0 350 </div>
michael@0 351 </div>
michael@0 352
michael@0 353 <div class="section-footer">
michael@0 354 <!-- Retry Button -->
michael@0 355 <button id="errorTryAgain" onclick="retryThis(this);">&retry.label;</button>
michael@0 356 </div>
michael@0 357
michael@0 358 </div>
michael@0 359
michael@0 360 <!--
michael@0 361 - Note: It is important to run the script this way, instead of using
michael@0 362 - an onload handler. This is because error pages are loaded as
michael@0 363 - LOAD_BACKGROUND, which means that onload handlers will not be executed.
michael@0 364 -->
michael@0 365 <script type="application/javascript">initPage();</script>
michael@0 366
michael@0 367 </body>
michael@0 368 </html>

mercurial