]> granicus.if.org Git - php/commitdiff
MFB51: Fixed bug #35705 (strtotime() fails to parse soap date format
authorIlia Alshanetsky <iliaa@php.net>
Fri, 16 Dec 2005 22:40:09 +0000 (22:40 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 16 Dec 2005 22:40:09 +0000 (22:40 +0000)
without TZ).

ext/date/lib/parse_date.c
ext/date/lib/parse_date.re
ext/date/tests/bug35705.phpt [new file with mode: 0644]

index a852d2a5c81bdede3d1d4afd7ad77345ce217f63..884d511293fbd8ca51f61f3ffb4df259d56dfb45 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.9.11.rc1 on Mon Dec 12 21:29:37 2005 */
+/* Generated by re2c 0.9.11.rc1 on Fri Dec 16 17:38:44 2005 */
 #line 1 "ext/date/lib/parse_date.re"
 /*
    +----------------------------------------------------------------------+
@@ -850,7 +850,7 @@ yy2:
 yy3:
        YYDEBUG(3, *YYCURSOR);
 
-#line 1321 "ext/date/lib/parse_date.re"
+#line 1323 "ext/date/lib/parse_date.re"
 {
                int tz_not_found;
                DEBUG_OUTPUT("tzcorrection | tz");
@@ -978,7 +978,7 @@ yy7:
 yy8:
        YYDEBUG(8, *YYCURSOR);
 
-#line 1387 "ext/date/lib/parse_date.re"
+#line 1389 "ext/date/lib/parse_date.re"
 {
 /*             printf("unexpected character: #%d, %c ", *s->tok, *s->tok); */
                s->errors++;
@@ -2023,7 +2023,7 @@ yy44:
 yy45:
        YYDEBUG(45, *YYCURSOR);
 
-#line 1376 "ext/date/lib/parse_date.re"
+#line 1378 "ext/date/lib/parse_date.re"
 {
                goto std;
        }
@@ -2039,7 +2039,7 @@ yy47:
 yy48:
        YYDEBUG(48, *YYCURSOR);
 
