Fixed date-time related validation (reported by David Crossley, bug
* xmlschemastypes.c: Fixed date-time related validation
(reported by David Crossley, bug #300576).
diff --git a/ChangeLog b/ChangeLog
index 5e59a30..1f139e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Apr 19 17:51:32 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+ * xmlschemastypes.c: Fixed date-time related validation
+ (reported by David Crossley, bug #300576).
+
Tue Apr 19 16:55:40 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c xmlregexp.c: Removed 5 unnecessary
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index 2b629bd..f4e6a5c 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -1012,14 +1012,17 @@
_xmlSchemaParseGMonth (xmlSchemaValDatePtr dt, const xmlChar **str) {
const xmlChar *cur = *str;
int ret = 0;
+ unsigned int value = 0;
- PARSE_2_DIGITS(dt->mon, cur, ret);
+ PARSE_2_DIGITS(value, cur, ret);
if (ret != 0)
return ret;
- if (!VALID_MONTH(dt->mon))
+ if (!VALID_MONTH(value))
return 2;
+ dt->mon = value;
+
*str = cur;
return 0;
}
@@ -1039,14 +1042,16 @@
_xmlSchemaParseGDay (xmlSchemaValDatePtr dt, const xmlChar **str) {
const xmlChar *cur = *str;
int ret = 0;
+ unsigned int value = 0;
- PARSE_2_DIGITS(dt->day, cur, ret);
+ PARSE_2_DIGITS(value, cur, ret);
if (ret != 0)
return ret;
- if (!VALID_DAY(dt->day))
+ if (!VALID_DAY(value))
return 2;
+ dt->day = value;
*str = cur;
return 0;
}
@@ -1068,21 +1073,26 @@
const xmlChar *cur = *str;
unsigned int hour = 0; /* use temp var in case str is not xs:time */
int ret = 0;
+ unsigned int value = 0;
- PARSE_2_DIGITS(hour, cur, ret);
+ PARSE_2_DIGITS(value, cur, ret);
if (ret != 0)
- return ret;
-
+ return ret;
if (*cur != ':')
return 1;
+ if (!VALID_HOUR(value))
+ return 2;
cur++;
/* the ':' insures this string is xs:time */
- dt->hour = hour;
+ dt->hour = value;
- PARSE_2_DIGITS(dt->min, cur, ret);
+ PARSE_2_DIGITS(value, cur, ret);
if (ret != 0)
return ret;
+ if (!VALID_MIN(value))
+ return 2;
+ dt->min = value;
if (*cur != ':')
return 1;
@@ -1092,7 +1102,7 @@
if (ret != 0)
return ret;
- if (!VALID_TIME(dt))
+ if ((!VALID_SEC(dt->sec)) || (!VALID_TZO(dt->tzo)))
return 2;
*str = cur;