On Fri, Feb 2, 2018 at 9:47 AM, Boris Zbarsky <bzbar...@mit.edu> wrote:

>
> What happens if a user's prefs file has things that were OK but now fail?
> Is it effectively dataloss in that we will not parse anything after that
> and then write out the modified pref file with all the later things missing?
>

There are two kinds of "user's prefs".

- prefs.js, which is written by Firefox. Firefox should always generate
data that is accepted by the new parser, so I don't think there is a
problem there. (If users do hand-edit, there might be problems. But that
file has a big "Do not edit this file" warning at the top, so I'm not too
worried about that case.)

- user.js, which is hand-written by users. If there is a syntax error in
this file the parser will issue an error message[*], abort, and any prefs
after the syntax error will be ignored, but Firefox will otherwise run
normally.

So I don't think data loss is a concern, but user.js prefs that were
previously accepted might now be ignored.

[*] One tricky question is what to do with syntax errors. The current
behaviour is here:
https://searchfox.org/mozilla-central/source/modules/libpref/Preferences.cpp#1000-1011.
It writes the error to the browser console, but if that fails, prints it to
stderr instead. And then it also does an NS_WARNING. This means that errors
are easy to overlook, especially in user.js. Do you have suggestions on a
better approach? Do you think the parser should do error recovery? Bug
107624 has some context for this.

- The old parser allowed integer literals to overflow, silently wrapping
>> them.
>>
>>    The new parser treats integer overflow as a parse error.
>>
>
> This seems like a footgun for users who set numeric prefs by hand...
>

Silently wrapping was also a footgun that came up in practice in bug
1424030 and bug 1434813. IMO it's better to give a clear error than to
silently do the wrong thing...

Nick
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to