-#line 1381 "ext/date/lib/parse_date.re"
+#line 1383 "ext/date/lib/parse_date.re"
 {
                s->pos = cursor; s->line++;
                goto std;
@@ -2252,7 +2252,7 @@ yy67:
 yy68:
        YYDEBUG(68, *YYCURSOR);
 
-#line 1360 "ext/date/lib/parse_date.re"
+#line 1362 "ext/date/lib/parse_date.re"
 {
                timelib_ull i;
                DEBUG_OUTPUT("relative");
@@ -3244,7 +3244,7 @@ yy172:
 yy173:
        YYDEBUG(173, *YYCURSOR);
 
-#line 1304 "ext/date/lib/parse_date.re"
+#line 1306 "ext/date/lib/parse_date.re"
 {
                timelib_sll i;
                int         behavior;
@@ -5022,7 +5022,7 @@ yy341:
 yy342:
        YYDEBUG(342, *YYCURSOR);
 
-#line 1288 "ext/date/lib/parse_date.re"
+#line 1290 "ext/date/lib/parse_date.re"
 {
                const timelib_relunit* relunit;
                DEBUG_OUTPUT("daytext");
@@ -6306,7 +6306,7 @@ yy431:
 yy432:
        YYDEBUG(432, *YYCURSOR);
 
-#line 1332 "ext/date/lib/parse_date.re"
+#line 1334 "ext/date/lib/parse_date.re"
 {
                int tz_not_found;
                DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz");
@@ -7164,7 +7164,7 @@ yy494:
 yy495:
        YYDEBUG(495, *YYCURSOR);
 
-#line 1219 "ext/date/lib/parse_date.re"
+#line 1221 "ext/date/lib/parse_date.re"
 {
                DEBUG_OUTPUT("pgtextshort");
                TIMELIB_INIT;
@@ -9028,7 +9028,7 @@ yy596:
 yy597:
        YYDEBUG(597, *YYCURSOR);
 
-#line 1273 "ext/date/lib/parse_date.re"
+#line 1275 "ext/date/lib/parse_date.re"
 {
                DEBUG_OUTPUT("ago");
                TIMELIB_INIT;
@@ -13432,7 +13432,7 @@ yy902:
 yy903:
        YYDEBUG(903, *YYCURSOR);
 
-#line 1245 "ext/date/lib/parse_date.re"
+#line 1247 "ext/date/lib/parse_date.re"
 {
                int tz_not_found;
                DEBUG_OUTPUT("clf");
@@ -13850,7 +13850,7 @@ yy955:
 yy956:
        YYDEBUG(956, *YYCURSOR);
 
-#line 1232 "ext/date/lib/parse_date.re"
+#line 1234 "ext/date/lib/parse_date.re"
 {
                DEBUG_OUTPUT("pgtextreverse");
                TIMELIB_INIT;
@@ -13995,7 +13995,7 @@ yy967:
 yy968:
        YYDEBUG(968, *YYCURSOR);
 
-#line 1264 "ext/date/lib/parse_date.re"
+#line 1266 "ext/date/lib/parse_date.re"
 {
                DEBUG_OUTPUT("year4");
                TIMELIB_INIT;
@@ -14360,7 +14360,7 @@ yy996:
 yy997:
        YYDEBUG(997, *YYCURSOR);
 
-#line 1200 "ext/date/lib/parse_date.re"
+#line 1202 "ext/date/lib/parse_date.re"
 {
                timelib_sll w, d;
                DEBUG_OUTPUT("isoweek");
@@ -14386,7 +14386,7 @@ yy998:
 yy999:
        YYDEBUG(999, *YYCURSOR);
 
-#line 1181 "ext/date/lib/parse_date.re"
+#line 1183 "ext/date/lib/parse_date.re"
 {
                timelib_sll w, d;
                DEBUG_OUTPUT("isoweekday");
@@ -14473,7 +14473,7 @@ yy1002:
 yy1003:
        YYDEBUG(1003, *YYCURSOR);
 
-#line 1168 "ext/date/lib/parse_date.re"
+#line 1170 "ext/date/lib/parse_date.re"
 {
                DEBUG_OUTPUT("pgydotd");
                TIMELIB_INIT;
@@ -14715,13 +14715,15 @@ yy1021:
                s->time->s = timelib_get_nr((char **) &ptr, 2);
                if (*ptr == '.') {
                        s->time->f = timelib_get_frac_nr((char **) &ptr, 9);
-                       s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
-                       s->errors += tz_not_found;
+                       if (*ptr) { /* timezone is optional */
+                               s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+                               s->errors += tz_not_found;
+                       }
                }
                TIMELIB_DEINIT;
                return TIMELIB_XMLRPC_SOAP;
        }
-#line 12653 "ext/date/lib/parse_date.c"
+#line 12655 "ext/date/lib/parse_date.c"
 yy1022:
        YYDEBUG(1022, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -15356,7 +15358,7 @@ yy1112:
                TIMELIB_DEINIT;
                return TIMELIB_ISO_DATE;
        }
-#line 13106 "ext/date/lib/parse_date.c"
+#line 13108 "ext/date/lib/parse_date.c"
 yy1113:
        YYDEBUG(1113, *YYCURSOR);
        yyaccept = 19;
@@ -15895,20 +15897,21 @@ yy1160:
        goto yy1161;
 yy1161:
        YYDEBUG(1161, *YYCURSOR);
-       ++YYCURSOR;
+       yyaccept = 20;
+       YYMARKER = ++YYCURSOR;
        if((YYLIMIT - YYCURSOR) < 6) YYFILL(6);
        yych = *YYCURSOR;
        goto yy1162;
 yy1162:
        YYDEBUG(1162, *YYCURSOR);
        if(yych <= ','){
-               if(yych != '+') goto yy52;
+               if(yych != '+') goto yy1021;
                goto yy1163;
        } else {
                if(yych <= '-') goto yy1163;
-               if(yych <= '/') goto yy52;
+               if(yych <= '/') goto yy1021;
                if(yych <= '9') goto yy1161;
-               goto yy52;
+               goto yy1021;
        }
 yy1163:
        YYDEBUG(1163, *YYCURSOR);
@@ -16469,7 +16472,7 @@ yy1205:
                TIMELIB_DEINIT;
                return TIMELIB_GNU_NOCOLON;
        }
-#line 14031 "ext/date/lib/parse_date.c"
+#line 14034 "ext/date/lib/parse_date.c"
 yy1206:
        YYDEBUG(1206, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -16583,7 +16586,7 @@ yy1213:
                TIMELIB_DEINIT;
                return TIMELIB_ISO_NOCOLON;
        }
-#line 14129 "ext/date/lib/parse_date.c"
+#line 14132 "ext/date/lib/parse_date.c"
 yy1214:
        YYDEBUG(1214, *YYCURSOR);
        yyaccept = 22;
@@ -16961,7 +16964,7 @@ yy1238:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 14451 "ext/date/lib/parse_date.c"
+#line 14454 "ext/date/lib/parse_date.c"
 yy1239:
        YYDEBUG(1239, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -17054,7 +17057,7 @@ yy1247:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 14526 "ext/date/lib/parse_date.c"
+#line 14529 "ext/date/lib/parse_date.c"
 yy1248:
        YYDEBUG(1248, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -17077,7 +17080,7 @@ yy1250:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 14543 "ext/date/lib/parse_date.c"
+#line 14546 "ext/date/lib/parse_date.c"
 yy1251:
        YYDEBUG(1251, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -17180,7 +17183,7 @@ yy1259:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 14628 "ext/date/lib/parse_date.c"
+#line 14631 "ext/date/lib/parse_date.c"
 yy1260:
        YYDEBUG(1260, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -17217,7 +17220,7 @@ yy1262:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 14659 "ext/date/lib/parse_date.c"
+#line 14662 "ext/date/lib/parse_date.c"
 yy1263:
        YYDEBUG(1263, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -17297,10 +17300,10 @@ yy1271:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 14721 "ext/date/lib/parse_date.c"
+#line 14724 "ext/date/lib/parse_date.c"
 }
 }
-#line 1392 "ext/date/lib/parse_date.re"
+#line 1394 "ext/date/lib/parse_date.re"
 
 }
 
index 52ee0549c3ee10b5fe85f304651b7dfb5fab86b3..98dbb216ea2bd145546f07279859c62f8d84899b 100644 (file)
@@ -794,7 +794,7 @@ datenoyearrev    = day ([ -.])* monthtext;
 datenocolon      = year4 monthlz daylz;
 
 /* Special formats */
-soap             = year4 "-" monthlz "-" daylz "T" hour24lz ":" minutelz ":" secondlz frac tzcorrection;
+soap             = year4 "-" monthlz "-" daylz "T" hour24lz ":" minutelz ":" secondlz frac tzcorrection?;
 xmlrpc           = year4 monthlz daylz "T" hour24 ":" minutelz ":" secondlz;
 xmlrpcnocolon    = year4 monthlz daylz 't' hour24 minutelz secondlz;
 wddx             = year4 "-" monthlz "-" daylz "T" hour24 ":" minutelz ":" secondlz;
@@ -1157,8 +1157,10 @@ relativetext = reltextnumber space? reltextunit;
                s->time->s = timelib_get_nr((char **) &ptr, 2);
                if (*ptr == '.') {
                        s->time->f = timelib_get_frac_nr((char **) &ptr, 9);
-                       s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
-                       s->errors += tz_not_found;
+                       if (*ptr) { /* timezone is optional */
+                               s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+                               s->errors += tz_not_found;
+                       }
                }
                TIMELIB_DEINIT;
                return TIMELIB_XMLRPC_SOAP;
diff --git a/ext/date/tests/bug35705.phpt b/ext/date/tests/bug35705.phpt
new file mode 100644 (file)
index 0000000..6894160
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #35705 (strtotime() fails to parse soap date format without TZ)
+--FILE--
+<?php
+date_default_timezone_set("UTC");
+
+echo date(DATE_ISO8601, strtotime('2000-10-10T10:12:30.000')) . "\n";
+
+?>
+--EXPECT--
+2000-10-10T10:12:30+0000