• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 966b0f21c15de0c959f4db88d658ba66bda41575 Mon Sep 17 00:00:00 2001
2From: Damjan Jovanovic <damjan.jov@gmail.com>
3Date: Thu, 19 Aug 2021 02:46:32 +0200
4Subject: [PATCH] Add whitespace folding for some atomic data types that it's
5 missing on.
6
7XSD validation fails when some atomic types contain surrounding whitespace
8even though XML Schema Part 2: Datatypes Second Edition, section 4.3.6
9says they should be collapsed. Fix this.
10
11(I am not sure whether the test is correct.)
12
13Issue: #278
14
15Conflict:NA
16Reference:https://gitlab.gnome.org/GNOME/libxml2/-/commit/966b0f21c15de0c959f4db88d658ba66bda41575
17
18---
19 test/xsdtest/xsdtest.xml | 5 +++++
20 xmlschemastypes.c        | 8 ++++++++
21 2 files changed, 13 insertions(+)
22
23diff --git a/test/xsdtest/xsdtest.xml b/test/xsdtest/xsdtest.xml
24index b8a6de9..2807d26 100644
25--- a/test/xsdtest/xsdtest.xml
26+++ b/test/xsdtest/xsdtest.xml
27@@ -657,6 +657,7 @@ B EEF </value>
28 </datatype>
29 <datatype name="byte">
30 <valid>1</valid>
31+<valid> 1 </valid>
32 <valid>127</valid>
33 <valid>-128</valid>
34 <invalid>128</invalid>
35@@ -665,6 +666,7 @@ B EEF </value>
36 <datatype name="unsignedLong">
37 <valid>1</valid>
38 <valid>+1</valid>
39+<valid> 1 </valid>
40 <invalid>-1</invalid>
41 <valid>0</valid>
42 <valid>18446744073709551615</valid>
43@@ -674,6 +676,7 @@ B EEF </value>
44 <datatype name="unsignedInt">
45 <valid>1</valid>
46 <valid>+1</valid>
47+<valid> 1 </valid>
48 <valid>0</valid>
49 <valid>4294967295</valid>
50 <invalid>4294967296</invalid>
51@@ -682,6 +685,7 @@ B EEF </value>
52 <datatype name="unsignedShort">
53 <valid>1</valid>
54 <valid>+1</valid>
55+<valid> 1 </valid>
56 <valid>0</valid>
57 <valid>65535</valid>
58 <invalid>65536</invalid>
59@@ -689,6 +693,7 @@ B EEF </value>
60 </datatype>
61 <datatype name="unsignedByte">
62 <valid>1</valid>
63+<valid> 1 </valid>
64 <valid>+1</valid>
65 <valid>0</valid>
66 <valid>255</valid>
67diff --git a/xmlschemastypes.c b/xmlschemastypes.c
68index af31be5..ebb0219 100644
69--- a/xmlschemastypes.c
70+++ b/xmlschemastypes.c
71@@ -3308,6 +3308,8 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
72
73                 if (cur == NULL)
74                     goto return1;
75+		if (normOnTheFly)
76+		    while IS_WSP_BLANK_CH(*cur) cur++;
77                 if (*cur == '-') {
78                     sign = 1;
79                     cur++;
80@@ -3316,6 +3318,8 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
81                 ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi);
82                 if (ret < 0)
83                     goto return1;
84+		if (normOnTheFly)
85+		    while IS_WSP_BLANK_CH(*cur) cur++;
86                 if (*cur != 0)
87                     goto return1;
88                 if (type->builtInType == XML_SCHEMAS_LONG) {
89@@ -3380,9 +3384,13 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
90
91                 if (cur == NULL)
92                     goto return1;
93+		if (normOnTheFly)
94+		    while IS_WSP_BLANK_CH(*cur) cur++;
95                 ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi);
96                 if (ret < 0)
97                     goto return1;
98+		if (normOnTheFly)
99+		    while IS_WSP_BLANK_CH(*cur) cur++;
100                 if (*cur != 0)
101                     goto return1;
102                 if (type->builtInType == XML_SCHEMAS_ULONG) {
103--
1042.27.0
105
106