Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1b113a2

Browse files
author
Thomas G. Lockhart
committed
Change rules for interpreting date/time input to disallow 1 and 3 character
years. Rejects dates like '0.085', which were accepted previously.
1 parent bcd488d commit 1b113a2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/backend/utils/adt/datetime.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.44 2000/03/16 14:36:51 thomas Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.45 2000/03/29 03:57:18 thomas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1367,8 +1367,11 @@ DecodeNumber(int flen, char *str, int fmask,
13671367
* more, but we now test first for a three-digit doy so anything
13681368
* bigger than two digits had better be an explicit year. - thomas
13691369
* 1999-01-09
1370+
* Back to requiring a 4 digit year.
1371+
* We accept a two digit year farther down.
1372+
* - thomas 2000-03-28
13701373
*/
1371-
else if (flen > 2)
1374+
else if (flen >= 4)
13721375
{
13731376
*tmask = DTK_M(YEAR);
13741377

@@ -1382,14 +1385,16 @@ DecodeNumber(int flen, char *str, int fmask,
13821385

13831386
tm->tm_year = val;
13841387
}
1388+
13851389
/* already have year? then could be month */
13861390
else if ((fmask & DTK_M(YEAR)) && (!(fmask & DTK_M(MONTH)))
13871391
&& ((val >= 1) && (val <= 12)))
13881392
{
13891393
*tmask = DTK_M(MONTH);
13901394
tm->tm_mon = val;
1391-
/* no year and EuroDates enabled? then could be day */
1395+
13921396
}
1397+
/* no year and EuroDates enabled? then could be day */
13931398
else if ((EuroDates || (fmask & DTK_M(MONTH)))
13941399
&& (!(fmask & DTK_M(YEAR)) && !(fmask & DTK_M(DAY)))
13951400
&& ((val >= 1) && (val <= 31)))
@@ -1409,7 +1414,11 @@ DecodeNumber(int flen, char *str, int fmask,
14091414
*tmask = DTK_M(DAY);
14101415
tm->tm_mday = val;
14111416
}
1412-
else if (!(fmask & DTK_M(YEAR)))
1417+
/* Check for 2 or 4 or more digits, but currently we reach here
1418+
* only if two digits. - thomas 2000-03-28
1419+
*/
1420+
else if (!(fmask & DTK_M(YEAR))
1421+
&& ((flen >= 4) || (flen == 2)))
14131422
{
14141423
*tmask = DTK_M(YEAR);
14151424
tm->tm_year = val;

0 commit comments

Comments
 (0)