leptris 1.9.338.0-ppc64le-linux → 1.9.340.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/CHANGELOG.md +22 -0
- data/Rakefile +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/ffi.rb +7 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +38 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/include/leptris.h +12 -0
- data/vendor-src/libleptris/src/leptris/dom/element_modify.c +88 -4
- data/vendor-src/libleptris/test/dom/test_dom.cpp +116 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e2e093eb60877bd54bb6e5486da00c113e0a80c62f514e14e1cee2c32637a1c
|
|
4
|
+
data.tar.gz: 6ba4619eefd150a18557df67966bf65dac6b780dcb257c7de8ee13ba81b87060
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7415abeed53efd82a102aabd09ad65a97b3b6315d14ea6ade754858a6d35a2c8c6664066f4f27a2c69f2e839e4ffcd697e957e48b5a808db7fda26c283276d29
|
|
7
|
+
data.tar.gz: 8bd40ef5f310e845d436f92c7fcf788f301af5c017564732d4665f0b5e962da82f839a3dcf5d7fdc8140ac82dbcd2a7662a9c1652f39c3a0ab51332800c8abc4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [1.9.340.0] - 2026-10-11
|
|
2
|
+
|
|
3
|
+
### Added — engine sync (libleptris 1.9.338-1.9.340)
|
|
4
|
+
|
|
5
|
+
- **`leptris_element_add_child_addr_installed` (1.9.340)**: the
|
|
6
|
+
addr-attach twin returning the EFFECTIVE installed address — a
|
|
7
|
+
foreign node adopted by copy (#1528) reports the copy's address,
|
|
8
|
+
which callers must use for every later handle (the dangling-
|
|
9
|
+
wrapper mechanism behind the Windows `fast_element_xml`
|
|
10
|
+
segfault). Audit 385/384.
|
|
11
|
+
|
|
12
|
+
### Fixed — engine sync
|
|
13
|
+
|
|
14
|
+
- 1.9.339: cycle-creating reparents rejected (#1636) — appending
|
|
15
|
+
a node into its own descendant subtree built parent cycles that
|
|
16
|
+
unbounded the serializer's recursion.
|
|
17
|
+
- 1.9.338: in-body drops table-structure start tags (#1634);
|
|
18
|
+
indent_html ext option (#1635).
|
|
19
|
+
|
|
20
|
+
Note: the #425/#426 plan faces (engine PR #1645, merged) were cut
|
|
21
|
+
AFTER the v1.9.340 tag — they ride the next engine release.
|
|
22
|
+
|
|
1
23
|
## [1.9.337.0] - 2026-10-11
|
|
2
24
|
|
|
3
25
|
### Added — engine sync (libleptris 1.9.337)
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
8
8
|
# Pin for `rake compile` and the platform-gem builds. Keep in lockstep
|
|
9
9
|
# with .github/workflows/build.yml (which calls `rake compile`) and the
|
|
10
10
|
# CHANGELOG when libleptris releases.
|
|
11
|
-
LIBLEPTRIS_VERSION = "1.9.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.340"
|
|
12
12
|
# Vendored alongside libleptris for fn:normalize-unicode (TODO
|
|
13
13
|
# .restructure/20): built per platform with a RELOCATABLE @rpath
|
|
14
14
|
# install name, loaded by ffi.rb before libleptris so the
|
data/lib/leptris/version.rb
CHANGED
data/lib/leptris/xml/ffi.rb
CHANGED
|
@@ -888,6 +888,13 @@ attach_function :leptris_parse_string,
|
|
|
888
888
|
# semantics and status contract as the pointer face.
|
|
889
889
|
attach_function :leptris_element_add_child_addr,
|
|
890
890
|
[:ulong_long, :ulong_long], :leptris_status
|
|
891
|
+
# #1636: the addr-attach twin returning the EFFECTIVE
|
|
892
|
+
# installed child address — a foreign node is adopted by
|
|
893
|
+
# copy (#1528) and the caller must use the copy's address
|
|
894
|
+
# for every later handle. installed may be NULL
|
|
895
|
+
# (status-only).
|
|
896
|
+
attach_function :leptris_element_add_child_addr_installed,
|
|
897
|
+
[:ulong_long, :ulong_long, :pointer], :leptris_status
|
|
891
898
|
# Fused create+append (libleptris 1.9.153): one document
|
|
892
899
|
# resolution, identical tree semantics to the two-call pair.
|
|
893
900
|
attach_function :leptris_element_create_child,
|
data/lib/libleptris.so
CHANGED
|
Binary file
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.340] - 2026-10-11
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`leptris_element_add_child_addr_installed` — the add_child_addr
|
|
8
|
+
twin reporting the effective installed address (leptris-ruby#1636,
|
|
9
|
+
PR #1642).** `add_child_addr` is status-only: a foreign node is
|
|
10
|
+
adopted by copy (#1528) and the installed copy's address is
|
|
11
|
+
dropped, so callers kept addressing the foreign original — which
|
|
12
|
+
dies with its document (the dangling-wrapper mechanism behind the
|
|
13
|
+
Windows `fast_element_xml` segfault). The twin returns the
|
|
14
|
+
effective node: same-document attaches return the argument
|
|
15
|
+
unchanged (zero extra cost), foreign attaches return the copy the
|
|
16
|
+
caller must rebase its wrapper to. `installed_addr = NULL` is the
|
|
17
|
+
status-only form; the status contract is identical to
|
|
18
|
+
`add_child_addr`, and the #1639 cycle rejection rides the append.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.9.339] - 2026-10-11
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **reject cycle-creating reparents (#1636, PR #1640).** The
|
|
27
|
+
Windows `fast_element_xml` CFUNC segfault in leptris 1.9.33x:
|
|
28
|
+
mutation could append a node into its own descendant subtree,
|
|
29
|
+
building a parent cycle — any serialize then recursed without
|
|
30
|
+
bound and the process died (the `_chkstk` signature in the
|
|
31
|
+
metanorma-standoc dump is the stack probe hitting the exhausted
|
|
32
|
+
stack; reproduced deterministically under ASAN). All four
|
|
33
|
+
reparenting mutators — `append_child`, `prepend_child`,
|
|
34
|
+
`insert_before`, `insert_after`, and `add_child_addr` through
|
|
35
|
+
the append contract — now reject the cycle edge with
|
|
36
|
+
`LEPTRIS_ERROR_INVALID_ARG`. Legal appends are byte-identical
|
|
37
|
+
(spec-pinned).
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
3
41
|
## [1.9.338] - 2026-10-11
|
|
4
42
|
|
|
5
43
|
### Added
|
|
@@ -2158,6 +2158,18 @@ LEPTRIS_API LeptrisStatus leptris_element_set_name(LeptrisElement elem, const ch
|
|
|
2158
2158
|
* status contract as leptris_element_append_child. */
|
|
2159
2159
|
LEPTRIS_API LeptrisStatus leptris_element_add_child_addr(uintptr_t parent_addr,
|
|
2160
2160
|
uintptr_t child_addr);
|
|
2161
|
+
|
|
2162
|
+
/* #1636: add_child_addr twin returning the EFFECTIVE installed
|
|
2163
|
+
* child address. A same-document attach installs the argument —
|
|
2164
|
+
* installed_addr receives it unchanged; a foreign node is adopted
|
|
2165
|
+
* by copy (#1528) and installed_addr receives the copy's address,
|
|
2166
|
+
* which the caller must use for every later handle. installed_addr
|
|
2167
|
+
* may be NULL (status-only). Same status contract as
|
|
2168
|
+
* add_child_addr.
|
|
2169
|
+
* Memory: the installed node is owned by parent's document. */
|
|
2170
|
+
LEPTRIS_API LeptrisStatus leptris_element_add_child_addr_installed(
|
|
2171
|
+
uintptr_t parent_addr, uintptr_t child_addr,
|
|
2172
|
+
uintptr_t* installed_addr);
|
|
2161
2173
|
LEPTRIS_API LeptrisStatus leptris_element_append_child(LeptrisElement parent, LeptrisElement child);
|
|
2162
2174
|
|
|
2163
2175
|
/**
|
|
@@ -500,9 +500,60 @@ LeptrisStatus leptris_element_add_child_addr(uintptr_t parent_addr,
|
|
|
500
500
|
(LeptrisElement)child_addr);
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
+
LeptrisStatus leptris_element_add_child_addr_installed(
|
|
504
|
+
uintptr_t parent_addr, uintptr_t child_addr,
|
|
505
|
+
uintptr_t* installed_addr) {
|
|
506
|
+
if (!parent_addr || !child_addr) return LEPTRIS_ERROR_NULL_ARG;
|
|
507
|
+
if (installed_addr) *installed_addr = child_addr;
|
|
508
|
+
|
|
509
|
+
/* The same-document fast path installs the argument itself;
|
|
510
|
+
* the foreign gate deep-copies (#1528) and the status-only
|
|
511
|
+
* face drops the copy's address — callers kept addressing the
|
|
512
|
+
* foreign original, which dies with its document (#1636).
|
|
513
|
+
* This face always reports the effective node. */
|
|
514
|
+
LeptrisElement original = (LeptrisElement)child_addr;
|
|
515
|
+
if (leptris_element_get_document(original) ==
|
|
516
|
+
leptris_element_get_document((LeptrisElement)parent_addr)) {
|
|
517
|
+
return leptris_element_append_child(
|
|
518
|
+
(LeptrisElement)parent_addr, original);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
LeptrisElement installed =
|
|
522
|
+
(LeptrisElement)adopt_for_splice((LeptrisNode*)original,
|
|
523
|
+
leptris_element_get_document(
|
|
524
|
+
(LeptrisElement)parent_addr));
|
|
525
|
+
if (!installed) return LEPTRIS_ERROR_MEMORY;
|
|
526
|
+
|
|
527
|
+
/* Cycle rejection rides the append; report the copy. */
|
|
528
|
+
LeptrisStatus rc = leptris_element_append_child(
|
|
529
|
+
(LeptrisElement)parent_addr, installed);
|
|
530
|
+
if (rc != LEPTRIS_OK) return rc;
|
|
531
|
+
if (installed_addr) *installed_addr = (uintptr_t)installed;
|
|
532
|
+
return LEPTRIS_OK;
|
|
533
|
+
}
|
|
534
|
+
|
|
503
535
|
LeptrisStatus leptris_element_append_child(LeptrisElement parent, LeptrisElement child) {
|
|
504
536
|
if (!parent || !child) return LEPTRIS_ERROR_NULL_ARG;
|
|
505
537
|
|
|
538
|
+
/* #1636: appending a node into its own descendant subtree
|
|
539
|
+
* builds a parent cycle — every tree walker (serializer
|
|
540
|
+
* first) then recurses without bound and the process dies
|
|
541
|
+
* (_chkstk SEGV on Windows). Parse-built trees cannot cycle
|
|
542
|
+
* (the open stack is a stack); only mutation can. Reject the
|
|
543
|
+
* ancestor edge: walk child's parent chain for parent. The
|
|
544
|
+
* same-document fast path below never sees foreign copies as
|
|
545
|
+
* ancestors, so the walk runs on the caller's node — O(depth),
|
|
546
|
+
* depth bounded by the parse cap. */
|
|
547
|
+
{
|
|
548
|
+
if (parent == child) return LEPTRIS_ERROR_INVALID_ARG;
|
|
549
|
+
LeptrisElement p = leptris_element_parent(parent);
|
|
550
|
+
int guard = 0;
|
|
551
|
+
while (p && guard++ < 8192) {
|
|
552
|
+
if (p == child) return LEPTRIS_ERROR_INVALID_ARG;
|
|
553
|
+
p = leptris_element_parent(p);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
506
557
|
/* Single document resolution per mutation (TODO 195c): the
|
|
507
558
|
* root walk + map lookup was paid three times per append
|
|
508
559
|
* (twice here, once inside the internal for the tail cache). */
|
|
@@ -542,6 +593,13 @@ LeptrisStatus leptris_element_append_child(LeptrisElement parent, LeptrisElement
|
|
|
542
593
|
LeptrisStatus leptris_element_prepend_child(LeptrisElement parent, LeptrisElement child) {
|
|
543
594
|
if (!parent || !child) return LEPTRIS_ERROR_NULL_ARG;
|
|
544
595
|
|
|
596
|
+
/* #1636: no cycles — see leptris_element_append_child. */
|
|
597
|
+
if (parent == child) return LEPTRIS_ERROR_INVALID_ARG;
|
|
598
|
+
for (LeptrisElement p = leptris_element_parent(parent);
|
|
599
|
+
p; p = leptris_element_parent(p)) {
|
|
600
|
+
if (p == child) return LEPTRIS_ERROR_INVALID_ARG;
|
|
601
|
+
}
|
|
602
|
+
|
|
545
603
|
/* #1528: a foreign document's node is adopted by copy, never
|
|
546
604
|
* spliced raw. */
|
|
547
605
|
child = (LeptrisElement)adopt_for_splice(
|
|
@@ -563,6 +621,19 @@ LeptrisStatus leptris_element_prepend_child(LeptrisElement parent, LeptrisElemen
|
|
|
563
621
|
LeptrisStatus leptris_element_insert_before(LeptrisElement sibling, LeptrisElement new_node) {
|
|
564
622
|
if (!sibling || !new_node) return LEPTRIS_ERROR_NULL_ARG;
|
|
565
623
|
|
|
624
|
+
/* #1636: reparenting a node into its own descendant subtree
|
|
625
|
+
* builds a parent cycle — tree walkers recurse unbounded and
|
|
626
|
+
* the process dies. Reject when the new parent position lies
|
|
627
|
+
* under the node itself. */
|
|
628
|
+
if (((LeptrisNode*)new_node)->type == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
629
|
+
if ((LeptrisElement)sibling == (LeptrisElement)new_node)
|
|
630
|
+
return LEPTRIS_ERROR_INVALID_ARG;
|
|
631
|
+
for (LeptrisElement p = leptris_element_parent(sibling);
|
|
632
|
+
p; p = leptris_element_parent(p)) {
|
|
633
|
+
if (p == (LeptrisElement)new_node)
|
|
634
|
+
return LEPTRIS_ERROR_INVALID_ARG;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
566
637
|
LeptrisNode* new_node_ptr = (LeptrisNode*)new_node;
|
|
567
638
|
LeptrisNode* sibling_ptr = (LeptrisNode*)sibling;
|
|
568
639
|
|
|
@@ -634,7 +705,7 @@ LeptrisStatus leptris_element_insert_before(LeptrisElement sibling, LeptrisEleme
|
|
|
634
705
|
|
|
635
706
|
/* Set parent (type-dispatching). TODO 155 Phase A: document field
|
|
636
707
|
* removed; non-root elements reach doc via walk to root. */
|
|
637
|
-
if (
|
|
708
|
+
if (((LeptrisNode*)new_node)->type == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
638
709
|
leptris_element_set_parent((LeptrisElement)new_node_ptr, parent);
|
|
639
710
|
} else {
|
|
640
711
|
switch (new_node_ptr->type) {
|
|
@@ -660,7 +731,7 @@ LeptrisStatus leptris_element_insert_before(LeptrisElement sibling, LeptrisEleme
|
|
|
660
731
|
|
|
661
732
|
/* Issue #213: maintain child_count for element children only,
|
|
662
733
|
* matching leptris_element_append_child_internal. */
|
|
663
|
-
if (
|
|
734
|
+
if (((LeptrisNode*)new_node)->type == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
664
735
|
parent->child_count++;
|
|
665
736
|
}
|
|
666
737
|
|
|
@@ -676,6 +747,19 @@ LeptrisStatus leptris_element_insert_before(LeptrisElement sibling, LeptrisEleme
|
|
|
676
747
|
LeptrisStatus leptris_element_insert_after(LeptrisElement sibling, LeptrisElement new_node) {
|
|
677
748
|
if (!sibling || !new_node) return LEPTRIS_ERROR_NULL_ARG;
|
|
678
749
|
|
|
750
|
+
/* #1636: reparenting a node into its own descendant subtree
|
|
751
|
+
* builds a parent cycle — tree walkers recurse unbounded and
|
|
752
|
+
* the process dies. Reject when the new parent position lies
|
|
753
|
+
* under the node itself. */
|
|
754
|
+
if (((LeptrisNode*)new_node)->type == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
755
|
+
if ((LeptrisElement)sibling == (LeptrisElement)new_node)
|
|
756
|
+
return LEPTRIS_ERROR_INVALID_ARG;
|
|
757
|
+
for (LeptrisElement p = leptris_element_parent(sibling);
|
|
758
|
+
p; p = leptris_element_parent(p)) {
|
|
759
|
+
if (p == (LeptrisElement)new_node)
|
|
760
|
+
return LEPTRIS_ERROR_INVALID_ARG;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
679
763
|
LeptrisNode* new_node_ptr = (LeptrisNode*)new_node;
|
|
680
764
|
LeptrisNode* sibling_ptr = (LeptrisNode*)sibling;
|
|
681
765
|
|
|
@@ -731,7 +815,7 @@ LeptrisStatus leptris_element_insert_after(LeptrisElement sibling, LeptrisElemen
|
|
|
731
815
|
|
|
732
816
|
/* Set parent (type-dispatching). TODO 155 Phase A: document field
|
|
733
817
|
* removed; non-root elements reach doc via walk to root. */
|
|
734
|
-
if (
|
|
818
|
+
if (((LeptrisNode*)new_node)->type == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
735
819
|
leptris_element_set_parent((LeptrisElement)new_node_ptr, parent);
|
|
736
820
|
} else {
|
|
737
821
|
switch (new_node_ptr->type) {
|
|
@@ -761,7 +845,7 @@ LeptrisStatus leptris_element_insert_after(LeptrisElement sibling, LeptrisElemen
|
|
|
761
845
|
leptris_elem_set_last_child(parent, new_node_ptr);
|
|
762
846
|
}
|
|
763
847
|
|
|
764
|
-
if (
|
|
848
|
+
if (((LeptrisNode*)new_node)->type == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
765
849
|
parent->child_count++;
|
|
766
850
|
}
|
|
767
851
|
|
|
@@ -2843,3 +2843,119 @@ 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
|
+
}
|
|
@@ -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.340",
|
|
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",
|