leptris 1.9.338.0-arm-linux → 1.9.341.0-arm-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/CHANGELOG.md +33 -0
- data/Rakefile +1 -1
- data/ext/leptris/native/native.c +18 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/descriptor.rb +39 -3
- data/lib/leptris/xml/element.rb +18 -7
- data/lib/leptris/xml/ffi.rb +27 -0
- data/lib/leptris/xml/native.so +0 -0
- data/lib/leptris/xml/node.rb +22 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +87 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/include/leptris/descriptor.h +27 -0
- data/vendor-src/libleptris/src/include/leptris.h +12 -0
- data/vendor-src/libleptris/src/leptris/descriptor/plan.c +226 -12
- data/vendor-src/libleptris/src/leptris/dom/element_modify.c +88 -4
- data/vendor-src/libleptris/src/leptris/serialize/serialize.c +38 -0
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +79 -0
- data/vendor-src/libleptris/test/abi/test_descriptor.cpp +120 -0
- data/vendor-src/libleptris/test/dom/test_dom.cpp +193 -0
- data/vendor-src/libleptris/test/serializer/test_serialize.cpp +25 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/a1.xsd +5 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/a2.xsd +4 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/b1.xsd +5 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/b2.xsd +4 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/s.xsd +3 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/w.xsd +5 -0
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +15 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +7 -1
|
@@ -2231,4 +2231,124 @@ TEST(Plan408, AddChildByAddress) {
|
|
|
2231
2231
|
leptris_document_free(doc);
|
|
2232
2232
|
}
|
|
2233
2233
|
|
|
2234
|
+
/* #425: the ext face — indent on element boundaries, compact
|
|
2235
|
+
* default; the 3-arg face stays byte-identical to before. */
|
|
2236
|
+
TEST(Plan425, SerializeExtIndentsBoundaries) {
|
|
2237
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2238
|
+
leptris_element_plan plans[2] = {};
|
|
2239
|
+
plans[0].element_name = "r";
|
|
2240
|
+
plans[1].element_name = "a";
|
|
2241
|
+
|
|
2242
|
+
leptris_child_plan kids[2] = {};
|
|
2243
|
+
kids[0].wire_name = "a";
|
|
2244
|
+
kids[0].kind = LEPTRIS_PLAN_KIND_SCALAR;
|
|
2245
|
+
kids[0].child_plan_index = 1;
|
|
2246
|
+
kids[1].wire_name = "b";
|
|
2247
|
+
kids[1].kind = LEPTRIS_PLAN_KIND_SCALAR;
|
|
2248
|
+
|
|
2249
|
+
plans[0].child_count = 2;
|
|
2250
|
+
plans[0].child_plans = kids;
|
|
2251
|
+
|
|
2252
|
+
leptris_plan_spec spec = {};
|
|
2253
|
+
spec.abi_version = leptris_plan_abi_version();
|
|
2254
|
+
spec.plan_count = 2;
|
|
2255
|
+
spec.plans = plans;
|
|
2256
|
+
LeptrisPlan plan = leptris_plan_build(&spec, &st);
|
|
2257
|
+
ASSERT_NE(plan, nullptr);
|
|
2258
|
+
|
|
2259
|
+
leptris_plan_row_op ops[] = {
|
|
2260
|
+
{LEPTRIS_PLAN_OP_ELEMENT, 0, UINT32_MAX, NULL, NULL, 0},
|
|
2261
|
+
{LEPTRIS_PLAN_OP_SCALAR, 0, 0, NULL, "v1", 2},
|
|
2262
|
+
{LEPTRIS_PLAN_OP_SCALAR, 0, 1, NULL, "v2", 2},
|
|
2263
|
+
{LEPTRIS_PLAN_OP_END, 0, 0, NULL, NULL, 0},
|
|
2264
|
+
};
|
|
2265
|
+
LeptrisPlanResult r = leptris_plan_result_build(plan, ops, 4, &st);
|
|
2266
|
+
ASSERT_NE(r, nullptr);
|
|
2267
|
+
|
|
2268
|
+
/* Compact (default) — unchanged shape. */
|
|
2269
|
+
char* compact = leptris_plan_serialize(plan, r, &st);
|
|
2270
|
+
ASSERT_NE(compact, nullptr);
|
|
2271
|
+
EXPECT_STREQ(compact, "<r><a>v1</a><b>v2</b></r>");
|
|
2272
|
+
|
|
2273
|
+
/* Ext: indent=2 — newline+indent before each child open and
|
|
2274
|
+
* before the root close. */
|
|
2275
|
+
leptris_plan_serialize_options opts = {};
|
|
2276
|
+
opts.indent = 2;
|
|
2277
|
+
char* pretty = leptris_plan_serialize_ext(plan, r, &opts,
|
|
2278
|
+
sizeof(opts), &st);
|
|
2279
|
+
ASSERT_NE(pretty, nullptr);
|
|
2280
|
+
EXPECT_STREQ(pretty,
|
|
2281
|
+
"<r>\n <a>v1</a>\n <b>v2</b>\n</r>\n");
|
|
2282
|
+
|
|
2283
|
+
/* Ext with a shorter opts_size than the struct is rejected. */
|
|
2284
|
+
EXPECT_EQ(leptris_plan_serialize_ext(plan, r, &opts, 1, &st),
|
|
2285
|
+
nullptr);
|
|
2286
|
+
|
|
2287
|
+
leptris_free_string(compact);
|
|
2288
|
+
leptris_free_string(pretty);
|
|
2289
|
+
leptris_plan_result_free(r);
|
|
2290
|
+
leptris_plan_free(plan);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
/* #426: build_result -> native document -> the document writer,
|
|
2294
|
+
* with no string round trip. */
|
|
2295
|
+
TEST(Plan426, FromPlanResultMintsNativeDocument) {
|
|
2296
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2297
|
+
leptris_element_plan plans[2] = {};
|
|
2298
|
+
plans[0].element_name = "r";
|
|
2299
|
+
plans[1].element_name = "a";
|
|
2300
|
+
|
|
2301
|
+
leptris_child_plan kids[2] = {};
|
|
2302
|
+
kids[0].wire_name = "a";
|
|
2303
|
+
kids[0].kind = LEPTRIS_PLAN_KIND_SCALAR;
|
|
2304
|
+
kids[0].child_plan_index = 1;
|
|
2305
|
+
kids[1].wire_name = "b";
|
|
2306
|
+
kids[1].kind = LEPTRIS_PLAN_KIND_SCALAR;
|
|
2307
|
+
|
|
2308
|
+
plans[0].child_count = 2;
|
|
2309
|
+
plans[0].child_plans = kids;
|
|
2310
|
+
|
|
2311
|
+
leptris_plan_spec spec = {};
|
|
2312
|
+
spec.abi_version = leptris_plan_abi_version();
|
|
2313
|
+
spec.plan_count = 2;
|
|
2314
|
+
spec.plans = plans;
|
|
2315
|
+
LeptrisPlan plan = leptris_plan_build(&spec, &st);
|
|
2316
|
+
ASSERT_NE(plan, nullptr);
|
|
2317
|
+
|
|
2318
|
+
leptris_plan_row_op ops[] = {
|
|
2319
|
+
{LEPTRIS_PLAN_OP_ELEMENT, 0, UINT32_MAX, NULL, NULL, 0},
|
|
2320
|
+
{LEPTRIS_PLAN_OP_ATTR, 0, 0, "k", "1", 1},
|
|
2321
|
+
{LEPTRIS_PLAN_OP_SCALAR, 0, 0, NULL, "v1", 2},
|
|
2322
|
+
{LEPTRIS_PLAN_OP_SCALAR, 0, 1, NULL, "v2", 2},
|
|
2323
|
+
{LEPTRIS_PLAN_OP_END, 0, 0, NULL, NULL, 0},
|
|
2324
|
+
};
|
|
2325
|
+
LeptrisPlanResult r = leptris_plan_result_build(plan, ops, 5, &st);
|
|
2326
|
+
ASSERT_NE(r, nullptr);
|
|
2327
|
+
|
|
2328
|
+
LeptrisDocument doc = leptris_document_from_plan_result(plan, r, &st);
|
|
2329
|
+
ASSERT_NE(doc, nullptr);
|
|
2330
|
+
LeptrisElement root = leptris_document_root(doc);
|
|
2331
|
+
ASSERT_NE(root, nullptr);
|
|
2332
|
+
EXPECT_STREQ(leptris_element_name(root), "r");
|
|
2333
|
+
EXPECT_STREQ(leptris_element_attribute(root, "k"), "1");
|
|
2334
|
+
EXPECT_EQ(leptris_element_child_count(root), 2u);
|
|
2335
|
+
LeptrisElement first = leptris_element_first_child_any(root);
|
|
2336
|
+
ASSERT_NE(first, nullptr);
|
|
2337
|
+
EXPECT_STREQ(leptris_element_name(first), "a");
|
|
2338
|
+
EXPECT_STREQ(leptris_element_text(first), "v1");
|
|
2339
|
+
|
|
2340
|
+
/* Non-ELEMENT roots are rejected. */
|
|
2341
|
+
leptris_plan_row_op scalar_ops[] = {
|
|
2342
|
+
{LEPTRIS_PLAN_OP_SCALAR, 0, 0, NULL, "x", 1}};
|
|
2343
|
+
LeptrisPlanResult scalar_root =
|
|
2344
|
+
leptris_plan_result_build(plan, scalar_ops, 1, &st);
|
|
2345
|
+
EXPECT_EQ(leptris_document_from_plan_result(plan, scalar_root, &st),
|
|
2346
|
+
nullptr);
|
|
2347
|
+
|
|
2348
|
+
leptris_plan_result_free(scalar_root);
|
|
2349
|
+
leptris_plan_result_free(r);
|
|
2350
|
+
leptris_plan_free(plan);
|
|
2351
|
+
leptris_document_free(doc);
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2234
2354
|
} // namespace
|
|
@@ -2843,3 +2843,196 @@ TEST(ElementNewWithAttributes, DuplicateNamesReplaceLastWins) {
|
|
|
2843
2843
|
EXPECT_STREQ(leptris_element_attribute(e, "id"), "second");
|
|
2844
2844
|
leptris_document_free(doc);
|
|
2845
2845
|
}
|
|
2846
|
+
|
|
2847
|
+
/* #1636: appending a node into its own descendant subtree built a
|
|
2848
|
+
* parent cycle; the serializer (every tree walker) then recursed
|
|
2849
|
+
* unbounded and the process died (_chkstk SEGV on Windows through
|
|
2850
|
+
* moxml fragment merges). Reparenting mutators reject the cycle
|
|
2851
|
+
* edge now. */
|
|
2852
|
+
TEST(DomCycleGuard, AncestorAppendRejected) {
|
|
2853
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2854
|
+
LeptrisDocument d =
|
|
2855
|
+
leptris_parse_string("<a><b/></a>", strlen("<a><b/></a>"), &st);
|
|
2856
|
+
ASSERT_NE(d, nullptr);
|
|
2857
|
+
LeptrisElement a = leptris_document_root(d);
|
|
2858
|
+
LeptrisElement b = leptris_element_first_child_any(a);
|
|
2859
|
+
ASSERT_NE(b, nullptr);
|
|
2860
|
+
EXPECT_EQ(leptris_element_append_child(b, a),
|
|
2861
|
+
LEPTRIS_ERROR_INVALID_ARG);
|
|
2862
|
+
EXPECT_EQ(leptris_element_prepend_child(b, a),
|
|
2863
|
+
LEPTRIS_ERROR_INVALID_ARG);
|
|
2864
|
+
EXPECT_EQ(leptris_element_append_child(a, a),
|
|
2865
|
+
LEPTRIS_ERROR_INVALID_ARG);
|
|
2866
|
+
/* the legal shape still works and serializes */
|
|
2867
|
+
LeptrisElement c = leptris_element_create(d, "c");
|
|
2868
|
+
ASSERT_NE(c, nullptr);
|
|
2869
|
+
EXPECT_EQ(leptris_element_append_child(b, c), LEPTRIS_OK);
|
|
2870
|
+
char* out = leptris_document_serialize(d, nullptr);
|
|
2871
|
+
ASSERT_NE(out, nullptr);
|
|
2872
|
+
EXPECT_NE(strstr(out, "<b><c/></b>"), nullptr);
|
|
2873
|
+
leptris_free_string(out);
|
|
2874
|
+
leptris_document_free(d);
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2877
|
+
TEST(DomCycleGuard, InsertIntoOwnSubtreeRejected) {
|
|
2878
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2879
|
+
LeptrisDocument d =
|
|
2880
|
+
leptris_parse_string("<a><b><x/></b></a>", strlen("<a><b><x/></b></a>"), &st);
|
|
2881
|
+
ASSERT_NE(d, nullptr);
|
|
2882
|
+
LeptrisElement a = leptris_document_root(d);
|
|
2883
|
+
LeptrisElement b = leptris_element_first_child_any(a);
|
|
2884
|
+
LeptrisElement x = leptris_element_first_child_any(b);
|
|
2885
|
+
ASSERT_NE(x, nullptr);
|
|
2886
|
+
/* inserting a (ancestor) inside a's own subtree */
|
|
2887
|
+
EXPECT_EQ(leptris_element_insert_before(x, a),
|
|
2888
|
+
LEPTRIS_ERROR_INVALID_ARG);
|
|
2889
|
+
EXPECT_EQ(leptris_element_insert_after(x, a),
|
|
2890
|
+
LEPTRIS_ERROR_INVALID_ARG);
|
|
2891
|
+
leptris_document_free(d);
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
/* leptris-ruby#1636: add_child_addr is status-only — a foreign
|
|
2895
|
+
* node is adopted by copy and the installed copy's address is
|
|
2896
|
+
* dropped, so callers kept addressing the foreign original, which
|
|
2897
|
+
* dies with its document. The installed twin reports the
|
|
2898
|
+
* effective node: same-document attaches return the argument,
|
|
2899
|
+
* foreign attaches return the copy (which survives the source
|
|
2900
|
+
* document's free). */
|
|
2901
|
+
TEST(DomAttachInstalled, ForeignAttachReportsCopyAddress) {
|
|
2902
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2903
|
+
LeptrisDocument frag =
|
|
2904
|
+
leptris_parse_string("<f><item>t</item></f>", strlen("<f><item>t</item></f>"), &st);
|
|
2905
|
+
ASSERT_NE(frag, nullptr);
|
|
2906
|
+
LeptrisDocument target = leptris_parse_string("<doc/>", 6, &st);
|
|
2907
|
+
ASSERT_NE(target, nullptr);
|
|
2908
|
+
LeptrisElement troot = leptris_document_root(target);
|
|
2909
|
+
LeptrisElement froot = leptris_document_root(frag);
|
|
2910
|
+
LeptrisElement item = leptris_element_first_child_any(froot);
|
|
2911
|
+
ASSERT_NE(item, nullptr);
|
|
2912
|
+
|
|
2913
|
+
uintptr_t installed = 0;
|
|
2914
|
+
EXPECT_EQ(leptris_element_add_child_addr_installed(
|
|
2915
|
+
(uintptr_t)troot, (uintptr_t)item, &installed),
|
|
2916
|
+
LEPTRIS_OK);
|
|
2917
|
+
EXPECT_NE(installed, 0u);
|
|
2918
|
+
/* the copy is a different node than the foreign original */
|
|
2919
|
+
EXPECT_NE(installed, (uintptr_t)item);
|
|
2920
|
+
|
|
2921
|
+
/* the source document dies; the installed copy must not dangle */
|
|
2922
|
+
leptris_document_free(frag);
|
|
2923
|
+
char* out = leptris_element_serialize(troot, nullptr);
|
|
2924
|
+
ASSERT_NE(out, nullptr);
|
|
2925
|
+
EXPECT_STREQ(out, "<doc><item>t</item></doc>");
|
|
2926
|
+
leptris_free_string(out);
|
|
2927
|
+
leptris_document_free(target);
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
TEST(DomAttachInstalled, SameDocumentReturnsArgument) {
|
|
2931
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2932
|
+
LeptrisDocument d = leptris_parse_string("<r/>", 4, &st);
|
|
2933
|
+
ASSERT_NE(d, nullptr);
|
|
2934
|
+
LeptrisElement root = leptris_document_root(d);
|
|
2935
|
+
LeptrisElement c = leptris_element_create(d, "c");
|
|
2936
|
+
ASSERT_NE(c, nullptr);
|
|
2937
|
+
uintptr_t installed = 0;
|
|
2938
|
+
EXPECT_EQ(leptris_element_add_child_addr_installed(
|
|
2939
|
+
(uintptr_t)root, (uintptr_t)c, &installed),
|
|
2940
|
+
LEPTRIS_OK);
|
|
2941
|
+
EXPECT_EQ(installed, (uintptr_t)c);
|
|
2942
|
+
leptris_document_free(d);
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
TEST(DomAttachInstalled, NullShapeAndStatusContract) {
|
|
2946
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2947
|
+
LeptrisDocument d = leptris_parse_string("<r/>", 4, &st);
|
|
2948
|
+
ASSERT_NE(d, nullptr);
|
|
2949
|
+
LeptrisElement root = leptris_document_root(d);
|
|
2950
|
+
LeptrisElement c = leptris_element_create(d, "c");
|
|
2951
|
+
ASSERT_NE(c, nullptr);
|
|
2952
|
+
/* status-only overload */
|
|
2953
|
+
EXPECT_EQ(leptris_element_add_child_addr_installed(
|
|
2954
|
+
(uintptr_t)root, (uintptr_t)c, NULL),
|
|
2955
|
+
LEPTRIS_OK);
|
|
2956
|
+
/* NULL-shaped errors */
|
|
2957
|
+
EXPECT_EQ(leptris_element_add_child_addr_installed(
|
|
2958
|
+
0, (uintptr_t)c, NULL),
|
|
2959
|
+
LEPTRIS_ERROR_NULL_ARG);
|
|
2960
|
+
leptris_document_free(d);
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
namespace {
|
|
2964
|
+
/* leptris#1646: reads every element's name, text, attribute names, and
|
|
2965
|
+
* expanded-QName prefix/URI views — the pool-backed views suspected of
|
|
2966
|
+
* dangling once the source document is freed. NULL text is legal; views
|
|
2967
|
+
* must be readable, not necessarily non-empty. */
|
|
2968
|
+
void ReadAllViews(LeptrisElement e) {
|
|
2969
|
+
const char* name = leptris_element_name(e);
|
|
2970
|
+
ASSERT_NE(name, nullptr);
|
|
2971
|
+
if (const char* text = leptris_element_text(e)) (void)strlen(text);
|
|
2972
|
+
const char* px = nullptr;
|
|
2973
|
+
const char* uri = nullptr;
|
|
2974
|
+
leptris_element_expanded_name(e, nullptr, &px, &uri);
|
|
2975
|
+
if (px) (void)strlen(px);
|
|
2976
|
+
if (uri) (void)strlen(uri);
|
|
2977
|
+
for (LeptrisAttribute a = leptris_element_first_attribute(e); a;
|
|
2978
|
+
a = leptris_attribute_next(a)) {
|
|
2979
|
+
const char* an = leptris_attribute_get_name(a);
|
|
2980
|
+
ASSERT_NE(an, nullptr);
|
|
2981
|
+
}
|
|
2982
|
+
for (LeptrisNodeRef c = leptris_node_first_child(leptris_element_as_node(e)); c;
|
|
2983
|
+
c = leptris_node_next_sibling(c)) {
|
|
2984
|
+
if (leptris_node_get_type(c) == LEPTRIS_NODE_TYPE_ELEMENT)
|
|
2985
|
+
ReadAllViews((LeptrisElement)c);
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
} // namespace
|
|
2989
|
+
|
|
2990
|
+
/* leptris#1646 — the two attach shapes whose survival the issue asked to
|
|
2991
|
+
* pin at the C level: (A) absorb-move, where dst's document absorbs src's
|
|
2992
|
+
* pool and the source document is then freed; (B) plain cross-document
|
|
2993
|
+
* append, which adopts by copy. In both, everything reachable from dst
|
|
2994
|
+
* must remain readable and serializable after leptris_document_free(src). */
|
|
2995
|
+
TEST(DomAbsorbSurvival, AbsorbedChildrenSurviveSourceFree) {
|
|
2996
|
+
static const char kSrc[] = "<w><a id=\"k1\" xmlns:p=\"urn:p\"><b>p:t</b><c>deep text</c></a></w>";
|
|
2997
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2998
|
+
LeptrisDocument dst = leptris_parse_string("<r/>", strlen("<r/>"), &st);
|
|
2999
|
+
ASSERT_NE(dst, nullptr);
|
|
3000
|
+
LeptrisDocument src = leptris_parse_string(kSrc, strlen(kSrc), &st);
|
|
3001
|
+
ASSERT_NE(src, nullptr);
|
|
3002
|
+
LeptrisElement droot = leptris_document_root(dst);
|
|
3003
|
+
LeptrisElement sroot = leptris_document_root(src);
|
|
3004
|
+
ASSERT_EQ(leptris_document_absorb(dst, src), LEPTRIS_OK);
|
|
3005
|
+
LeptrisNodeRef moved = leptris_node_first_child(leptris_element_as_node(sroot));
|
|
3006
|
+
ASSERT_NE(moved, nullptr);
|
|
3007
|
+
EXPECT_EQ(leptris_element_append_child(droot, (LeptrisElement)moved), LEPTRIS_OK);
|
|
3008
|
+
|
|
3009
|
+
leptris_document_free(src);
|
|
3010
|
+
char* out = leptris_document_serialize(dst, nullptr);
|
|
3011
|
+
ASSERT_NE(out, nullptr);
|
|
3012
|
+
EXPECT_STREQ(out, "<r><a xmlns:p=\"urn:p\" id=\"k1\"><b>p:t</b><c>deep text</c></a></r>");
|
|
3013
|
+
leptris_free_string(out);
|
|
3014
|
+
ReadAllViews(droot);
|
|
3015
|
+
leptris_document_free(dst);
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
TEST(DomAbsorbSurvival, CopyAttachSurvivesSourceFree) {
|
|
3019
|
+
static const char kSrc[] = "<w><a id=\"k1\" xmlns:p=\"urn:p\"><b>p:t</b><c>deep text</c></a></w>";
|
|
3020
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
3021
|
+
LeptrisDocument dst = leptris_parse_string("<r/>", strlen("<r/>"), &st);
|
|
3022
|
+
ASSERT_NE(dst, nullptr);
|
|
3023
|
+
LeptrisDocument src = leptris_parse_string(kSrc, strlen(kSrc), &st);
|
|
3024
|
+
ASSERT_NE(src, nullptr);
|
|
3025
|
+
LeptrisElement droot = leptris_document_root(dst);
|
|
3026
|
+
LeptrisElement sroot = leptris_document_root(src);
|
|
3027
|
+
LeptrisNodeRef orig = leptris_node_first_child(leptris_element_as_node(sroot));
|
|
3028
|
+
ASSERT_NE(orig, nullptr);
|
|
3029
|
+
EXPECT_EQ(leptris_element_append_child(droot, (LeptrisElement)orig), LEPTRIS_OK);
|
|
3030
|
+
|
|
3031
|
+
leptris_document_free(src);
|
|
3032
|
+
char* out = leptris_document_serialize(dst, nullptr);
|
|
3033
|
+
ASSERT_NE(out, nullptr);
|
|
3034
|
+
EXPECT_STREQ(out, "<r><a xmlns:p=\"urn:p\" id=\"k1\"><b>p:t</b><c>deep text</c></a></r>");
|
|
3035
|
+
leptris_free_string(out);
|
|
3036
|
+
ReadAllViews(droot);
|
|
3037
|
+
leptris_document_free(dst);
|
|
3038
|
+
}
|
|
@@ -802,6 +802,31 @@ TEST(SerializeOptions, IndentHtmlNestsBlockChildren) {
|
|
|
802
802
|
leptris_document_free(doc);
|
|
803
803
|
}
|
|
804
804
|
|
|
805
|
+
/* Issue #1647: the LAST block child of its parent must nest like
|
|
806
|
+
* any other — the pending-indent flush at close-parent has to fire
|
|
807
|
+
* for the trailing block (a following sibling used to mask it). */
|
|
808
|
+
TEST(SerializeOptions, IndentHtmlNestsLastBlockChild) {
|
|
809
|
+
const char xml[] = "<html><head><title>T</title></head><body>"
|
|
810
|
+
"<div id=\"a\"><p>x</p><span>y</span></div></body></html>";
|
|
811
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
812
|
+
LeptrisDocument doc = leptris_parse_string(xml, std::strlen(xml), &st);
|
|
813
|
+
ASSERT_NE(doc, nullptr);
|
|
814
|
+
char* s = html_force_serialize(doc, 2, 1, 0);
|
|
815
|
+
ASSERT_NE(s, nullptr);
|
|
816
|
+
EXPECT_EQ(std::string(s),
|
|
817
|
+
"<html>\n"
|
|
818
|
+
" <head><title>T</title></head>\n"
|
|
819
|
+
" <body>\n"
|
|
820
|
+
" <div id=\"a\">\n"
|
|
821
|
+
" <p>x</p>\n"
|
|
822
|
+
" <span>y</span>\n"
|
|
823
|
+
" </div>\n"
|
|
824
|
+
" </body>\n"
|
|
825
|
+
"</html>");
|
|
826
|
+
leptris_free_string(s);
|
|
827
|
+
leptris_document_free(doc);
|
|
828
|
+
}
|
|
829
|
+
|
|
805
830
|
TEST(SerializeOptions, IndentHtmlLegacyStaysNewlineOnly) {
|
|
806
831
|
const char xml[] = "<html><body><div><p>one</p><p>two</p></div>"
|
|
807
832
|
"</body></html>";
|
|
@@ -152,6 +152,21 @@ TEST(Libxml2Corpus, EveryFixtureCompilesOrFailsCleanly) {
|
|
|
152
152
|
|
|
153
153
|
} // namespace
|
|
154
154
|
|
|
155
|
+
// leptris#1644: a dense include/import DAG must capture each schema
|
|
156
|
+
// unit exactly once. Without a visited set, every path through the
|
|
157
|
+
// DAG re-parses and re-captures the whole subtree (the dml-main
|
|
158
|
+
// blowup: multi-GB / minutes at include_depth 16). Unique captures
|
|
159
|
+
// here: 6 element declarations + 8 include markers = 14;
|
|
160
|
+
// path-enumerated capture reports 21 (a2/b2 twice, s four times).
|
|
161
|
+
TEST(XsdCompile, ImportDagCapturesEachUnitOnce) {
|
|
162
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
163
|
+
LeptrisXsdSchema s = leptris_xsd_compile_file(
|
|
164
|
+
LEPTRIS_XSD_CASES_DIR "/import_dag/w.xsd", &st);
|
|
165
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0) << "status " << (int)st;
|
|
166
|
+
EXPECT_EQ(leptris_xsd_declaration_count(s), 14u);
|
|
167
|
+
leptris_xsd_free(s);
|
|
168
|
+
}
|
|
169
|
+
|
|
155
170
|
// ---- slice 2: lexical validation ----------------------------------
|
|
156
171
|
namespace {
|
|
157
172
|
|
|
@@ -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.341",
|
|
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,7 +1,7 @@
|
|
|
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.341.0
|
|
5
5
|
platform: arm-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -1324,6 +1324,12 @@ files:
|
|
|
1324
1324
|
- vendor-src/libleptris/test/xsd/libxml2-cases/import2_0.imp
|
|
1325
1325
|
- vendor-src/libleptris/test/xsd/libxml2-cases/import2_0.xml
|
|
1326
1326
|
- vendor-src/libleptris/test/xsd/libxml2-cases/import2_0.xsd
|
|
1327
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/a1.xsd
|
|
1328
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/a2.xsd
|
|
1329
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/b1.xsd
|
|
1330
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/b2.xsd
|
|
1331
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/s.xsd
|
|
1332
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/import_dag/w.xsd
|
|
1327
1333
|
- vendor-src/libleptris/test/xsd/libxml2-cases/include1_0.inc
|
|
1328
1334
|
- vendor-src/libleptris/test/xsd/libxml2-cases/include1_0.xml
|
|
1329
1335
|
- vendor-src/libleptris/test/xsd/libxml2-cases/include1_0.xsd
|