firefox-profile-js icon indicating copy to clipboard operation
firefox-profile-js copied to clipboard

`setPreference` doesn't escape quotes in values

Open ROpdebee opened this issue 3 years ago • 0 comments

Example

const profile = new FirefoxProfile();
profile.setPreference('foo', '"bar"');
profile.updatePreferences();
console.log(await readFile(profile.userPrefs, { encoding: 'utf8' }));

This leads to a file containing the following line:

user_pref("foo", ""bar"");

and FF errors out because it's invalid.


Workaround

profile.defaultPreferences['foo'] = JSON.stringify('"bar"');
profile.updatePreferences();

Potential fix

Use JSON.stringify in setPreference. That might be able to replace the custom cleaning logic altogether.

ROpdebee avatar Nov 20 '21 16:11 ROpdebee