saadtazi / firefox-profile-js

Firefox Profile creation using nodejs and CLI
MIT License
60 stars 30 forks source link

`setPreference` doesn't escape quotes in values #130

Open ROpdebee opened 2 years ago

ROpdebee commented 2 years ago

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.