Bug 1325876 - Add a pref for showing internal error page for HTTP responses with error codes (4xx, 5xx) and Content-Length: 0 instead of blank page r=manuel,necko-reviewers,fluent-reviewers,jesup,bolsson,valentin,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D220193
This commit is contained in:
@@ -6,6 +6,7 @@ malformedURI2=Please check that the URL is correct and try again.
|
|||||||
fileNotFound=Firefox can’t find the file at %S.
|
fileNotFound=Firefox can’t find the file at %S.
|
||||||
fileAccessDenied=The file at %S is not readable.
|
fileAccessDenied=The file at %S is not readable.
|
||||||
# %S is replaced by the uri host
|
# %S is replaced by the uri host
|
||||||
|
httpErrorPage=%S sent back an error.
|
||||||
serverError=%S might have a temporary problem or it could have moved.
|
serverError=%S might have a temporary problem or it could have moved.
|
||||||
dnsNotFound2=We can’t connect to the server at %S.
|
dnsNotFound2=We can’t connect to the server at %S.
|
||||||
basicHttpAuthDisabled=Someone pretending to be the site could try to steal things like your username, password, or email.
|
basicHttpAuthDisabled=Someone pretending to be the site could try to steal things like your username, password, or email.
|
||||||
|
|||||||
@@ -3354,6 +3354,9 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
|||||||
nestedURI = do_QueryInterface(tempURI);
|
nestedURI = do_QueryInterface(tempURI);
|
||||||
}
|
}
|
||||||
error = "unknownProtocolFound";
|
error = "unknownProtocolFound";
|
||||||
|
} else if (NS_ERROR_NET_EMPTY_RESPONSE == aError) {
|
||||||
|
NS_ENSURE_ARG_POINTER(aURI);
|
||||||
|
error = "httpErrorPage";
|
||||||
} else if (NS_ERROR_NET_ERROR_RESPONSE == aError) {
|
} else if (NS_ERROR_NET_ERROR_RESPONSE == aError) {
|
||||||
NS_ENSURE_ARG_POINTER(aURI);
|
NS_ENSURE_ARG_POINTER(aURI);
|
||||||
error = "serverError";
|
error = "serverError";
|
||||||
@@ -6111,6 +6114,7 @@ nsresult nsDocShell::FilterStatusForErrorPage(
|
|||||||
|
|
||||||
if (aStatus == NS_ERROR_NET_TIMEOUT ||
|
if (aStatus == NS_ERROR_NET_TIMEOUT ||
|
||||||
aStatus == NS_ERROR_NET_TIMEOUT_EXTERNAL ||
|
aStatus == NS_ERROR_NET_TIMEOUT_EXTERNAL ||
|
||||||
|
aStatus == NS_ERROR_NET_EMPTY_RESPONSE ||
|
||||||
aStatus == NS_ERROR_NET_ERROR_RESPONSE ||
|
aStatus == NS_ERROR_NET_ERROR_RESPONSE ||
|
||||||
aStatus == NS_ERROR_PROXY_GATEWAY_TIMEOUT ||
|
aStatus == NS_ERROR_PROXY_GATEWAY_TIMEOUT ||
|
||||||
aStatus == NS_ERROR_REDIRECT_LOOP ||
|
aStatus == NS_ERROR_REDIRECT_LOOP ||
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ malformedURI2=Please check that the URL is correct and try again.
|
|||||||
fileNotFound=The file %S cannot be found. Please check the location and try again.
|
fileNotFound=The file %S cannot be found. Please check the location and try again.
|
||||||
fileAccessDenied=The file at %S is not readable.
|
fileAccessDenied=The file at %S is not readable.
|
||||||
# %S is replaced by the uri host
|
# %S is replaced by the uri host
|
||||||
|
httpErrorPage=%S sent back an error.
|
||||||
serverError=%S might have a temporary problem or it could have moved.
|
serverError=%S might have a temporary problem or it could have moved.
|
||||||
dnsNotFound2=%S could not be found. Please check the name and try again.
|
dnsNotFound2=%S could not be found. Please check the name and try again.
|
||||||
basicHttpAuthDisabled=Someone pretending to be the site could try to steal your info. Your connection settings could also be set up incorrectly.
|
basicHttpAuthDisabled=Someone pretending to be the site could try to steal your info. Your connection settings could also be set up incorrectly.
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ XPC_MSG_DEF(NS_ERROR_NET_TIMEOUT_EXTERNAL , "The request has been canc
|
|||||||
XPC_MSG_DEF(NS_ERROR_OFFLINE , "The requested action could not be completed in the offline state")
|
XPC_MSG_DEF(NS_ERROR_OFFLINE , "The requested action could not be completed in the offline state")
|
||||||
XPC_MSG_DEF(NS_ERROR_PORT_ACCESS_NOT_ALLOWED , "Establishing a connection to an unsafe or otherwise banned port was prohibited")
|
XPC_MSG_DEF(NS_ERROR_PORT_ACCESS_NOT_ALLOWED , "Establishing a connection to an unsafe or otherwise banned port was prohibited")
|
||||||
XPC_MSG_DEF(NS_ERROR_NET_RESET , "The connection was established, but no data was ever received")
|
XPC_MSG_DEF(NS_ERROR_NET_RESET , "The connection was established, but no data was ever received")
|
||||||
|
XPC_MSG_DEF(NS_ERROR_NET_EMPTY_RESPONSE , "The connection was established, but the browser received an empty page with an error response")
|
||||||
XPC_MSG_DEF(NS_ERROR_NET_ERROR_RESPONSE , "The connection was established, but the browser received an error response from the server")
|
XPC_MSG_DEF(NS_ERROR_NET_ERROR_RESPONSE , "The connection was established, but the browser received an error response from the server")
|
||||||
XPC_MSG_DEF(NS_ERROR_NET_INTERRUPT , "The connection was established, but the data transfer was interrupted")
|
XPC_MSG_DEF(NS_ERROR_NET_INTERRUPT , "The connection was established, but the data transfer was interrupted")
|
||||||
XPC_MSG_DEF(NS_ERROR_NET_PARTIAL_TRANSFER , "A transfer was only partially done when it completed")
|
XPC_MSG_DEF(NS_ERROR_NET_PARTIAL_TRANSFER , "A transfer was only partially done when it completed")
|
||||||
|
|||||||
@@ -1584,6 +1584,15 @@
|
|||||||
value: false
|
value: false
|
||||||
mirror: always
|
mirror: always
|
||||||
|
|
||||||
|
# If false, show internal error page for HTTP responses with error
|
||||||
|
# codes (4xx, 5xx) and "Content-Length": 0 instead of blank page
|
||||||
|
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1325876#c32 for why this
|
||||||
|
# is disabled on Android.
|
||||||
|
- name: browser.http.blank_page_with_error_response.enabled
|
||||||
|
type: bool
|
||||||
|
value: true
|
||||||
|
mirror: always
|
||||||
|
|
||||||
# The minimum area for a rect to be included in a wireframe, in CSS pixels.
|
# The minimum area for a rect to be included in a wireframe, in CSS pixels.
|
||||||
#
|
#
|
||||||
# The current value of 50 is pretty arbitrary, and will be tuned as we refine
|
# The current value of 50 is pretty arbitrary, and will be tuned as we refine
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const KNOWN_ERROR_TITLE_IDS = new Set([
|
|||||||
"unsafeContentType-title",
|
"unsafeContentType-title",
|
||||||
"netReset-title",
|
"netReset-title",
|
||||||
"netTimeout-title",
|
"netTimeout-title",
|
||||||
|
"httpErrorPage-title",
|
||||||
"serverError-title",
|
"serverError-title",
|
||||||
"unknownProtocolFound-title",
|
"unknownProtocolFound-title",
|
||||||
"proxyConnectFailure-title",
|
"proxyConnectFailure-title",
|
||||||
@@ -773,8 +774,7 @@ function getNetErrorDescParts() {
|
|||||||
case "connectionFailure":
|
case "connectionFailure":
|
||||||
case "netInterrupt":
|
case "netInterrupt":
|
||||||
case "netReset":
|
case "netReset":
|
||||||
case "netTimeout":
|
case "netTimeout": {
|
||||||
case "serverError": {
|
|
||||||
let errorTags = [
|
let errorTags = [
|
||||||
["li", "neterror-load-error-try-again"],
|
["li", "neterror-load-error-try-again"],
|
||||||
["li", "neterror-load-error-connection"],
|
["li", "neterror-load-error-connection"],
|
||||||
@@ -786,6 +786,10 @@ function getNetErrorDescParts() {
|
|||||||
return errorTags;
|
return errorTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "httpErrorPage": // 4xx
|
||||||
|
return [["li", "neterror-http-error-page"]];
|
||||||
|
case "serverError": // 5xx
|
||||||
|
return [["li", "neterror-load-error-try-again"]];
|
||||||
case "blockedByCOOP": {
|
case "blockedByCOOP": {
|
||||||
return [
|
return [
|
||||||
["p", "certerror-blocked-by-corp-headers-description"],
|
["p", "certerror-blocked-by-corp-headers-description"],
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ contentEncodingError-title = Content Encoding Error
|
|||||||
unsafeContentType-title = Unsafe File Type
|
unsafeContentType-title = Unsafe File Type
|
||||||
netReset-title = The connection was reset
|
netReset-title = The connection was reset
|
||||||
netTimeout-title = The connection has timed out
|
netTimeout-title = The connection has timed out
|
||||||
|
httpErrorPage-title = Looks like there’s a problem with this site
|
||||||
serverError-title = Looks like there’s a problem with this site
|
serverError-title = Looks like there’s a problem with this site
|
||||||
unknownProtocolFound-title = The address wasn’t understood
|
unknownProtocolFound-title = The address wasn’t understood
|
||||||
proxyConnectFailure-title = The proxy server is refusing connections
|
proxyConnectFailure-title = The proxy server is refusing connections
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ neterror-load-error-firewall = If your computer or network is protected by a fir
|
|||||||
# This warning is only shown on macOS Sequoia and later (see bug 1929377)
|
# This warning is only shown on macOS Sequoia and later (see bug 1929377)
|
||||||
neterror-load-osx-permission = If you are trying to load a local network page, please check that { -brand-short-name } has been granted Local Network permissions in the macOS Privacy & Security settings.
|
neterror-load-osx-permission = If you are trying to load a local network page, please check that { -brand-short-name } has been granted Local Network permissions in the macOS Privacy & Security settings.
|
||||||
|
|
||||||
|
neterror-http-error-page = Check to make sure you’ve typed the website address correctly.
|
||||||
|
|
||||||
neterror-captive-portal = You must log in to this network before you can access the internet.
|
neterror-captive-portal = You must log in to this network before you can access the internet.
|
||||||
|
|
||||||
# Variables:
|
# Variables:
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ ID01:
|
|||||||
- unsafeContentType-title
|
- unsafeContentType-title
|
||||||
- netReset-title
|
- netReset-title
|
||||||
- netTimeout-title
|
- netTimeout-title
|
||||||
|
- httpErrorPage-title
|
||||||
- serverError-title
|
- serverError-title
|
||||||
- unknownProtocolFound-title
|
- unknownProtocolFound-title
|
||||||
- proxyConnectFailure-title
|
- proxyConnectFailure-title
|
||||||
|
|||||||
@@ -131,6 +131,23 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIRequest* request) {
|
|||||||
if (204 == responseCode || 205 == responseCode) {
|
if (204 == responseCode || 205 == responseCode) {
|
||||||
return NS_BINDING_ABORTED;
|
return NS_BINDING_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mozilla::StaticPrefs::
|
||||||
|
browser_http_blank_page_with_error_response_enabled()) {
|
||||||
|
// Bug 1325876: Show internal error page for HTTP responses with error
|
||||||
|
// codes (4xx, 5xx) and "Content-Length": 0 instead of blank page
|
||||||
|
int64_t contentLength = 0;
|
||||||
|
rv = httpChannel->GetContentLength(&contentLength);
|
||||||
|
|
||||||
|
if (NS_FAILED(rv) || contentLength <= 0) {
|
||||||
|
if (responseCode >= 500) {
|
||||||
|
return NS_ERROR_NET_ERROR_RESPONSE;
|
||||||
|
}
|
||||||
|
if (responseCode >= 400) {
|
||||||
|
return NS_ERROR_NET_EMPTY_RESPONSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -327,6 +327,8 @@ with modules["NETWORK"]:
|
|||||||
errors["NS_ERROR_NET_RESET"] = FAILURE(20)
|
errors["NS_ERROR_NET_RESET"] = FAILURE(20)
|
||||||
# The connection was established, but browser received an error response from the server
|
# The connection was established, but browser received an error response from the server
|
||||||
errors["NS_ERROR_NET_ERROR_RESPONSE"] = FAILURE(35)
|
errors["NS_ERROR_NET_ERROR_RESPONSE"] = FAILURE(35)
|
||||||
|
# The connection was established, but browser received an empty page with 4xx, 5xx error response
|
||||||
|
errors["NS_ERROR_NET_EMPTY_RESPONSE"] = FAILURE(36)
|
||||||
# The connection was established, but the data transfer was interrupted.
|
# The connection was established, but the data transfer was interrupted.
|
||||||
errors["NS_ERROR_NET_INTERRUPT"] = FAILURE(71)
|
errors["NS_ERROR_NET_INTERRUPT"] = FAILURE(71)
|
||||||
# The connection attempt to a proxy failed.
|
# The connection attempt to a proxy failed.
|
||||||
|
|||||||
Reference in New Issue
Block a user