Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
torbutton
Commits
bb975009
Commit
bb975009
authored
Sep 05, 2019
by
Alex Catarineu
Committed by
Georg Koppen
Sep 06, 2019
Browse files
Bug 31562: Fix circuit display for error pages
parent
d796dd27
Changes
2
Hide whitespace changes
Inline
Side-by-side
chrome/content/torbutton.js
View file @
bb975009
...
...
@@ -850,7 +850,7 @@ function torbutton_send_ctrl_cmd(command) {
// Bug 1506 P4: Needed for New IP Address
function
torbutton_new_circuit
()
{
let
firstPartyDomain
=
getDomainForBrowser
(
gBrowser
);
let
firstPartyDomain
=
getDomainForBrowser
(
gBrowser
.
selectedBrowser
);
let
domainIsolator
=
Cc
[
"
@torproject.org/domain-isolator;1
"
]
.
getService
(
Ci
.
nsISupports
).
wrappedJSObject
;
...
...
modules/utils.js
View file @
bb975009
...
...
@@ -4,9 +4,6 @@
// ### Import Mozilla Services
const
{
Services
}
=
ChromeUtils
.
import
(
"
resource://gre/modules/Services.jsm
"
);
// ### About firstPartyDomain literal
const
k_tb_about_uri_first_party_domain
=
"
about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla
"
;
// ## Pref utils
// __prefs__. A shortcut to Mozilla Services.prefs.
...
...
@@ -212,30 +209,34 @@ var show_torbrowser_manual = () => {
return
availableLocales
.
indexOf
(
shortLocale
)
>=
0
;
}
var
getFPDFromHost
=
(
hostname
)
=>
{
try
{
return
Services
.
eTLD
.
getBaseDomainFromHost
(
hostname
);
}
catch
(
e
)
{
if
(
e
.
result
==
Cr
.
NS_ERROR_HOST_IS_IP_ADDRESS
||
e
.
result
==
Cr
.
NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS
)
{
return
hostname
;
}
}
return
null
;
}
// Assuming this is called with gBrowser.selectedBrowser
var
getDomainForBrowser
=
(
browser
)
=>
{
let
firstPartyDomain
=
browser
.
contentPrincipal
.
originAttributes
.
firstPartyDomain
;
// Bug 22538: For neterror or certerror, get firstPartyDomain causing it from the u param
if
(
firstPartyDomain
===
k_tb_about_uri_first_party_domain
)
{
let
knownErrors
=
[
"
about:neterror
"
,
"
about:certerror
"
];
let
origin
=
browser
.
contentPrincipal
.
origin
||
''
;
if
(
knownErrors
.
some
(
x
=>
origin
.
startsWith
(
x
)))
{
try
{
let
urlOrigin
=
new
URL
(
origin
);
let
{
hostname
}
=
new
URL
(
urlOrigin
.
searchParams
.
get
(
'
u
'
));
if
(
hostname
)
{
try
{
firstPartyDomain
=
Services
.
eTLD
.
getBaseDomainFromHost
(
hostname
);
}
catch
(
e
)
{
if
(
e
.
result
==
Cr
.
NS_ERROR_HOST_IS_IP_ADDRESS
||
e
.
result
==
Cr
.
NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS
)
{
firstPartyDomain
=
hostname
;
}
}
}
}
catch
(
e
)
{}
let
fpd
=
browser
.
contentPrincipal
.
originAttributes
.
firstPartyDomain
;
// Bug 31562: For neterror or certerror, get the original URL from
// browser.currentURI and use it to calculate the firstPartyDomain.
let
knownErrors
=
[
"
about:neterror
"
,
"
about:certerror
"
];
let
documentURI
=
browser
.
documentURI
;
if
(
documentURI
&&
documentURI
.
schemeIs
(
'
about
'
)
&&
knownErrors
.
some
(
x
=>
documentURI
.
spec
.
startsWith
(
x
)))
{
let
knownSchemes
=
[
"
http
"
,
"
https
"
,
"
ftp
"
];
let
currentURI
=
browser
.
currentURI
;
if
(
currentURI
&&
knownSchemes
.
some
(
x
=>
currentURI
.
schemeIs
(
x
)))
{
fpd
=
getFPDFromHost
(
currentURI
.
host
)
||
fpd
;
}
}
return
f
irstPartyDomain
;
return
f
pd
;
};
// Export utility functions for external use.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment