Skip to content

Firefox managed storage properties other than adminSettings not applying #2067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
8 tasks done
theaquamarine opened this issue Mar 26, 2022 · 6 comments
Closed
8 tasks done

Comments

@theaquamarine
Copy link

Prerequisites

I tried to reproduce the issue when...

  • uBO is the only extension
  • uBO with default lists/settings
  • using a new, unmodified browser profile

Description

When configuring uBlock's managed storage properties for Firefox, properties other than adminSettings aren't being applied, but they're applied properly in Chrome and Edge. I'm using the Windows registry, but have tested quickly using a json and I think the same thing is happening.

I believe the issue is Firefox is escaping the properties and causing them to be read as strings rather than objects, as typeof (await vAPI.adminStorage.get(['toOverwrite'])).toOverwrite is string in Firefox but object in Chrome and Edge. adminSettings works as JSON.parse() is used on it, but not on the other properties, so the fix is probably more if ( typeof json === 'string' && json !== '' ) {data = JSON.parse(json);} like https://github.com/gorhill/uBlock/blob/ab6a59daf8bd183cbaf9f07d22f9d432d4adfc44/src/js/storage.js#L1392

The properties are also shown escaped on about:policies in Firefox even if they are not escaped in the registry (but not escaped on chrome://policy or edge://policy) suggesting Firefox is escaping them, but I've not been able to find anything saying this if this is expected.

A specific URL where the issue occurs

https://github.com

Steps to Reproduce

  1. Configure an admin policy other than adminSettings, eg toOverwrite [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Mozilla\Firefox\3rdparty\Extensions\[email protected]] "toOverwrite"="{\"trustedSiteDirectives\": [\"example.com\",\"example.org\"]}"

  2. Start Firefox

Expected behavior

Settings are applied, in this example trusted sites are set to example.com and example.org

Actual behavior

Settings are applied, in this example trusted sites are not set

uBlock Origin version

1.41.8

Browser name and version

Firefox 98.0.2

Operating System and version

Windows Server 2019 17763.737

@theaquamarine
Copy link
Author

Same using browser.storage.managed.get() - string in Firefox but object in Chrome & Edge.

browser.storage.managed.get(['toOverwrite'], function(result) {
  console.log(typeof result.toOverwrite)})

theaquamarine added a commit to theaquamarine/uBlock that referenced this issue Mar 26, 2022
Firefox preferences appear to not work because of
uBlockOrigin/uBlock-issues#2067
@gorhill
Copy link
Member

gorhill commented Mar 30, 2022

Configure an admin policy other than adminSettings, eg toOverwrite [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Mozilla\Firefox\3rdparty\Extensions\[email protected]] "toOverwrite"="{\"trustedSiteDirectives\": [\"example.com\",\"example.org\"]}"

I don't have Windows but what you are doing does not match the MDN documentation.

@theaquamarine
Copy link
Author

I think that's just a case of the docs being outdated - there's a couple of examples of this approach being used by other extensions, and currently works with uBlock for configuring adminSettings, or for all settings with the PR applied.

@gorhill
Copy link
Member

gorhill commented Mar 30, 2022

The other thing I observe is that you set toOverwrite to a string "{\"trustedSiteDirectives\": [\"example.com\",\"example.org\"]}".

It's supposed to be an object, so should it not be {"trustedSiteDirectives": ["example.com","example.org"]} instead?

@theaquamarine
Copy link
Author

Ah sorry, I should've flagged that- no, that's just the export tool, it's not escaped in the registry.

So the registry ends up looking like this
image
which is shown on Firefox's about:policies like this
image
and then that's presented to the extension as a string, rather than an array
image

vs the same setting in Chrome, on chrome://policy, and inspecting the extension in Chrome
image
image
image

@theaquamarine
Copy link
Author

Mozilla say this is expected, and I've now got configuring Firefox via the registry working properly by changing the settings to REG_MULTI_SZ instead of REG_SZ as those are treated as json instead https://bugzilla.mozilla.org/show_bug.cgi?id=1762253

theaquamarine added a commit to theaquamarine/uBlock-admx that referenced this issue May 7, 2022
Firefox preferences appear to not work because of
uBlockOrigin/uBlock-issues#2067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants