[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:59:53 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 65d708f3b3417ffce9ed0e0047b4b4de9db6141c
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Nov 14 04:44:00 2002 +0000
- fixed 3099930 -- dates/times without time zones are parsed as UTC by kjs,
local time by other browsers
* kjs/date_object.cpp:
(DateProtoFuncImp::call): Handle the NaN case better, like Mozilla and OmniWeb.
(DateObjectFuncImp::call): Return NaN rather than Undefined() for bad dates.
(KJS::parseDate): Return NaN rather than Undefined() or 0 for bad dates.
(KJS::KRFCDate_parseDate): Return -1 rather than 0 for bad dates.
Assume local time if no time zone is passed. Don't return 1 if we parse 0.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 31b02cf..9aef2f2 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,17 @@
2002-11-13 Darin Adler <darin at apple.com>
+ - fixed 3099930 -- dates/times without time zones are parsed as UTC by kjs,
+ local time by other browsers
+
+ * kjs/date_object.cpp:
+ (DateProtoFuncImp::call): Handle the NaN case better, like Mozilla and OmniWeb.
+ (DateObjectFuncImp::call): Return NaN rather than Undefined() for bad dates.
+ (KJS::parseDate): Return NaN rather than Undefined() or 0 for bad dates.
+ (KJS::KRFCDate_parseDate): Return -1 rather than 0 for bad dates.
+ Assume local time if no time zone is passed. Don't return 1 if we parse 0.
+
+2002-11-13 Darin Adler <darin at apple.com>
+
- fixed 3073230 -- JavaScript time calls do I/O by lstat()ing /etc/localtime
* kjs/date_object.cpp:
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index 31b02cf..9aef2f2 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,5 +1,17 @@
2002-11-13 Darin Adler <darin at apple.com>
+ - fixed 3099930 -- dates/times without time zones are parsed as UTC by kjs,
+ local time by other browsers
+
+ * kjs/date_object.cpp:
+ (DateProtoFuncImp::call): Handle the NaN case better, like Mozilla and OmniWeb.
+ (DateObjectFuncImp::call): Return NaN rather than Undefined() for bad dates.
+ (KJS::parseDate): Return NaN rather than Undefined() or 0 for bad dates.
+ (KJS::KRFCDate_parseDate): Return -1 rather than 0 for bad dates.
+ Assume local time if no time zone is passed. Don't return 1 if we parse 0.
+
+2002-11-13 Darin Adler <darin at apple.com>
+
- fixed 3073230 -- JavaScript time calls do I/O by lstat()ing /etc/localtime
* kjs/date_object.cpp:
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 31b02cf..9aef2f2 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,5 +1,17 @@
2002-11-13 Darin Adler <darin at apple.com>
+ - fixed 3099930 -- dates/times without time zones are parsed as UTC by kjs,
+ local time by other browsers
+
+ * kjs/date_object.cpp:
+ (DateProtoFuncImp::call): Handle the NaN case better, like Mozilla and OmniWeb.
+ (DateObjectFuncImp::call): Return NaN rather than Undefined() for bad dates.
+ (KJS::parseDate): Return NaN rather than Undefined() or 0 for bad dates.
+ (KJS::KRFCDate_parseDate): Return -1 rather than 0 for bad dates.
+ Assume local time if no time zone is passed. Don't return 1 if we parse 0.
+
+2002-11-13 Darin Adler <darin at apple.com>
+
- fixed 3073230 -- JavaScript time calls do I/O by lstat()ing /etc/localtime
* kjs/date_object.cpp:
diff --git a/JavaScriptCore/kjs/date_object.cpp b/JavaScriptCore/kjs/date_object.cpp
index 8f4b1aa..14cbcb7 100644
--- a/JavaScriptCore/kjs/date_object.cpp
+++ b/JavaScriptCore/kjs/date_object.cpp
@@ -199,6 +199,8 @@ static UString formatLocaleTime(time_t tv)
using namespace KJS;
+const time_t invalidDate = -1;
+
// ------------------------------ DateInstanceImp ------------------------------
const ClassInfo DateInstanceImp::info = {"Date", 0, 0, 0};
@@ -319,6 +321,34 @@ Value DateProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
#endif
Value v = thisObj.internalValue();
double milli = v.toNumber(exec);
+
+ if (isNaN(milli)) {
+ switch (id) {
+ case ToString:
+ case ToDateString:
+ case ToTimeString:
+ case ToGMTString:
+ case ToUTCString:
+ case ToLocaleString:
+ case ToLocaleDateString:
+ case ToLocaleTimeString:
+ return String("Invalid Date");
+ case ValueOf:
+ case GetTime:
+ case GetYear:
+ case GetFullYear:
+ case GetMonth:
+ case GetDate:
+ case GetDay:
+ case GetHours:
+ case GetMinutes:
+ case GetSeconds:
+ case GetMilliSeconds:
+ case GetTimezoneOffset:
+ return Number(NaN);
+ }
+ }
+
time_t tv = (time_t)(milli / 1000.0);
int ms = int(milli - tv * 1000.0);
@@ -341,9 +371,6 @@ Value DateProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
break;
case ToGMTString:
case ToUTCString:
- // FIXME: In other browsers, toUTCString seems to do toLocaleTimeString,
- // instead of what hte specification says. Do we need to do that to be
- // bug-compatible? Just in quirks mode?
result = String(formatDate(*t, true) + " " + formatTime(*t));
break;
case ToLocaleString:
@@ -604,7 +631,7 @@ Value DateObjectFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &
if (args[0].type() == StringType)
return parseDate(args[0].toString(exec));
else
- return Undefined();
+ return Number(NaN);
}
else { // UTC
struct tm t;
@@ -640,8 +667,8 @@ Value KJS::parseDate(const String &s)
#ifdef KJS_VERBOSE
fprintf(stderr,"KRFCDate_parseDate returned seconds=%d\n",seconds);
#endif
- if ( seconds == -1 )
- return Undefined();
+ if ( seconds == invalidDate )
+ return Number(NaN);
else
return Number(seconds * 1000.0);
}
@@ -654,7 +681,7 @@ Value KJS::parseDate(const String &s)
if ( secondSlash == -1 )
{
fprintf(stderr,"KJS::parseDate parsing for this format isn't implemented\n%s", u.ascii());
- return Number(0);
+ return Number(NaN);
}
int day = u.substr(firstSlash+1,secondSlash-firstSlash-1).toULong();
int year = u.substr(secondSlash+1).toULong();
@@ -669,7 +696,7 @@ Value KJS::parseDate(const String &s)
if ( seconds == -1 )
{
fprintf(stderr,"KJS::parseDate mktime returned -1.\n%s", u.ascii());
- return Undefined();
+ return Number(NaN);
}
else
return Number(seconds * 1000.0);
@@ -728,7 +755,6 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
//
// We ignore the weekday
//
- time_t result = 0;
int offset = 0;
char *newPosStr;
const char *dateString = _date.ascii();
@@ -770,16 +796,16 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
dateString++;
if (!*dateString)
- return result; // Invalid date
+ return invalidDate; // Invalid date
// ' 09-Nov-99 23:12:40 GMT'
day = strtol(dateString, &newPosStr, 10);
dateString = newPosStr;
if ((day < 1) || (day > 31))
- return result; // Invalid date;
+ return invalidDate; // Invalid date;
if (!*dateString)
- return result; // Invalid date
+ return invalidDate; // Invalid date
if (*dateString == '-')
dateString++;
@@ -792,7 +818,7 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
for(int i=0; i < 3;i++)
{
if (!*dateString || (*dateString == '-') || isspace(*dateString))
- return result; // Invalid date
+ return invalidDate; // Invalid date
monthStr[i] = tolower(*dateString++);
}
monthStr[3] = '\0';
@@ -800,27 +826,27 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
newPosStr = (char*)strstr(haystack, monthStr);
if (!newPosStr)
- return result; // Invalid date
+ return invalidDate; // Invalid date
month = (newPosStr-haystack)/3; // Jan=00, Feb=01, Mar=02, ..
if ((month < 0) || (month > 11))
- return result; // Invalid date
+ return invalidDate; // Invalid date
while(*dateString && (*dateString != '-') && !isspace(*dateString))
dateString++;
if (!*dateString)
- return result; // Invalid date
+ return invalidDate; // Invalid date
// '-99 23:12:40 GMT'
if ((*dateString != '-') && !isspace(*dateString))
- return result; // Invalid date
+ return invalidDate; // Invalid date
dateString++;
}
if ((month < 0) || (month > 11))
- return result; // Invalid date
+ return invalidDate; // Invalid date
// '99 23:12:40 GMT'
year = strtol(dateString, &newPosStr, 10);
@@ -834,40 +860,40 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
year += 1900; // Y2K
if ((year < 1900) || (year > 2500))
- return result; // Invalid date
+ return invalidDate; // Invalid date
// Don't fail if the time is missing.
if (*dateString)
{
// ' 23:12:40 GMT'
if (!isspace(*dateString++))
- return result; // Invalid date
+ return invalidDate; // Invalid date
hour = strtol(dateString, &newPosStr, 10);
dateString = newPosStr;
if ((hour < 0) || (hour > 23))
- return result; // Invalid date
+ return invalidDate; // Invalid date
if (!*dateString)
- return result; // Invalid date
+ return invalidDate; // Invalid date
// ':12:40 GMT'
if (*dateString++ != ':')
- return result; // Invalid date
+ return invalidDate; // Invalid date
minute = strtol(dateString, &newPosStr, 10);
dateString = newPosStr;
if ((minute < 0) || (minute > 59))
- return result; // Invalid date
+ return invalidDate; // Invalid date
if (!*dateString)
- return result; // Invalid date
+ return invalidDate; // Invalid date
// ':40 GMT'
if (*dateString != ':' && !isspace(*dateString))
- return result; // Invalid date
+ return invalidDate; // Invalid date
// seconds are optional in rfc822 + rfc2822
if (*dateString ==':') {
@@ -877,7 +903,7 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
dateString = newPosStr;
if ((second < 0) || (second > 59))
- return result; // Invalid date
+ return invalidDate; // Invalid date
} else {
dateString++;
}
@@ -888,13 +914,17 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
// don't fail if the time zone is missing, some
// broken mail-/news-clients omit the time zone
- if (*dateString) {
-
+ bool localTime;
+ if (*dateString == 0) {
+ // Other web browsers interpret missing time zone as "current time zone".
+ localTime = true;
+ } else {
+ localTime = false;
if ((*dateString == '+') || (*dateString == '-')) {
offset = strtol(dateString, &newPosStr, 10);
if ((offset < -9959) || (offset > 9959))
- return result; // Invalid date
+ return invalidDate; // Invalid date
int sgn = (offset < 0)? -1:1;
offset = abs(offset);
@@ -936,6 +966,19 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
}
}
+ time_t result;
+
+ if (localTime) {
+ struct tm tm;
+ tm.tm_year = year - 1900;
+ tm.tm_mon = month;
+ tm.tm_mday = day;
+ tm.tm_hour = hour;
+ tm.tm_min = minute;
+ tm.tm_sec = second;
+ tm.tm_isdst = -1;
+ result = mktime(&tm);
+ } else {
result = ymdhms_to_seconds(year, month+1, day, hour, minute, second);
// avoid negative time values
@@ -943,11 +986,7 @@ time_t KJS::KRFCDate_parseDate(const UString &_date)
offset = 0;
result -= offset*60;
-
- // If epoch 0 return epoch +1 which is Thu, 01-Jan-70 00:00:01 GMT
- // This is so that parse error and valid epoch 0 return values won't
- // be the same for sensitive applications...
- if (result < 1) result = 1;
+ }
return result;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list