1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2026-10-24 01:09:01 +03:00
Brett Kail
2026-08-07 10:06:52 +02:00
committed by Daniel Garcia Moreno
parent ddcb79dc99
commit d67a71d9de
6 changed files with 135 additions and 2 deletions

View File

@@ -0,0 +1 @@
./test/schemas/date-whitespace_0.xml validates

View File

@@ -0,0 +1,31 @@
./test/schemas/date-whitespace_1.xml:3: Schemas validity error : Element 'date': '2000 -01-01' is not a valid value of the atomic type 'xs:date'.
./test/schemas/date-whitespace_1.xml:4: Schemas validity error : Element 'date': '2000-01 -01' is not a valid value of the atomic type 'xs:date'.
./test/schemas/date-whitespace_1.xml:5: Schemas validity error : Element 'date': '2000-01-01 Z' is not a valid value of the atomic type 'xs:date'.
./test/schemas/date-whitespace_1.xml:6: Schemas validity error : Element 'date': '2000-01-01+99:00 ' is not a valid value of the atomic type 'xs:date'.
./test/schemas/date-whitespace_1.xml:7: Schemas validity error : Element 'dateTime': '2000 -01-01T00:00:00' is not a valid value of the atomic type 'xs:dateTime'.
./test/schemas/date-whitespace_1.xml:8: Schemas validity error : Element 'dateTime': '2000-01 -01T00:00:00' is not a valid value of the atomic type 'xs:dateTime'.
./test/schemas/date-whitespace_1.xml:9: Schemas validity error : Element 'dateTime': '2000-01-01 T00:00:00' is not a valid value of the atomic type 'xs:dateTime'.
./test/schemas/date-whitespace_1.xml:10: Schemas validity error : Element 'dateTime': '2000-01-01T00 :00:00' is not a valid value of the atomic type 'xs:dateTime'.
./test/schemas/date-whitespace_1.xml:11: Schemas validity error : Element 'dateTime': '2000-01-01T00:00 :00' is not a valid value of the atomic type 'xs:dateTime'.
./test/schemas/date-whitespace_1.xml:12: Schemas validity error : Element 'dateTime': '2000-01-01T00:00:00 Z' is not a valid value of the atomic type 'xs:dateTime'.
./test/schemas/date-whitespace_1.xml:13: Schemas validity error : Element 'dateTime': '2000-01-01T00:00:00+99:00 ' is not a valid value of the atomic type 'xs:dateTime'.
./test/schemas/date-whitespace_1.xml:14: Schemas validity error : Element 'time': '00 :00:00' is not a valid value of the atomic type 'xs:time'.
./test/schemas/date-whitespace_1.xml:15: Schemas validity error : Element 'time': '00:00 :00' is not a valid value of the atomic type 'xs:time'.
./test/schemas/date-whitespace_1.xml:16: Schemas validity error : Element 'time': '00:00:00 Z' is not a valid value of the atomic type 'xs:time'.
./test/schemas/date-whitespace_1.xml:17: Schemas validity error : Element 'gYear': '2000 Z' is not a valid value of the atomic type 'xs:gYear'.
./test/schemas/date-whitespace_1.xml:18: Schemas validity error : Element 'gYearMonth': '2000 -01' is not a valid value of the atomic type 'xs:gYearMonth'.
./test/schemas/date-whitespace_1.xml:19: Schemas validity error : Element 'gYearMonth': '2000-01 Z' is not a valid value of the atomic type 'xs:gYearMonth'.
./test/schemas/date-whitespace_1.xml:20: Schemas validity error : Element 'gMonth': '--01 Z' is not a valid value of the atomic type 'xs:gMonth'.
./test/schemas/date-whitespace_1.xml:21: Schemas validity error : Element 'gMonthDay': '--01 -01' is not a valid value of the atomic type 'xs:gMonthDay'.
./test/schemas/date-whitespace_1.xml:22: Schemas validity error : Element 'gMonthDay': '--01-01 Z' is not a valid value of the atomic type 'xs:gMonthDay'.
./test/schemas/date-whitespace_1.xml:23: Schemas validity error : Element 'gDay': '---01 Z' is not a valid value of the atomic type 'xs:gDay'.
./test/schemas/date-whitespace_1.xml:24: Schemas validity error : Element 'duration': 'P 1Y' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml:25: Schemas validity error : Element 'duration': 'P1 Y' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml:26: Schemas validity error : Element 'duration': 'P1Y 1M1DT1H1M1S' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml:27: Schemas validity error : Element 'duration': 'P1Y1M 1DT1H1M1S' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml:28: Schemas validity error : Element 'duration': 'P1Y1M1D T1H1M1S' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml:29: Schemas validity error : Element 'duration': 'P1Y1M1DT 1H1M1S' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml:30: Schemas validity error : Element 'duration': 'P1Y1M1DT1 H1M1S' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml:31: Schemas validity error : Element 'duration': 'P1Y1M1DT1H 1M1S' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml:32: Schemas validity error : Element 'duration': 'P1Y1M1DT1H1M 1S' is not a valid value of the atomic type 'xs:duration'.
./test/schemas/date-whitespace_1.xml fails to validate

View File

