Open Bug 1827422 Opened 2 years ago Updated 2 years ago

Merge isRestrictedPrincipalURI from ExtensionDNR.sys.mjs with ChannelWrapper::CanModify

Categories

(WebExtensions :: Request Handling, task, P3)

task

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: robwu, Assigned: robwu)

References

(Depends on 1 open bug)

Details

(Whiteboard: [addons-jira])

After landing the small refactor of WebRequest.jsm (bug 1825882), we should merge the isRestrictedPrincipalURI logic introduced in bug 1826651 with ChannelWrapper::CanModify. The result would be logically equivalent, but serves multiple purposes:

  1. ChannelWrapper::CanModify can very efficiently check schemas (with atoms instead of nsIURI::SchemeIs). This is a slight optimization in the DNR evaluation, which already checks channel.canModify.
  2. Validation in CanModify is more explicit than relying indirectly on implementation details in MatchPattern.cpp + allowedOrigins in Extension.jsm.

Note: we should ideally fix view-source: detection (bug 1828141) because the referenced isRestrictedPrincipalURI logic [1] currently causes view-source:-URIs to be ignored.

[1] https://searchfox.org/mozilla-central/rev/7e1f58e993f362d5d16bd1230a4417ebb2aa07b3/toolkit/components/extensions/ExtensionDNR.sys.mjs#1833-1892

Severity: -- → N/A
Priority: -- → P3

Another scheme to consider is ws(s) - bug 1828151.

While loadingPrincipal can never have ws(s) (explicitly called out in the source of isRestrictedPrincipalURI), we also use the isRestrictedPrincipalURI test helper in testMatchOutcome (source). If we introduce support for "ws"/"wss" in DNR, we should also adjust the logic accordingly.

You need to log in before you can comment on or make changes to this bug.