leptris 1.9.401.0-ppc64le-linux → 1.9.403.0-ppc64le-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +43 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/leptris/rng/rng_regex.c +235 -41
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +60 -7
- data/vendor-src/libleptris/src/leptris/xsd/datatypes.c +166 -4
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +90 -14
- data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +1 -1
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +551 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +2 -2
|
@@ -83,7 +83,11 @@ static int unbounded_sign_ok(const char* name, const char* s) {
|
|
|
83
83
|
for (; *d; d++)
|
|
84
84
|
if (*d != '0') { zero_only = 0; break; }
|
|
85
85
|
if (strcmp(name, "xs:integer") == 0) return 1;
|
|
86
|
-
|
|
86
|
+
/* XSD §3.3.20 (leptris-rs#28, errE002): a negative sign is
|
|
87
|
+
* legal where the value is ZERO — "-0" is a valid
|
|
88
|
+
* nonNegativeInteger lexical */
|
|
89
|
+
if (strcmp(name, "xs:nonNegativeInteger") == 0)
|
|
90
|
+
return !neg || zero_only;
|
|
87
91
|
if (strcmp(name, "xs:positiveInteger") == 0)
|
|
88
92
|
return !neg && !zero_only;
|
|
89
93
|
if (strcmp(name, "xs:nonPositiveInteger") == 0)
|
|
@@ -547,14 +551,172 @@ static int facet_check(const XsdSimple* s, const char* v,
|
|
|
547
551
|
free(collapsed);
|
|
548
552
|
return rc;
|
|
549
553
|
}
|
|
554
|
+
|
|
555
|
+
/* ---- temporal enumeration equality (leptris-rs#27) ---------------
|
|
556
|
+
* Enumeration (§4.3.5) is an equality test over the VALUE space:
|
|
557
|
+
* dateTime compares by instant (App. E), and the time/date/gMonth
|
|
558
|
+
* family includes the timezone in the value so only the zero
|
|
559
|
+
* spellings (Z / +00:00 / -00:00) normalize to each other. */
|
|
560
|
+
|
|
561
|
+
/* days from 1970-01-01 (Howard Hinnant's civil algorithm) */
|
|
562
|
+
static double xsd_days_from_civil(long y, unsigned m, unsigned d) {
|
|
563
|
+
y -= m <= 2;
|
|
564
|
+
long era = (y >= 0 ? y : y - 399) / 400;
|
|
565
|
+
unsigned yoe = (unsigned)(y - era * 400);
|
|
566
|
+
unsigned doy = (153u * (m + (m > 2 ? -3u : 9u)) + 2u) / 5u + d - 1u;
|
|
567
|
+
unsigned doe = yoe * 365u + yoe / 4u - yoe / 100u + doy;
|
|
568
|
+
return (double)era * 146097.0 + (double)doe - 719468.0;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/* [-]yyyy-mm-ddThh:mm:ss(.f+)?(Z|(+|-)hh:mm)? -> seconds since the
|
|
572
|
+
* epoch; 0 unless fully parsed (only well-formed lexicals reach
|
|
573
|
+
* the comparison — anything else stays lexical-equal-only). */
|
|
574
|
+
static int xsd_parse_datetime_instant(const char* v, double* out) {
|
|
575
|
+
const char* p = v;
|
|
576
|
+
int neg_year = 0;
|
|
577
|
+
if (*p == '-') {
|
|
578
|
+
neg_year = 1;
|
|
579
|
+
p++;
|
|
580
|
+
}
|
|
581
|
+
long y = 0;
|
|
582
|
+
int got = 0;
|
|
583
|
+
while (*p >= '0' && *p <= '9') {
|
|
584
|
+
y = y * 10 + (*p++ - '0');
|
|
585
|
+
got++;
|
|
586
|
+
}
|
|
587
|
+
if (got < 4) return 0;
|
|
588
|
+
if (*p++ != '-') return 0;
|
|
589
|
+
if (p[0] < '0' || p[0] > '9' || p[1] < '0' || p[1] > '9') return 0;
|
|
590
|
+
int mo = (p[0] - '0') * 10 + (p[1] - '0');
|
|
591
|
+
p += 2;
|
|
592
|
+
if (mo < 1 || mo > 12) return 0;
|
|
593
|
+
if (*p++ != '-') return 0;
|
|
594
|
+
if (p[0] < '0' || p[0] > '9' || p[1] < '0' || p[1] > '9') return 0;
|
|
595
|
+
int da = (p[0] - '0') * 10 + (p[1] - '0');
|
|
596
|
+
p += 2;
|
|
597
|
+
if (da < 1 || da > 31) return 0;
|
|
598
|
+
if (*p != 'T' && *p != ' ') return 0;
|
|
599
|
+
p++;
|
|
600
|
+
if (p[0] < '0' || p[0] > '9' || p[1] < '0' || p[1] > '9') return 0;
|
|
601
|
+
int hh = (p[0] - '0') * 10 + (p[1] - '0');
|
|
602
|
+
p += 2;
|
|
603
|
+
if (hh > 24) return 0;
|
|
604
|
+
if (*p++ != ':') return 0;
|
|
605
|
+
if (p[0] < '0' || p[0] > '9' || p[1] < '0' || p[1] > '9') return 0;
|
|
606
|
+
int mm = (p[0] - '0') * 10 + (p[1] - '0');
|
|
607
|
+
p += 2;
|
|
608
|
+
if (mm > 59) return 0;
|
|
609
|
+
if (*p++ != ':') return 0;
|
|
610
|
+
double ss = 0;
|
|
611
|
+
got = 0;
|
|
612
|
+
while (*p >= '0' && *p <= '9') {
|
|
613
|
+
ss = ss * 10 + (*p++ - '0');
|
|
614
|
+
got++;
|
|
615
|
+
}
|
|
616
|
+
if (!got) return 0;
|
|
617
|
+
if (*p == '.') {
|
|
618
|
+
p++;
|
|
619
|
+
double f = 0.1;
|
|
620
|
+
while (*p >= '0' && *p <= '9') {
|
|
621
|
+
ss += (*p++ - '0') * f;
|
|
622
|
+
f /= 10.0;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
long tzo = 0;
|
|
626
|
+
if (*p == 'Z') {
|
|
627
|
+
p++;
|
|
628
|
+
} else if (*p == '+' || *p == '-') {
|
|
629
|
+
int sign = (*p == '+') ? 1 : -1;
|
|
630
|
+
p++;
|
|
631
|
+
if (p[0] < '0' || p[0] > '9' || p[1] < '0' || p[1] > '9')
|
|
632
|
+
return 0;
|
|
633
|
+
int zh = (p[0] - '0') * 10 + (p[1] - '0');
|
|
634
|
+
p += 2;
|
|
635
|
+
if (*p++ != ':') return 0;
|
|
636
|
+
if (p[0] < '0' || p[0] > '9' || p[1] < '0' || p[1] > '9')
|
|
637
|
+
return 0;
|
|
638
|
+
int zm = (p[0] - '0') * 10 + (p[1] - '0');
|
|
639
|
+
p += 2;
|
|
640
|
+
if (zh > 14 || zm > 59) return 0;
|
|
641
|
+
tzo = sign * (zh * 60 + zm);
|
|
642
|
+
}
|
|
643
|
+
if (*p) return 0;
|
|
644
|
+
if (neg_year) y = -y;
|
|
645
|
+
*out = xsd_days_from_civil(y, (unsigned)mo, (unsigned)da) *
|
|
646
|
+
86400.0 +
|
|
647
|
+
hh * 3600.0 + mm * 60.0 + ss - (double)tzo * 60.0;
|
|
648
|
+
return 1;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
static int xsd_datetime_instant_equal(const char* a, const char* b) {
|
|
652
|
+
double ia = 0, ib = 0;
|
|
653
|
+
if (!xsd_parse_datetime_instant(a, &ia)) return 0;
|
|
654
|
+
if (!xsd_parse_datetime_instant(b, &ib)) return 0;
|
|
655
|
+
return ia == ib;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
static void xsd_normalize_zero_tz(const char* s, char* out, size_t cap) {
|
|
659
|
+
size_t n = strlen(s);
|
|
660
|
+
const char* tail = (n >= 6) ? s + n - 6 : NULL;
|
|
661
|
+
if (tail && (strcmp(tail, "+00:00") == 0 ||
|
|
662
|
+
strcmp(tail, "-00:00") == 0)) {
|
|
663
|
+
if (n - 6 + 1 < cap) {
|
|
664
|
+
memcpy(out, s, n - 6);
|
|
665
|
+
out[n - 6] = 'Z';
|
|
666
|
+
out[n - 5] = 0;
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
snprintf(out, cap, "%s", s);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
static int xsd_tznormalized_equal(const char* a, const char* b) {
|
|
674
|
+
char na[256], nb[256];
|
|
675
|
+
xsd_normalize_zero_tz(a, na, sizeof na);
|
|
676
|
+
xsd_normalize_zero_tz(b, nb, sizeof nb);
|
|
677
|
+
return strcmp(na, nb) == 0;
|
|
678
|
+
}
|
|
679
|
+
|
|
550
680
|
static int facet_check_body(const XsdSimple* s, const char* v,
|
|
551
681
|
const char* terminal_base,
|
|
552
682
|
int chain_is_list) {
|
|
553
|
-
|
|
683
|
+
/* several patterns are a disjunction (p16: same as [abc]+|[123]+) */
|
|
684
|
+
if (s->patterns) {
|
|
685
|
+
int matched = 0;
|
|
686
|
+
for (XsdFacetValue* p = s->patterns; p; p = p->next)
|
|
687
|
+
if (rng_regex_matches(p->text, v)) {
|
|
688
|
+
matched = 1;
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
if (!matched) return 0;
|
|
692
|
+
}
|
|
554
693
|
if (s->enum_values) {
|
|
555
694
|
int found = 0;
|
|
556
|
-
|
|
557
|
-
|
|
695
|
+
int is_dt = terminal_base &&
|
|
696
|
+
strcmp(terminal_base, "xs:dateTime") == 0;
|
|
697
|
+
int is_tzval = terminal_base &&
|
|
698
|
+
(strcmp(terminal_base, "xs:time") == 0 ||
|
|
699
|
+
strcmp(terminal_base, "xs:date") == 0 ||
|
|
700
|
+
strcmp(terminal_base, "xs:gYearMonth") == 0 ||
|
|
701
|
+
strcmp(terminal_base, "xs:gYear") == 0 ||
|
|
702
|
+
strcmp(terminal_base, "xs:gMonthDay") == 0 ||
|
|
703
|
+
strcmp(terminal_base, "xs:gDay") == 0 ||
|
|
704
|
+
strcmp(terminal_base, "xs:gMonth") == 0);
|
|
705
|
+
for (XsdFacetValue* e = s->enum_values; e; e = e->next) {
|
|
706
|
+
if (strcmp(e->text, v) == 0) {
|
|
707
|
+
found = 1;
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
if (!found && is_dt &&
|
|
711
|
+
xsd_datetime_instant_equal(e->text, v)) {
|
|
712
|
+
found = 1;
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
if (!found && is_tzval && xsd_tznormalized_equal(e->text, v)) {
|
|
716
|
+
found = 1;
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
558
720
|
if (!found) return 0;
|
|
559
721
|
}
|
|
560
722
|
/* Length family: character count (string-family semantics) —
|
|
@@ -157,16 +157,25 @@ static int token_family_builtin(const char* t) {
|
|
|
157
157
|
strcmp(t, "xs:NMTOKENS") == 0 ||
|
|
158
158
|
strcmp(t, "xs:ENTITIES") == 0;
|
|
159
159
|
}
|
|
160
|
+
|
|
161
|
+
/* XSD §4.3.6: whiteSpace=collapse is FIXED on every builtin
|
|
162
|
+
* EXCEPT string (preserve) and normalizedString (replace) — the
|
|
163
|
+
* numerics, the temporal family, boolean, the binaries, QName all
|
|
164
|
+
* collapse (leptris-rs#29, elemZ002). */
|
|
165
|
+
static int builtin_collapses(const char* t) {
|
|
166
|
+
return strcmp(t, "xs:string") != 0 &&
|
|
167
|
+
strcmp(t, "xs:normalizedString") != 0;
|
|
168
|
+
}
|
|
160
169
|
static int type_collapses_ws(struct leptris_xsd_schema* s,
|
|
161
170
|
const char* type, const char* ns) {
|
|
162
171
|
if (!type) return 0;
|
|
163
|
-
if (strncmp(type, "xs:", 3) == 0) return
|
|
172
|
+
if (strncmp(type, "xs:", 3) == 0) return builtin_collapses(type);
|
|
164
173
|
const XsdSimple* st = xsd_find_simple_ns_pub(s, type, ns);
|
|
165
174
|
int depth = 0;
|
|
166
175
|
while (st && depth++ < 32) {
|
|
167
176
|
if (!st->base) return 0;
|
|
168
177
|
if (strncmp(st->base, "xs:", 3) == 0)
|
|
169
|
-
return
|
|
178
|
+
return builtin_collapses(st->base);
|
|
170
179
|
st = xsd_find_simple_pub(s, st->base);
|
|
171
180
|
}
|
|
172
181
|
return 0;
|
|
@@ -336,8 +345,24 @@ static void validate_children(struct xsd_validator* v,
|
|
|
336
345
|
LeptrisElement elem, XsdCm* ct) {
|
|
337
346
|
XsdCm* model = ct->first_child;
|
|
338
347
|
/* empty content model: no element children are allowed (the
|
|
339
|
-
* anyAttr-derive2 family accepted whole foreign subtrees here)
|
|
348
|
+
* anyAttr-derive2 family accepted whole foreign subtrees here)
|
|
349
|
+
* and NO character content either — an attributes-only
|
|
350
|
+
* complexType is empty (p2: <elem>abc</elem> [invalid]; the
|
|
351
|
+
* oracle rejects whitespace-only content too, #1691 law) */
|
|
340
352
|
if (!model) {
|
|
353
|
+
/* simpleContent types ride text_type with no particle —
|
|
354
|
+
* their text is validated at the call site */
|
|
355
|
+
if (!ct->text_type) {
|
|
356
|
+
const char* et = leptris_element_text(elem);
|
|
357
|
+
if (et && *et) {
|
|
358
|
+
const char* pn = NULL;
|
|
359
|
+
leptris_element_expanded_name(elem, &pn, NULL, NULL);
|
|
360
|
+
verrf_atk(v, elem, "content-model", pn ? pn : "",
|
|
361
|
+
"element", "#text",
|
|
362
|
+
"character content is not allowed: the "
|
|
363
|
+
"content model is empty");
|
|
364
|
+
}
|
|
365
|
+
}
|
|
341
366
|
for (LeptrisNodeRef c =
|
|
342
367
|
leptris_node_first_child(leptris_element_as_node(elem));
|
|
343
368
|
c; c = leptris_node_next_sibling(c)) {
|
|
@@ -797,13 +822,28 @@ static void validate_element(struct xsd_validator* v,
|
|
|
797
822
|
break;
|
|
798
823
|
}
|
|
799
824
|
}
|
|
800
|
-
|
|
825
|
+
/* #1936 (stE): the element's fixed VALUE constraint applies
|
|
826
|
+
* regardless of the type resolution — inline anonymous types
|
|
827
|
+
* leave eff_type NULL and used to skip the check entirely.
|
|
828
|
+
* XSD 1.0 §3.12.2/§4.3.1.2 (leptris-rs#25, isDefault001): an
|
|
829
|
+
* element with EMPTY content is satisfied BY the fixed value —
|
|
830
|
+
* only non-empty content that differs violates (nine suite
|
|
831
|
+
* rows flipped on the 1.9.402 ride; whitespace-only counts as
|
|
832
|
+
* empty per the §3.3.4 initial reading). */
|
|
801
833
|
if (d->fixed) {
|
|
802
834
|
const char* text = leptris_element_text(elem);
|
|
803
|
-
|
|
835
|
+
int has_content = 0;
|
|
836
|
+
if (text)
|
|
837
|
+
for (const char* q = text; *q; q++)
|
|
838
|
+
if (!isspace((unsigned char)*q)) {
|
|
839
|
+
has_content = 1;
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
if (has_content && strcmp(text, d->fixed) != 0)
|
|
804
843
|
verrfk(v, "content-model", "element", local,
|
|
805
844
|
"content does not match the fixed value");
|
|
806
845
|
}
|
|
846
|
+
if (!eff_type) return; /* anyType */
|
|
807
847
|
/* XSD 1.0 §2.6.2/§3.3.4 (moxml#433): xsi:type on the instance
|
|
808
848
|
* names the type definition this element is assessed against —
|
|
809
849
|
* it replaces the declared type and wins over XSD 1.1
|
|
@@ -851,6 +891,40 @@ static void validate_local_uri(struct xsd_validator* v,
|
|
|
851
891
|
* wp:extent -> a:CT_PositiveSize2D) — resolve through the
|
|
852
892
|
* reference ladder, not the element-ns-strict lookup */
|
|
853
893
|
XsdCm* ct = xsd_find_complex_ref(s, type, euri);
|
|
894
|
+
/* XSD 1.0 §2.7/§3.3.3 (leptris-rs#26, particlesIa002/
|
|
895
|
+
* QFE1700g2): a NILLED element must have neither character nor
|
|
896
|
+
* element content — the content model is not applied (the nil
|
|
897
|
+
* value replaces it; the oracle rejects whitespace too).
|
|
898
|
+
* Attributes are unaffected by nil and still validate. */
|
|
899
|
+
const char* nilattr = leptris_element_attribute_ns(
|
|
900
|
+
elem, "http://www.w3.org/2001/XMLSchema-instance", "nil");
|
|
901
|
+
if (nilattr && strcmp(nilattr, "true") == 0) {
|
|
902
|
+
const char* ntext = leptris_element_text(elem);
|
|
903
|
+
if (ntext && *ntext)
|
|
904
|
+
verrfk(v, "content-model", "element", local,
|
|
905
|
+
"character content is not allowed: the element "
|
|
906
|
+
"is nilled");
|
|
907
|
+
for (LeptrisNodeRef c =
|
|
908
|
+
leptris_node_first_child(leptris_element_as_node(elem));
|
|
909
|
+
c; c = leptris_node_next_sibling(c)) {
|
|
910
|
+
if (leptris_node_get_type(c) != LEPTRIS_NODE_TYPE_ELEMENT)
|
|
911
|
+
continue;
|
|
912
|
+
verrfk(v, "content-model", "element", local,
|
|
913
|
+
"element content is not allowed: the element "
|
|
914
|
+
"is nilled");
|
|
915
|
+
break;
|
|
916
|
+
}
|
|
917
|
+
if (ct) {
|
|
918
|
+
const XsdTypeAttrs* nrows =
|
|
919
|
+
xsd_find_type_attrs_ns(s, type, euri);
|
|
920
|
+
if (!nrows) nrows = xsd_find_type_attrs(s, type);
|
|
921
|
+
validate_attributes(v, s, elem, nrows, ct);
|
|
922
|
+
} else {
|
|
923
|
+
static const XsdTypeAttrs k_no_attrs;
|
|
924
|
+
validate_attributes(v, s, elem, &k_no_attrs, NULL);
|
|
925
|
+
}
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
854
928
|
if (ct) {
|
|
855
929
|
const XsdTypeAttrs* rows =
|
|
856
930
|
xsd_find_type_attrs_ns(s, type, euri);
|
|
@@ -875,10 +949,12 @@ static void validate_local_uri(struct xsd_validator* v,
|
|
|
875
949
|
: "(invalid)");
|
|
876
950
|
}
|
|
877
951
|
if (ct->text_type) {
|
|
952
|
+
/* empty content is still a lexical value — it faces the
|
|
953
|
+
* facets (reG17: '' must fail the pattern) */
|
|
878
954
|
const char* text = leptris_element_text(elem);
|
|
879
|
-
if (text
|
|
880
|
-
|
|
881
|
-
|
|
955
|
+
if (!text) text = "";
|
|
956
|
+
text_valid(v, s, ct->text_type, text, ct->ns,
|
|
957
|
+
"element", local, elem);
|
|
882
958
|
}
|
|
883
959
|
return;
|
|
884
960
|
}
|
|
@@ -899,9 +975,9 @@ static void validate_local_uri(struct xsd_validator* v,
|
|
|
899
975
|
static const XsdTypeAttrs k_no_attrs;
|
|
900
976
|
validate_attributes(v, s, elem, &k_no_attrs, NULL);
|
|
901
977
|
const char* text = leptris_element_text(elem);
|
|
902
|
-
if (text
|
|
903
|
-
|
|
904
|
-
|
|
978
|
+
if (!text) text = "";
|
|
979
|
+
text_valid(v, s, type, text, euri, "element", local,
|
|
980
|
+
elem);
|
|
905
981
|
return;
|
|
906
982
|
}
|
|
907
983
|
/* libxml2-compat (#1691 ns1_0/seq-dubl-elem1): an UNPREFIXED
|
|
@@ -919,9 +995,9 @@ static void validate_local_uri(struct xsd_validator* v,
|
|
|
919
995
|
static const XsdTypeAttrs k_no_attrs;
|
|
920
996
|
validate_attributes(v, s, elem, &k_no_attrs, NULL);
|
|
921
997
|
const char* text = leptris_element_text(elem);
|
|
922
|
-
if (text
|
|
923
|
-
|
|
924
|
-
|
|
998
|
+
if (!text) text = "";
|
|
999
|
+
text_valid(v, s, builtin, text, euri, "element",
|
|
1000
|
+
local, elem);
|
|
925
1001
|
return;
|
|
926
1002
|
}
|
|
927
1003
|
}
|
|
@@ -48,7 +48,7 @@ typedef struct xsd_simple {
|
|
|
48
48
|
size_t member_count;
|
|
49
49
|
struct xsd_simple** member_defs; /* UNION: inline members */
|
|
50
50
|
size_t member_def_count;
|
|
51
|
-
|
|
51
|
+
XsdFacetValue* patterns; /* DISJUNCTION: any pattern may match */
|
|
52
52
|
XsdFacetValue* enum_values;
|
|
53
53
|
size_t enum_count;
|
|
54
54
|
char* min_inclusive;
|