Open Bug 1922052 Opened 9 months ago Updated 9 months ago

Site identity panel gets confused by `file` url with host

Categories

(Core :: Networking, task, P2)

task

Tracking

()

People

(Reporter: edgul, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

See browser/base/content/browser-siteIdentity.js

One:
this._uriHasHost can now be true for file URLs. Fix that where it is set in setURI() by checking that it's not a file URL: this._uriHasHost = !!this._uri.host && !uri.schemeIs("file");
OR
move up initialization of _isURILoadedFromFile and use: this._uriHasHost = !!this._uri.host && !this._isURILoadedFromFile;

Two:
getHostForDisplay() is supposed to return the full spec for file URLs, but now it can unexpectedly return a host for them. You could fix the special case at the end to be if (!host || this._isURILoadedFromFile) {
but better to fix it at the top where host is set in the first place and avoid wasteful invocation of the IDN service on non-hosts. URLs that don't have hosts. Only set the host if this._uriHasHost is true. Might be safer to do that check inside getEffectiveHost(); it's not currently used anywhere else, but it doesn't start with an underscore and someone in the future might think it's a public part of gIdentityHandler. Or rename it to _getEffectiveHost() so people know to stay away. All of the following are currently wrong for file URLs that have a host part:

  • This is used in this file to set the "Site information for ${}" identity panel header and the "Connection security for ${}" string
  • gIdentityHandler.getHostForDisplay() is used to set the "Permissions for ${}" permissions panel header in browser-sitePermissionPanel.js
  • gIdentityHandler.getHostForDisplay() is used to set the panel header "Protections for ${}" in browser-siteProtections.js, and the aria-label "Enhanced Tracking Protection: On for ${}"

Three:
Unrelated to file URLs, but these two chunks appear to be setting the same string twice
https://searchfox.org/mozilla-central/rev/6e2e933cd6b7931e1d4e8bd8af8daa9788b27760/browser/base/content/browser-siteIdentity.js#1147-1153,1163-1169

Severity: -- → N/A
Priority: -- → P2
Whiteboard: [necko-triaged]
You need to log in before you can comment on or make changes to this bug.