Closed Bug 445049 Opened 16 years ago Closed 16 years ago

Preference value types are not validated (or converted) before being set

Categories

(Toolkit :: Preferences, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: iannbugzilla, Assigned: neil)

References

()

Details

(Keywords: regression)

Attachments

(1 file)

If you have a preference of type int, it allows you to set the value to the string for example if it is on a radiogroup, radio buttons only take string values so selecting a radio button will set the preference value to a string rather than int. I can see this being a problem on radiogroups and menulists but not sure if on anything else. This probably also affects preferences of different types (bool perhaps) and should look at converting the aValue to the correct type for those ones.
For int types, this is a regression from bug 301837. bool types still work correctly.
Blocks: 301837
Keywords: regression
I had some other ideas for integer conversions: parseInt(value, 10) | 0; - casts to PRInt32 value | 0; - casts to PRInt32 and accepts hex input parseInt(value) | 0; - casts to PRInt32 and accepts hex or octal input parseInt(value); - accepts hex or octal input value - 0; - accepts hex input
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #329361 - Flags: review?(gavin.sharp)
>+ return parseInt(value, 10) || 0; Non-integer input will return the integer it starts with (if any), e.g. parseInt("010busted", 10) will return 10 - is that wanted? (Yes, I know it did before, too.)
Comment on attachment 329361 [details] [diff] [review] Proposed patch (Checkin: Comment 5) Thankfully the other bit touched by attachment 190281 [details] [diff] [review] has already been fixed.
Attachment #329361 - Flags: review?(gavin.sharp) → review+
Blocks: 444157
Attachment #329361 - Attachment description: Proposed patch → Proposed patch (Checkin: Comment 5)
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: