forked from mirrors/gecko-dev
Bug 1881930 - Be more strict about delimiter after day of week r=arai
Differential Revision: https://phabricator.services.mozilla.com/D207674
This commit is contained in:
parent
bcc703fbc9
commit
69bdd20b2c
2 changed files with 10 additions and 7 deletions
|
|
@ -1387,11 +1387,12 @@ static bool ParseDate(DateTimeInfo::ForceUTC forceUTC, const CharT* s,
|
|||
if (IsAsciiDigit(s[index])) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Reject numbers directly after letters e.g. foo2
|
||||
if (IsAsciiDigit(s[index]) && IsAsciiAlpha(s[index - 1])) {
|
||||
return false;
|
||||
}
|
||||
} else if (!strchr(" ,.-/", s[index])) {
|
||||
// We're only allowing the above delimiters after the day of
|
||||
// week to prevent things such as "foo_1" from being parsed
|
||||
// as a date, which may break software which uses this function
|
||||
// to determine whether or not something is a date.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3668,8 +3669,8 @@ static bool ToDateString(JSContext* cx, const CallArgs& args, ClippedTime t) {
|
|||
if (!locale) {
|
||||
return false;
|
||||
}
|
||||
return FormatDate(cx, ForceUTC(cx->realm()), locale,
|
||||
t.toDouble(), FormatSpec::DateTime, args.rval());
|
||||
return FormatDate(cx, ForceUTC(cx->realm()), locale, t.toDouble(),
|
||||
FormatSpec::DateTime, args.rval());
|
||||
}
|
||||
|
||||
static bool DateNoArguments(JSContext* cx, const CallArgs& args) {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ const rejected = [
|
|||
"Sep 26 1995 foo",
|
||||
"1995 foo Sep 26",
|
||||
"foo2 Sep 26 1995",
|
||||
"Tuesday_Sep 26 1995",
|
||||
"foo_12",
|
||||
];
|
||||
|
||||
for (const format of formats) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue