leptris 1.9.331.0 → 1.9.334.0
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/CHANGELOG.md +31 -0
- data/Rakefile +19 -1
- data/lib/leptris/vendor/aarch64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/aarch64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/arm64-darwin/libutf8proc.3.dylib +0 -0
- data/lib/leptris/vendor/ppc64le-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/s390x-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/x86_64-darwin/libutf8proc.3.dylib +0 -0
- data/lib/leptris/vendor/x86_64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/cdata.rb +4 -0
- data/lib/leptris/xml/comment.rb +4 -0
- data/lib/leptris/xml/descriptor.rb +55 -0
- data/lib/leptris/xml/entity_reference.rb +4 -0
- data/lib/leptris/xml/ffi.rb +25 -0
- data/lib/leptris/xml/node.rb +1 -0
- data/lib/leptris/xml/processing_instruction.rb +4 -0
- data/lib/leptris/xml/text.rb +4 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +65 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/include/leptris/descriptor.h +30 -0
- data/vendor-src/libleptris/src/include/leptris.h +5 -0
- data/vendor-src/libleptris/src/leptris/descriptor/plan.c +144 -0
- data/vendor-src/libleptris/src/leptris/dom/element_modify.c +7 -0
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +241 -4
- data/vendor-src/libleptris/src/leptris/xsd/content_model.c +50 -0
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +190 -8
- data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +34 -0
- data/vendor-src/libleptris/test/abi/test_descriptor.cpp +95 -0
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +380 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +2 -2
|
@@ -1119,3 +1119,383 @@ TEST(XsdCompileFile, MissingFileIsNullWithStatus) {
|
|
|
1119
1119
|
}
|
|
1120
1120
|
|
|
1121
1121
|
} // namespace
|
|
1122
|
+
|
|
1123
|
+
// ---- tier 2 (#1075): xs:assert --------------------------------------
|
|
1124
|
+
namespace {
|
|
1125
|
+
|
|
1126
|
+
const char* k_assert_schema =
|
|
1127
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1128
|
+
" version=\"1.1\">"
|
|
1129
|
+
"<xs:complexType name=\"boxT\">"
|
|
1130
|
+
"<xs:sequence>"
|
|
1131
|
+
"<xs:element name=\"item\" type=\"xs:token\" minOccurs=\"0\""
|
|
1132
|
+
" maxOccurs=\"unbounded\"/>"
|
|
1133
|
+
"</xs:sequence>"
|
|
1134
|
+
"<xs:attribute name=\"qty\" type=\"xs:integer\"/>"
|
|
1135
|
+
"<xs:assert test=\"count(item) <= 2\"/>"
|
|
1136
|
+
"</xs:complexType>"
|
|
1137
|
+
"<xs:element name=\"box\" type=\"boxT\"/>"
|
|
1138
|
+
"</xs:schema>";
|
|
1139
|
+
|
|
1140
|
+
TEST(XsdAssert11, ComplexTypeAssertionEnforces) {
|
|
1141
|
+
EXPECT_EQ(validate_doc(k_assert_schema,
|
|
1142
|
+
"<box qty=\"1\"><item>a</item>"
|
|
1143
|
+
"</box>"), 1);
|
|
1144
|
+
EXPECT_EQ(validate_doc(k_assert_schema,
|
|
1145
|
+
"<box qty=\"1\"><item>a</item><item>b</item>"
|
|
1146
|
+
"</box>"), 1);
|
|
1147
|
+
/* the assertion fails at three items */
|
|
1148
|
+
EXPECT_EQ(validate_doc(k_assert_schema,
|
|
1149
|
+
"<box qty=\"1\"><item>a</item><item>b</item>"
|
|
1150
|
+
"<item>c</item></box>"), 0);
|
|
1151
|
+
/* attributes ride the assertion context too */
|
|
1152
|
+
EXPECT_EQ(validate_doc(k_assert_schema,
|
|
1153
|
+
"<box qty=\"9\"><item>a</item>"
|
|
1154
|
+
"<item>b</item><item>c</item></box>"), 0);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
const char* k_assert_attr_schema =
|
|
1158
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1159
|
+
" version=\"1.1\">"
|
|
1160
|
+
"<xs:complexType name=\"pairT\">"
|
|
1161
|
+
"<xs:attribute name=\"lo\" type=\"xs:integer\"/>"
|
|
1162
|
+
"<xs:attribute name=\"hi\" type=\"xs:integer\"/>"
|
|
1163
|
+
"<xs:assert test=\"number(@lo) <= number(@hi)\"/>"
|
|
1164
|
+
"</xs:complexType>"
|
|
1165
|
+
"<xs:element name=\"p\" type=\"pairT\"/>"
|
|
1166
|
+
"</xs:schema>";
|
|
1167
|
+
|
|
1168
|
+
TEST(XsdAssert11, AttributeComparisonAssertion) {
|
|
1169
|
+
EXPECT_EQ(validate_doc(k_assert_attr_schema,
|
|
1170
|
+
"<p lo=\"1\" hi=\"3\"/>"), 1);
|
|
1171
|
+
EXPECT_EQ(validate_doc(k_assert_attr_schema,
|
|
1172
|
+
"<p lo=\"4\" hi=\"3\"/>"), 0);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/* assertions nested under complexContent/extension also bind */
|
|
1176
|
+
TEST(XsdAssert11, ExtensionAssertionEnforces) {
|
|
1177
|
+
const char* x =
|
|
1178
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1179
|
+
" version=\"1.1\">"
|
|
1180
|
+
"<xs:complexType name=\"baseT\">"
|
|
1181
|
+
"<xs:sequence><xs:element name=\"a\" type=\"xs:token\"/>"
|
|
1182
|
+
"</xs:sequence>"
|
|
1183
|
+
"</xs:complexType>"
|
|
1184
|
+
"<xs:complexType name=\"extT\">"
|
|
1185
|
+
"<xs:complexContent>"
|
|
1186
|
+
"<xs:extension base=\"baseT\">"
|
|
1187
|
+
"<xs:sequence><xs:element name=\"b\" type=\"xs:token\"/>"
|
|
1188
|
+
"</xs:sequence>"
|
|
1189
|
+
"<xs:assert test=\"a = b\"/>"
|
|
1190
|
+
"</xs:extension>"
|
|
1191
|
+
"</xs:complexContent>"
|
|
1192
|
+
"</xs:complexType>"
|
|
1193
|
+
"<xs:element name=\"e\" type=\"extT\"/>"
|
|
1194
|
+
"</xs:schema>";
|
|
1195
|
+
EXPECT_EQ(validate_doc(x, "<e><a>t</a><b>t</b></e>"), 1);
|
|
1196
|
+
EXPECT_EQ(validate_doc(x, "<e><a>t</a><b>u</b></e>"), 0);
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/* 1.0-labelled schemas ignore the construct (XSD 1.0 validators
|
|
1200
|
+
* see unknown elements) — no assertion enforcement */
|
|
1201
|
+
TEST(XsdAssert11, Version10IgnoresAssertions) {
|
|
1202
|
+
const char* x =
|
|
1203
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1204
|
+
" version=\"1.0\">"
|
|
1205
|
+
"<xs:complexType name=\"boxT\">"
|
|
1206
|
+
"<xs:sequence>"
|
|
1207
|
+
"<xs:element name=\"item\" type=\"xs:token\" minOccurs=\"0\""
|
|
1208
|
+
" maxOccurs=\"unbounded\"/>"
|
|
1209
|
+
"</xs:sequence>"
|
|
1210
|
+
"<xs:assert test=\"count(item) <= 1\"/>"
|
|
1211
|
+
"</xs:complexType>"
|
|
1212
|
+
"<xs:element name=\"box\" type=\"boxT\"/>"
|
|
1213
|
+
"</xs:schema>";
|
|
1214
|
+
EXPECT_EQ(validate_doc(x,
|
|
1215
|
+
"<box><item>a</item><item>b</item></box>"), 1);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
} // namespace
|
|
1219
|
+
|
|
1220
|
+
// ---- tier 2 (#1075): xs:assertion on simpleTypes -------------------
|
|
1221
|
+
namespace {
|
|
1222
|
+
|
|
1223
|
+
const char* k_sa_schema =
|
|
1224
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1225
|
+
" version=\"1.1\">"
|
|
1226
|
+
"<xs:simpleType name=\"small\">"
|
|
1227
|
+
"<xs:restriction base=\"xs:integer\">"
|
|
1228
|
+
"<xs:assertion test=\"$value < 10\"/>"
|
|
1229
|
+
"</xs:restriction>"
|
|
1230
|
+
"</xs:simpleType>"
|
|
1231
|
+
"<xs:simpleType name=\"word\">"
|
|
1232
|
+
"<xs:restriction base=\"xs:string\">"
|
|
1233
|
+
"<xs:assertion test=\"string-length($value) <= 3\"/>"
|
|
1234
|
+
"</xs:restriction>"
|
|
1235
|
+
"</xs:simpleType>"
|
|
1236
|
+
"<xs:element name=\"n\" type=\"small\"/>"
|
|
1237
|
+
"<xs:element name=\"w\" type=\"word\"/>"
|
|
1238
|
+
"</xs:schema>";
|
|
1239
|
+
|
|
1240
|
+
TEST(XsdAssertion11, SimpleTypeValueAssertions) {
|
|
1241
|
+
EXPECT_EQ(validate_doc(k_sa_schema, "<n>5</n>"), 1);
|
|
1242
|
+
EXPECT_EQ(validate_doc(k_sa_schema, "<n>50</n>"), 0);
|
|
1243
|
+
EXPECT_EQ(validate_doc(k_sa_schema, "<w>abc</w>"), 1);
|
|
1244
|
+
EXPECT_EQ(validate_doc(k_sa_schema, "<w>abcd</w>"), 0);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
} // namespace
|
|
1248
|
+
|
|
1249
|
+
// ---- tier 2 (#1075): open content ----------------------------------
|
|
1250
|
+
namespace {
|
|
1251
|
+
|
|
1252
|
+
const char* k_oc_interleave =
|
|
1253
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1254
|
+
" version=\"1.1\">"
|
|
1255
|
+
"<xs:complexType name=\"tT\">"
|
|
1256
|
+
"<xs:sequence>"
|
|
1257
|
+
"<xs:element name=\"a\" type=\"xs:token\"/>"
|
|
1258
|
+
"<xs:element name=\"b\" type=\"xs:token\"/>"
|
|
1259
|
+
"</xs:sequence>"
|
|
1260
|
+
"<xs:openContent mode=\"interleave\">"
|
|
1261
|
+
"<xs:any namespace=\"##any\" processContents=\"lax\"/>"
|
|
1262
|
+
"</xs:openContent>"
|
|
1263
|
+
"</xs:complexType>"
|
|
1264
|
+
"<xs:element name=\"e\" type=\"tT\"/>"
|
|
1265
|
+
"</xs:schema>";
|
|
1266
|
+
|
|
1267
|
+
TEST(XsdOpenContent11, InterleavedWildcardsBindAnywhere) {
|
|
1268
|
+
/* the plain sequence */
|
|
1269
|
+
EXPECT_EQ(validate_doc(k_oc_interleave,
|
|
1270
|
+
"<e><a>1</a><b>2</b></e>"), 1);
|
|
1271
|
+
/* foreign element before, between, after */
|
|
1272
|
+
EXPECT_EQ(validate_doc(k_oc_interleave,
|
|
1273
|
+
"<e><q/><a>1</a><b>2</b></e>"), 1);
|
|
1274
|
+
EXPECT_EQ(validate_doc(k_oc_interleave,
|
|
1275
|
+
"<e><a>1</a><q/><b>2</b></e>"), 1);
|
|
1276
|
+
EXPECT_EQ(validate_doc(k_oc_interleave,
|
|
1277
|
+
"<e><a>1</a><b>2</b><q/></e>"), 1);
|
|
1278
|
+
/* the sequence itself still enforces order */
|
|
1279
|
+
EXPECT_EQ(validate_doc(k_oc_interleave,
|
|
1280
|
+
"<e><b>2</b><a>1</a></e>"), 0);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
const char* k_oc_suffix =
|
|
1284
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1285
|
+
" version=\"1.1\">"
|
|
1286
|
+
"<xs:complexType name=\"tT\">"
|
|
1287
|
+
"<xs:sequence>"
|
|
1288
|
+
"<xs:element name=\"a\" type=\"xs:token\"/>"
|
|
1289
|
+
"</xs:sequence>"
|
|
1290
|
+
"<xs:openContent mode=\"suffix\">"
|
|
1291
|
+
"<xs:any namespace=\"##any\" processContents=\"lax\"/>"
|
|
1292
|
+
"</xs:openContent>"
|
|
1293
|
+
"</xs:complexType>"
|
|
1294
|
+
"<xs:element name=\"e\" type=\"tT\"/>"
|
|
1295
|
+
"</xs:schema>";
|
|
1296
|
+
|
|
1297
|
+
TEST(XsdOpenContent11, SuffixWildcardsBindOnlyAtTheEnd) {
|
|
1298
|
+
EXPECT_EQ(validate_doc(k_oc_suffix, "<e><a>1</a><q/></e>"), 1);
|
|
1299
|
+
EXPECT_EQ(validate_doc(k_oc_suffix, "<e><a>1</a><q/><r/></e>"), 1);
|
|
1300
|
+
EXPECT_EQ(validate_doc(k_oc_suffix, "<e><q/><a>1</a></e>"), 0);
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
const char* k_oc_default =
|
|
1304
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1305
|
+
" version=\"1.1\">"
|
|
1306
|
+
"<xs:defaultOpenContent mode=\"interleave\">"
|
|
1307
|
+
"<xs:any namespace=\"##any\" processContents=\"lax\"/>"
|
|
1308
|
+
"</xs:defaultOpenContent>"
|
|
1309
|
+
"<xs:complexType name=\"tT\">"
|
|
1310
|
+
"<xs:sequence>"
|
|
1311
|
+
"<xs:element name=\"a\" type=\"xs:token\"/>"
|
|
1312
|
+
"</xs:sequence>"
|
|
1313
|
+
"</xs:complexType>"
|
|
1314
|
+
"<xs:element name=\"e\" type=\"tT\"/>"
|
|
1315
|
+
"</xs:schema>";
|
|
1316
|
+
|
|
1317
|
+
TEST(XsdOpenContent11, DefaultOpenContentApplies) {
|
|
1318
|
+
EXPECT_EQ(validate_doc(k_oc_default, "<e><a>1</a></e>"), 1);
|
|
1319
|
+
EXPECT_EQ(validate_doc(k_oc_default, "<e><a>1</a><q/></e>"), 1);
|
|
1320
|
+
EXPECT_EQ(validate_doc(k_oc_default, "<e><q/><a>1</a></e>"), 1);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
} // namespace
|
|
1324
|
+
|
|
1325
|
+
// ---- tier 2 (#1075): conditional type assignment --------------
|
|
1326
|
+
namespace {
|
|
1327
|
+
|
|
1328
|
+
const char* k_alt_schema =
|
|
1329
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
1330
|
+
" version=\"1.1\">"
|
|
1331
|
+
"<xs:complexType name=\"circleT\">"
|
|
1332
|
+
"<xs:sequence><xs:element name=\"r\" type=\"xs:integer\"/>"
|
|
1333
|
+
"</xs:sequence>"
|
|
1334
|
+
"</xs:complexType>"
|
|
1335
|
+
"<xs:complexType name=\"squareT\">"
|
|
1336
|
+
"<xs:sequence><xs:element name=\"s\" type=\"xs:string\"/>"
|
|
1337
|
+
"</xs:sequence>"
|
|
1338
|
+
"</xs:complexType>"
|
|
1339
|
+
"<xs:complexType name=\"fallbackT\">"
|
|
1340
|
+
"<xs:sequence><xs:element name=\"u\" type=\"xs:token\"/>"
|
|
1341
|
+
"</xs:sequence>"
|
|
1342
|
+
"</xs:complexType>"
|
|
1343
|
+
"<xs:element name=\"shape\" type=\"fallbackT\">"
|
|
1344
|
+
"<xs:alternative test=\"@kind = 'circle'\" type=\"circleT\"/>"
|
|
1345
|
+
"<xs:alternative test=\"@kind = 'square'\" type=\"squareT\"/>"
|
|
1346
|
+
"</xs:element>"
|
|
1347
|
+
"</xs:schema>";
|
|
1348
|
+
|
|
1349
|
+
TEST(XsdAlternative11, FirstMatchingAlternativeTypes) {
|
|
1350
|
+
/* circle alternative */
|
|
1351
|
+
EXPECT_EQ(validate_doc(k_alt_schema,
|
|
1352
|
+
"<shape kind=\"circle\"><r>2</r></shape>"), 1);
|
|
1353
|
+
EXPECT_EQ(validate_doc(k_alt_schema,
|
|
1354
|
+
"<shape kind=\"circle\"><r>x</r></shape>"), 0);
|
|
1355
|
+
/* square alternative */
|
|
1356
|
+
EXPECT_EQ(validate_doc(k_alt_schema,
|
|
1357
|
+
"<shape kind=\"square\"><s>hi</s></shape>"), 1);
|
|
1358
|
+
EXPECT_EQ(validate_doc(k_alt_schema,
|
|
1359
|
+
"<shape kind=\"square\"><r>2</r></shape>"), 0);
|
|
1360
|
+
/* no alternative matches: the declared fallback type applies */
|
|
1361
|
+
EXPECT_EQ(validate_doc(k_alt_schema,
|
|
1362
|
+
"<shape kind=\"blob\"><u>t</u></shape>"), 1);
|
|
1363
|
+
EXPECT_EQ(validate_doc(k_alt_schema,
|
|
1364
|
+
"<shape kind=\"blob\"><r>2</r></shape>"), 0);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
} // namespace
|
|
1368
|
+
|
|
1369
|
+
/* #1615 regression pin: a union combining memberTypes with inline
|
|
1370
|
+
* anonymous members consults BOTH member sets (the issue reported
|
|
1371
|
+
* over-acceptance through a stale binding binary; the engine was
|
|
1372
|
+
* verified correct on main, the tag, and every published gem —
|
|
1373
|
+
* this pins the behavior in CI, binary-independent). */
|
|
1374
|
+
TEST(XsdDatatypes, UnionMixesNamedAndInlineMembers) {
|
|
1375
|
+
const char* x =
|
|
1376
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
|
|
1377
|
+
"<xs:simpleType name=\"intOrAuto\">"
|
|
1378
|
+
"<xs:union memberTypes=\"xs:integer\">"
|
|
1379
|
+
"<xs:simpleType>"
|
|
1380
|
+
"<xs:restriction base=\"xs:token\">"
|
|
1381
|
+
"<xs:enumeration value=\"auto\"/>"
|
|
1382
|
+
"</xs:restriction>"
|
|
1383
|
+
"</xs:simpleType>"
|
|
1384
|
+
"</xs:union>"
|
|
1385
|
+
"</xs:simpleType>"
|
|
1386
|
+
"<xs:element name=\"v\" type=\"intOrAuto\"/>"
|
|
1387
|
+
"</xs:schema>";
|
|
1388
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
1389
|
+
LeptrisXsdSchema s = leptris_xsd_compile(x, strlen(x), &st);
|
|
1390
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
1391
|
+
EXPECT_EQ(leptris_xsd_simple_valid(s, "intOrAuto", "42"), 1);
|
|
1392
|
+
EXPECT_EQ(leptris_xsd_simple_valid(s, "intOrAuto", "auto"), 1);
|
|
1393
|
+
EXPECT_EQ(leptris_xsd_simple_valid(s, "intOrAuto", "zz"), 0);
|
|
1394
|
+
leptris_xsd_free(s);
|
|
1395
|
+
EXPECT_EQ(validate_doc(x, "<v>zz</v>"), 0);
|
|
1396
|
+
EXPECT_EQ(validate_doc(x, "<v>42</v>"), 1);
|
|
1397
|
+
EXPECT_EQ(validate_doc(x, "<v>auto</v>"), 1);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
// ---- completion wave: xs:all order-free semantics ------------------
|
|
1401
|
+
namespace {
|
|
1402
|
+
|
|
1403
|
+
const char* k_all_schema =
|
|
1404
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
|
|
1405
|
+
"<xs:complexType name=\"aT\">"
|
|
1406
|
+
"<xs:all>"
|
|
1407
|
+
"<xs:element name=\"x\" type=\"xs:token\"/>"
|
|
1408
|
+
"<xs:element name=\"y\" type=\"xs:token\" minOccurs=\"0\"/>"
|
|
1409
|
+
"</xs:all>"
|
|
1410
|
+
"</xs:complexType>"
|
|
1411
|
+
"<xs:element name=\"r\" type=\"aT\"/>"
|
|
1412
|
+
"</xs:schema>";
|
|
1413
|
+
|
|
1414
|
+
TEST(XsdContent, AllGroupIsOrderFree) {
|
|
1415
|
+
/* declaration order */
|
|
1416
|
+
EXPECT_EQ(validate_doc(k_all_schema, "<r><x>1</x><y>2</y></r>"), 1);
|
|
1417
|
+
/* reversed order: xs:all is order-free */
|
|
1418
|
+
EXPECT_EQ(validate_doc(k_all_schema, "<r><y>2</y><x>1</x></r>"), 1);
|
|
1419
|
+
/* optional member absent */
|
|
1420
|
+
EXPECT_EQ(validate_doc(k_all_schema, "<r><x>1</x></r>"), 1);
|
|
1421
|
+
/* a member appears twice: at most once in xs:all */
|
|
1422
|
+
EXPECT_EQ(validate_doc(k_all_schema, "<r><x>1</x><x>1</x></r>"), 0);
|
|
1423
|
+
/* required member missing */
|
|
1424
|
+
EXPECT_EQ(validate_doc(k_all_schema, "<r><y>2</y></r>"), 0);
|
|
1425
|
+
/* undeclared child inside xs:all */
|
|
1426
|
+
EXPECT_EQ(validate_doc(k_all_schema, "<r><x>1</x><z/></r>"), 0);
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
} // namespace
|
|
1430
|
+
|
|
1431
|
+
// ---- completion wave: loud unresolved types ------------------------
|
|
1432
|
+
namespace {
|
|
1433
|
+
|
|
1434
|
+
TEST(XsdValidate, UnresolvedTypeIsALoudFailure) {
|
|
1435
|
+
/* the schema references a type that does not exist — the
|
|
1436
|
+
* instance must not silently validate (the #1615 symptom
|
|
1437
|
+
* class: stale engines accepted unresolved types) */
|
|
1438
|
+
const char* x =
|
|
1439
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
|
|
1440
|
+
"<xs:element name=\"v\" type=\"noSuchType\"/>"
|
|
1441
|
+
"</xs:schema>";
|
|
1442
|
+
EXPECT_EQ(validate_doc(x, "<v>anything</v>"), 0);
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
} // namespace
|
|
1446
|
+
|
|
1447
|
+
// ---- completion wave: strict undeclared elements/attributes -------
|
|
1448
|
+
namespace {
|
|
1449
|
+
|
|
1450
|
+
TEST(XsdValidate, UndeclaredElementIsStrict) {
|
|
1451
|
+
const char* x =
|
|
1452
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
|
|
1453
|
+
"<xs:element name=\"r\">"
|
|
1454
|
+
"<xs:complexType><xs:sequence>"
|
|
1455
|
+
"<xs:element name=\"a\" type=\"xs:token\"/>"
|
|
1456
|
+
"</xs:sequence></xs:complexType>"
|
|
1457
|
+
"</xs:element>"
|
|
1458
|
+
"</xs:schema>";
|
|
1459
|
+
EXPECT_EQ(validate_doc(x, "<r><a>1</a></r>"), 1);
|
|
1460
|
+
/* a child the schema never declared */
|
|
1461
|
+
EXPECT_EQ(validate_doc(x, "<r><a>1</a><ghost/></r>"), 0);
|
|
1462
|
+
/* an element outside the sequence */
|
|
1463
|
+
EXPECT_EQ(validate_doc(x, "<r><ghost/><a>1</a></r>"), 0);
|
|
1464
|
+
/* an undeclared ROOT element */
|
|
1465
|
+
EXPECT_EQ(validate_doc(x, "<ghost/>"), 0);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
TEST(XsdValidate, UndeclaredAttributeIsStrictUnlessAnyAttribute) {
|
|
1469
|
+
const char* strict =
|
|
1470
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
|
|
1471
|
+
"<xs:element name=\"r\">"
|
|
1472
|
+
"<xs:complexType><xs:sequence>"
|
|
1473
|
+
"<xs:element name=\"a\" type=\"xs:token\"/>"
|
|
1474
|
+
"</xs:sequence>"
|
|
1475
|
+
"<xs:attribute name=\"id\" type=\"xs:integer\"/>"
|
|
1476
|
+
"</xs:complexType>"
|
|
1477
|
+
"</xs:element>"
|
|
1478
|
+
"</xs:schema>";
|
|
1479
|
+
EXPECT_EQ(validate_doc(strict, "<r id=\"1\"><a>x</a></r>"), 1);
|
|
1480
|
+
/* an attribute the schema never declared */
|
|
1481
|
+
EXPECT_EQ(validate_doc(strict, "<r id=\"1\" note=\"hi\"><a>x</a></r>"),
|
|
1482
|
+
0);
|
|
1483
|
+
|
|
1484
|
+
/* xs:anyAttribute opens the wildcard: undeclared attrs pass */
|
|
1485
|
+
const char* open_attrs =
|
|
1486
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
|
|
1487
|
+
"<xs:element name=\"r\">"
|
|
1488
|
+
"<xs:complexType><xs:sequence>"
|
|
1489
|
+
"<xs:element name=\"a\" type=\"xs:token\"/>"
|
|
1490
|
+
"</xs:sequence>"
|
|
1491
|
+
"<xs:attribute name=\"id\" type=\"xs:integer\"/>"
|
|
1492
|
+
"<xs:anyAttribute namespace=\"##any\" processContents=\"lax\"/>"
|
|
1493
|
+
"</xs:complexType>"
|
|
1494
|
+
"</xs:element>"
|
|
1495
|
+
"</xs:schema>";
|
|
1496
|
+
EXPECT_EQ(validate_doc(open_attrs,
|
|
1497
|
+
"<r id=\"1\" note=\"hi\" tag=\"x\"><a>x</a></r>"),
|
|
1498
|
+
1);
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
} // namespace
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
|
3
3
|
"name": "leptris",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.334",
|
|
5
5
|
"description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
|
|
6
6
|
"homepage": "https://github.com/leptris/leptris",
|
|
7
7
|
"license": "MIT",
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: leptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.334.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|