Repository navigation
Conversation
coerceCLICustomPreference() treated a value as numeric when it equalled
`${parseInt(value)}`, and `${NaN}` is the string "NaN". That turned
`--pref some.pref=NaN` into the number NaN, which firefox-profile then wrote
into prefs.js as the bare token `user_pref("some.pref", NaN);` instead of the
quoted string it writes for every other non-numeric value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
coerceCLICustomPreference()decides whether a--pref name=valuevalue is numeric with:parseInt('NaN')isNaN, and`${NaN}`is the string"NaN", so the literal valueNaNpasses the round-trip check and becomes the numberNaN.Downstream,
firefox-profile'ssetPreference()quotes onlytrue,falseandstringvalues and falls back toparseInt(value, 10).toString()for everything else. That means the numberNaNends up inprefs.jsas an unquoted token, while the string"NaN"— what every other non-numeric value gets — is quoted:--pref some.pref=...prefs.jsbefore this change455user_pref("some.pref", 455);NaNuser_pref("some.pref", NaN);user_pref("some.pref", "NaN");Infinityuser_pref("some.pref", "Infinity");Both lines above were produced by calling
firefox-profile's ownsetPreference(), so this is not a hypothetical serialization.NaNis not a representable preference value, andconfigureThisProfile()also logs the custom preferences withJSON.stringify(), which renders it asnull— soweb-ext run --pref some.pref=NaNreports and writes something other than what was asked for.Fix
Only accept the round-trip when
parseInt()actually produced a number. Everything else keeps its current behaviour, including the documented "floats stay strings" case (4.55is still written as"4.55").Tests
Added two regression tests to
tests/unit/test-firefox/test.preferences.js: one for theNaNvalue itself, and one pinning the neighbouring non-numeric forms (Infinity,0x1f,1e3) that the changed condition touches.12 passing,1 failing—AssertionError: expected NaN to be a string.13 passing.npm run build && npm test(eslint plus the whole unit suite):591 passing, no failures.prettier --list-differentreports no difference for both changed files.Notes
I did not find an existing issue for this, so there is no
Fixes #…in the description; say the word and I'll open one and link it.This investigation was AI-assisted (Qoder Desktop); I verified each claim above against the source in
src/firefox/preferences.jsand against the installedfirefox-profileimplementation.