@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<test>
<date> 2000-01-01</date>
<date>2000-01-01 </date>
<date>2000-01-01Z </date>
<dateTime> 2000-01-01T00:00:00</dateTime>
<dateTime>2000-01-01T00:00:00 </dateTime>
<dateTime>2000-01-01T00:00:00Z </dateTime>
<time> 00:00:00</time>
<time>00:00:00 </time>
<time>00:00:00Z </time>
<gYear> 2000</gYear>
<gYear>2000 </gYear>
<gYear>2000Z </gYear>
<gYearMonth> 2000-01</gYearMonth>
<gYearMonth>2000-01 </gYearMonth>
<gYearMonth>2000-01Z </gYearMonth>
<gMonth> --01</gMonth>
<gMonth>--01 </gMonth>
<gMonth>--01Z </gMonth>
<gMonthDay> --01-01</gMonthDay>
<gMonthDay>--01-01 </gMonthDay>
<gMonthDay>--01-01Z </gMonthDay>
<gDay> ---01</gDay>
<gDay>---01 </gDay>
<gDay>---01Z </gDay>
<duration> P1Y</duration>
<duration>P1Y </duration>
</test>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="test">
<xsd:complexType>
<xsd:sequence>
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="date" type="xsd:date"/>
<xsd:element name="dateTime" type="xsd:dateTime"/>
<xsd:element name="time" type="xsd:time"/>
<xsd:element name="gYear" type="xsd:gYear"/>
<xsd:element name="gYearMonth" type="xsd:gYearMonth"/>
<xsd:element name="gMonth" type="xsd:gMonth"/>
<xsd:element name="gMonthDay" type="xsd:gMonthDay"/>
<xsd:element name="gDay" type="xsd:gDay"/>
<xsd:element name="duration" type="xsd:duration"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<test>
<date>2000 -01-01</date>
<date>2000-01 -01</date>
<date>2000-01-01 Z</date>
<date>2000-01-01+99:00 </date> <!-- invalid timezone -->
<dateTime>2000 -01-01T00:00:00</dateTime>
<dateTime>2000-01 -01T00:00:00</dateTime>
<dateTime>2000-01-01 T00:00:00</dateTime>
<dateTime>2000-01-01T00 :00:00</dateTime>
<dateTime>2000-01-01T00:00 :00</dateTime>
<dateTime>2000-01-01T00:00:00 Z</dateTime>
<dateTime>2000-01-01T00:00:00+99:00 </dateTime> <!-- invalid timezone -->
<time>00 :00:00</time>
<time>00:00 :00</time>
<time>00:00:00 Z</time>
<gYear>2000 Z</gYear>
<gYearMonth>2000 -01</gYearMonth>
<gYearMonth>2000-01 Z</gYearMonth>
<gMonth>--01 Z</gMonth>
<gMonthDay>--01 -01</gMonthDay>
<gMonthDay>--01-01 Z</gMonthDay>
<gDay>---01 Z</gDay>
<duration>P 1Y</duration>
<duration>P1 Y</duration>
<duration>P1Y 1M1DT1H1M1S</duration>
<duration>P1Y1M 1DT1H1M1S</duration>
<duration>P1Y1M1D T1H1M1S</duration>
<duration>P1Y1M1DT 1H1M1S</duration>
<duration>P1Y1M1DT1 H1M1S</duration>
<duration>P1Y1M1DT1H 1M1S</duration>
<duration>P1Y1M1DT1H1M 1S</duration>
</test>

View File

@@ -1781,16 +1781,25 @@ xmlSchemaValidateDates (xmlSchemaValType type,
xmlSchemaValPtr dt;
int ret;
const xmlChar *cur = dateTime;
const xmlChar *start;
#define RETURN_TYPE_IF_VALID(t) \
if (IS_TZO_CHAR(*cur)) { \
ret = _xmlSchemaParseTimeZone(&(dt->value.date), &cur); \
if (ret == 0) { \
if (collapse) \
while IS_WSP_BLANK_CH(*cur) cur++; \
if (*cur != 0) \
goto error; \
dt->type = t; \
goto done; \
} \
} else if (collapse && IS_WSP_BLANK_CH(*cur)) { \
while IS_WSP_BLANK_CH(*cur) cur++; \
if (*cur != 0) \
goto error; \
dt->type = t; \
goto done; \
}
if (dateTime == NULL)
@@ -1799,6 +1808,8 @@ xmlSchemaValidateDates (xmlSchemaValType type,
if (collapse)
while IS_WSP_BLANK_CH(*cur) cur++;
start = cur;
if ((*cur != '-') && (*cur < '0') && (*cur > '9'))
return 1;
@@ -1889,7 +1900,7 @@ xmlSchemaValidateDates (xmlSchemaValType type,
}
/* fallback on date parsing */
cur = dateTime;
cur = start;
ret = _xmlSchemaParseGYear(&(dt->value.date), &cur);
if (ret != 0)
@@ -1929,7 +1940,8 @@ xmlSchemaValidateDates (xmlSchemaValType type,
if (ret != 0)
goto error;
ret = _xmlSchemaParseTimeZone(&(dt->value.date), &cur);
if (IS_TZO_CHAR(*cur))
ret = _xmlSchemaParseTimeZone(&(dt->value.date), &cur);
if (collapse)
while IS_WSP_BLANK_CH(*cur) cur++;
if ((ret != 0) || (*cur != 0) || (!(VALID_DATETIME((&(dt->value.date))))))
@@ -2035,6 +2047,13 @@ xmlSchemaValidateDuration (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
int has_frac = 0;
const xmlChar desig[] = {'Y', 'M', 'D', 'H', 'M', 'S'};
if (collapse && IS_WSP_BLANK_CH(*cur)) {
while IS_WSP_BLANK_CH(*cur) cur++;
if (*cur != 0)
goto error;
break;
}
/* input string should be empty or invalid date/time item */
if (seq >= sizeof(desig))
goto error;