Bug 755508: Do not allow the use of NaN dates as keys. r=sicking

This commit is contained in:
Kyle Huey 2012-05-25 11:52:19 -07:00
parent 8ab9ce853c
commit b27b2d8178
2 changed files with 6 additions and 0 deletions

View File

@ -168,6 +168,9 @@ Key::EncodeJSValInternal(JSContext* aCx, const jsval aVal,
} }
if (JS_ObjectIsDate(aCx, obj)) { if (JS_ObjectIsDate(aCx, obj)) {
if (!js_DateIsValid(aCx, obj)) {
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
}
EncodeNumber(js_DateGetMsecSinceEpoch(aCx, obj), eDate + aTypeOffset); EncodeNumber(js_DateGetMsecSinceEpoch(aCx, obj), eDate + aTypeOffset);
return NS_OK; return NS_OK;
} }

View File

@ -211,11 +211,14 @@ function testSteps()
null, null,
/x/, /x/,
{}, {},
new Date(NaN),
new Date("foopy"),
[nan], [nan],
[undefined], [undefined],
[null], [null],
[/x/], [/x/],
[{}], [{}],
[new Date(NaN)],
[1, nan], [1, nan],
[1, undefined], [1, undefined],
[1, null], [1, null],