leptris 1.9.355.0-arm-linux → 1.9.359.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.adoc +13 -5
  4. data/Rakefile +1 -1
  5. data/ext/leptris/native/native.c +383 -5
  6. data/lib/leptris/version.rb +1 -1
  7. data/lib/leptris/xml/cdata.rb +3 -0
  8. data/lib/leptris/xml/comment.rb +3 -0
  9. data/lib/leptris/xml/declaration.rb +59 -0
  10. data/lib/leptris/xml/doc_type.rb +33 -1
  11. data/lib/leptris/xml/document.rb +74 -2
  12. data/lib/leptris/xml/element.rb +21 -1
  13. data/lib/leptris/xml/entity_reference.rb +3 -0
  14. data/lib/leptris/xml/native.so +0 -0
  15. data/lib/leptris/xml/node_set.rb +22 -0
  16. data/lib/leptris/xml/processing_instruction.rb +3 -0
  17. data/lib/leptris/xml/sax/parser.rb +102 -78
  18. data/lib/leptris/xml/text.rb +4 -0
  19. data/lib/leptris/xml.rb +14 -0
  20. data/lib/libleptris.so +0 -0
  21. data/scripts/gem_smoke.rb +6 -3
  22. data/vendor-src/README.md +1 -1
  23. data/vendor-src/libleptris/CHANGELOG.md +134 -0
  24. data/vendor-src/libleptris/CMakeLists.txt +1 -1
  25. data/vendor-src/libleptris/TODO.xslt-full/REMAINING.md +37 -18
  26. data/vendor-src/libleptris/cli/commands/validate.c +15 -2
  27. data/vendor-src/libleptris/src/include/leptris.h +60 -4
  28. data/vendor-src/libleptris/src/leptris/dom/element.c +8 -0
  29. data/vendor-src/libleptris/src/leptris/dtd/content_check.c +280 -144
  30. data/vendor-src/libleptris/src/leptris/dtd/parser.c +17 -4
  31. data/vendor-src/libleptris/src/leptris/rng/parse.c +53 -8
  32. data/vendor-src/libleptris/src/leptris/rng/validate.c +63 -21
  33. data/vendor-src/libleptris/src/leptris/xinclude/xinclude.c +304 -12
  34. data/vendor-src/libleptris/src/leptris/xpath/evaluator.c +30 -0
  35. data/vendor-src/libleptris/src/leptris/xpath/evaluator.h +11 -0
  36. data/vendor-src/libleptris/src/leptris/xpath/evaluator_axes.c +3 -3
  37. data/vendor-src/libleptris/src/leptris/xpath/evaluator_path.c +4 -20
  38. data/vendor-src/libleptris/src/leptris/xpath/parser.c +4 -1
  39. data/vendor-src/libleptris/src/leptris/xpath/vm.c +41 -11
  40. data/vendor-src/libleptris/src/leptris/xpath/xpath_compiled.c +4 -3
  41. data/vendor-src/libleptris/src/leptris/xpath/xpath_public.c +2 -1
  42. data/vendor-src/libleptris/src/leptris/xsd/compile.c +981 -38
  43. data/vendor-src/libleptris/src/leptris/xsd/content_model.c +15 -3
  44. data/vendor-src/libleptris/src/leptris/xsd/validate.c +27 -9
  45. data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +1 -0
  46. data/vendor-src/libleptris/test/cli/test_cli.cpp +50 -14
  47. data/vendor-src/libleptris/test/dom/test_dom.cpp +27 -0
  48. data/vendor-src/libleptris/test/dtd/test_dtd_validate.cpp +80 -4
  49. data/vendor-src/libleptris/test/rng/include-cases/attr-text-choice.rng +18 -0
  50. data/vendor-src/libleptris/test/rng/include-cases/dup-inc-mid.rng +7 -0
  51. data/vendor-src/libleptris/test/rng/include-cases/dup-inc-shared.rng +5 -0
  52. data/vendor-src/libleptris/test/rng/include-cases/dup-inc-top.rng +6 -0
  53. data/vendor-src/libleptris/test/rng/test_rng.cpp +101 -0
  54. data/vendor-src/libleptris/test/xinclude/test_xinclude.cpp +261 -0
  55. data/vendor-src/libleptris/test/xpath/test_xpath.cpp +169 -0
  56. data/vendor-src/libleptris/test/xpath/test_xpath_conformance.cpp +8 -1
  57. data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +128 -11
  58. data/vendor-src/libleptris/vcpkg.json +1 -1
  59. metadata +7 -2
@@ -1,5 +1,139 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.359] - 2026-10-15
4
+
5
+ ### Fixed
6
+
7
+ - **xpath: descendant axes from document-node contexts walk the tree**
8
+ (leptris-ruby#458 follow-up, #1728). The VM's relative descendant
9
+ opcodes skipped non-element inputs — a document-typed context (the
10
+ NULL-context default) produced empty results for `.//a` and
11
+ `descendant::a` while `//a` kept working. Document inputs now walk
12
+ the root subtree with include-self (the root element IS a
13
+ descendant of the document, the AST walker's rule).
14
+ - **xpath: the reserved xmlns: prefix resolves to the in-scope
15
+ default namespace** (leptris-ruby#469, #1729). The libxml2/nokogiri
16
+ idiom for default-namespaced documents — `doc.xpath("./xmlns:target")`
17
+ now matches. One helper wired into all seven prefixed name-test
18
+ sites; explicit bindings win first; the innermost prefixless
19
+ declaration wins per context node; unprefixed name tests stay
20
+ spec-strict (XPath 1.0 §2.3, no-namespace only).
21
+
22
+
23
+ ## [1.9.358] - 2026-10-15
24
+
25
+ ### Fixed
26
+
27
+ - **xpath: document-level queries evaluate against the document node**
28
+ (leptris-ruby#458). A NULL context defaulted to the root element in
29
+ all four public eval entry points; libxml2/Nokogiri semantics are
30
+ the document node — `doc.xpath("r/a/@id")` now resolves the root's
31
+ children (was silently empty), and doc-level `*` yields exactly the
32
+ root (was the root's children). `leptris.h` documents NULL = the
33
+ document node.
34
+ - **xpath: the `//` + `*` fast path continues past predicates**
35
+ (leptris-ruby#458). It parsed the star step and predicates then
36
+ returned bare, leaving a following SLASH unconsumed —
37
+ `//*[local-name()='a']/@id` and `//*[@id]/@id` failed to compile
38
+ with "Unexpected token after expression: SLASH". It now runs
39
+ parse_path_continuation, the same shape `(//a)/@id` already used.
40
+ - **dtd: Phase 8 closeout** (#1724). Parameter-entity substitution
41
+ peeks the `<!ELEMENT` / `<!ATTLIST` / `<!NOTATION` keyword before
42
+ consuming (PE-blurred keyword boundary); occurrence capture after
43
+ the balanced-paren scan; nested-group choice parses and backtracks;
44
+ mixed content models `(#PCDATA|a|b)*` validate through the
45
+ rewritten backtracking matcher — `(#PCDATA)` without `*` correctly
46
+ rejects element children.
47
+ - Four Phase-5 ID content-model fixtures corrected from `(a|b)` to
48
+ `(a|b)*` (an ID requires at least one matching child).
49
+
50
+
51
+ ## [1.9.357] - 2026-10-15
52
+
53
+ ### Fixed
54
+
55
+ - **XSD conformance: 898/1056 oracle parity (leptris#1691 closed).**
56
+ Four slices landed: ref-QName declaration resolution across the
57
+ include/import graph — chameleon includes adopt the includer's
58
+ namespace, first import per namespace wins (#1718); UPA —
59
+ choice-branch FIRST overlap and optional/repeating sequence
60
+ adjacency with exact wildcard coverage (#1719); the
61
+ attribute-wildcard family — `##targetNamespace`/`##other` list
62
+ keywords and union normalization (#1723); plus the earlier
63
+ derivation-ok/transitive-include slice (#1716). Floors 839 → 898;
64
+ the only non-converging pair is `length3_0`, an oracle gap
65
+ (libxml2 2.9.13 cannot resolve the spec-valid
66
+ `xs:non-positive-integer`), deliberately not codified.
67
+ - **XInclude: xml:base chains + resolver policy (leptris#1694,
68
+ PR #1719).** Relative hrefs resolve against the nearest xml:base
69
+ ancestor (RFC 3986 merge) and nested includes resolve against the
70
+ INCLUDED document's own directory. `leptris_xinclude_process_opts`
71
+ adds a resolver hook, XML Catalog exact-mapping lookups, and
72
+ `no_network` (default on — remote schemes are resource errors;
73
+ catalogs are consulted first so remote names can localize).
74
+ - **RelaxNG: sound interleave + include merge (leptris#1709,
75
+ PR #1711).** Include merge deep-copies (adoption-by-copy) instead
76
+ of moving shared trees; combine=interleave nested defines keep
77
+ their wrapper; the interleave walk is a consuming fixpoint with a
78
+ zero-width satisfiability pass; attribute choices with a text
79
+ branch validate (BIPM locality/date). Include-merge originals are
80
+ freed (Linux-ASAN leak).
81
+ - **RELAX NG diagnostics: full report in the CLI (leptris#1704).**
82
+ A misplaced element that also carries an invalid attribute reports
83
+ BOTH diagnostics (Jing parity); `validate --rng` prints the whole
84
+ report instead of only the first record.
85
+ - **RELAX NG: bare relative schema filenames resolve includes
86
+ against "." (PR #1720).** A schema filename with no path
87
+ separator made every relative `<include href>` resolve against
88
+ the filename itself and die with a misleading parse error.
89
+ - **CLI: per-test fixture files for the parallel validators**
90
+ (PR #1708) — the ctest -j4 Schematron/RngRound flake.
91
+ - **XSD anyAttribute unions + wildcard list keywords (PR #1723).**
92
+
93
+ ### Test suite
94
+
95
+ - 2030 tests (2026 on v1.9.356), zero-warning builds maintained.
96
+
97
+
98
+ ## [1.9.356] - 2026-10-14
99
+
100
+ ### Fixed
101
+
102
+ - **DOM: type-guard the public first-attribute face
103
+ (leptris#1712, PR #1713).** A wrong-type node handle — a text
104
+ node passed where an element is expected, which duck-typed
105
+ consumers do (svg_conform's NamespaceRemediation probes
106
+ `element?` via `#name`, and the Ruby binding's NativeNode text
107
+ wrapper answers it Nokogiri-compatibly) — decoded the pool word
108
+ at the `element.first_attribute_off` overlay offset. That offset
109
+ sits 4 bytes past a 32-byte text struct: the next pool node's
110
+ type word. A following text node (type == 1) yielded
111
+ `attr == node + 1`, and the first string read on that handle
112
+ segfaulted — deterministically on svg corpora with adjacent
113
+ `<text>` nodes (3.6 MB `fig-a1.svg`: 3064 rects, 170 paths).
114
+ `leptris_element_first_attribute` now answers the empty contract
115
+ (`NULL`) for non-element handles; internal callers keep the
116
+ unchecked inline fast path. Red spec:
117
+ `DomBasics.AttributeFacesRejectNonElementHandles` (parse-carved
118
+ adjacent text nodes reproduce the dangling handle).
119
+ - **RelaxNG: free the include-merge originals (PR #1711
120
+ follow-up).** The define-body deep copy (adoption-by-copy) left
121
+ the included grammar's original pattern trees unreachable but
122
+ unfreed — one 80-byte `RngPattern` tree leaked per merged define
123
+ on every include hop (Linux-ASAN/LSan, `RngInclude.*` aborts).
124
+ The merge now frees the original after the copy, on both the
125
+ success and the failure paths.
126
+
127
+ ### ruby binding (leptris-ruby 1.9.356.0, PR leptris-ruby#453)
128
+
129
+ - Type-guard every native attribute face (`nn_attributes`,
130
+ `nn_attribute`, `nf_fast_attribute2`, `nf_attribute`,
131
+ `nf_bulk_attr_faces`): non-element handles answer the empty
132
+ contract (`{}` / `nil`), matching `nf_attribute_rows`' existing
133
+ check. The svg_conform remediation now completes on the crash
134
+ corpus with byte-identical output to the nokogiri adapter.
135
+
136
+
3
137
  ## [1.9.355] - 2026-10-14
4
138
 
5
139
  ### Fixed
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.355
6
+ VERSION 1.9.359
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -1,9 +1,10 @@
1
1
  # REMAINING — the complete open-work ledger
2
2
 
3
- SSOT for everything still open after v1.9.144 (2026-09-12).
4
- Update entries as work ships; delete entries as they close.
5
- Per-lane details live in the numbered docs; this file is the index
6
- + the graph.
3
+ SSOT for everything still open. REFRESHED 2026-10-15 for v1.9.357:
4
+ the engine issue board is EMPTY (#878-family, #659, #1691, #1694,
5
+ #1704, #1709, #1712 all closed); this file's per-lane statuses were
6
+ re-verified against the shipped state. Per-lane details live in the
7
+ numbered docs; this file is the index + the graph.
7
8
 
8
9
  ## A. In flight — the staged path (2026-09-12)
9
10
 
@@ -93,20 +94,38 @@ ruby/python/c scoreboard. We feed measured numbers only.
93
94
  v1.9.144, the adapter batched-accessor primitive.)
94
95
  - **#930** — CLOSED (v1.9.117).
95
96
 
96
- ## C. TODO.xslt-full lanes — residual items
97
-
98
- - 01/03/04/06/08/09/10 — CLOSED.
99
- - 05 (dates) tail → Stage 2.2. 07 (fn items) tail → Stage 2.3.
100
- - 11/12 (XQuery) tails → Stage 2.1 QT3 subsets via the XTH
101
- connector shape.
102
- - 13 (perf) = #682 (Stage 5). SAX binding-drain residual: retry
103
- quiet-machine best-of-20, else engine-side batched-drain API.
104
- - 14 (HTML) = #659 (Stage 1).
105
- - 15 (binding entries) → Stage 2.4. RelaxNG entries already
106
- shipped (leptris-ruby#165).
107
- - 16 (Schematron 2025): COMPLETE C-side = Stage 3; binding PRs
108
- open (user merges).
109
- - 17 (XML diff): PRs open = Stage 4 (leptris-ruby#171, canon#191).
97
+ ## C. TODO.xslt-full lanes — residual items (2026-10-15 re-verified)
98
+
99
+ - 01/03/04/05/06/07/08/09/10 — CLOSED (fn sequences/regex/math/
100
+ strings/dates/grammar-3x/function-items/maps-arrays/xslt fillins/
101
+ tunnel params all shipped; dates + fn-items verified in
102
+ functions_ext31.c).
103
+ - 11/12 (XQuery) — core surface shipped through v1.9.245+; the
104
+ residual is QT3-suite growth only: the typed-atom lane sits at
105
+ 99 adopted / 2 pins (cbcl-002/002b) and the 5
106
+ duration-canonical survivors are Saxon-verified but may be
107
+ unreachable — measure before grinding.
108
+ - 13 (perf) = #682: ceiling-analyzed (~1.1x in-process max);
109
+ OWNER SCOPE CALL pending — do not grind.
110
+ - 14 (HTML) = #659: CLOSED C-side (fail=0 on the 1753-case corpus,
111
+ 1555 pass / 198 legitimate skips).
112
+ - 15 (binding entries): versioned eval shipped
113
+ (leptris_xpath_eval_versioned, xpath_public.c); result-type
114
+ mirrors live with the binding agents.
115
+ - 16 (Schematron): COMPLETE C-side (IR + SVRL + CLI --phase/--svrl);
116
+ binding wrappers in their repos (dedicated agents).
117
+ - 17 (XML diff): C-side shipped; binding PRs with the user.
118
+ - 18 (compact nodes): superseded by the #1285 compact-pointer
119
+ architecture (elements at ~96 bytes shipped).
120
+
121
+ ## C2. New open work since the last refresh
122
+
123
+ - DTD Phase 8 closeout (PE substitution headless reparse, mixed
124
+ models through %pe;, nested-group choice parse + real
125
+ backtracking) — PR #1724 (in CI).
126
+ - #1717 closed: the churn-crash report was slice-tooling shadowing,
127
+ engine exonerated.
128
+ - Engine issue board: ZERO open issues as of 2026-10-15.
110
129
 
111
130
  ## D. Bindings (user-owned repos — PRs only, never release)
112
131
 
@@ -259,8 +259,21 @@ static cli_result_t validate_execute(int argc, char** argv) {
259
259
  printf("rng: valid\n");
260
260
  } else {
261
261
  printf("rng: invalid\n");
262
- const char* e = leptris_rng_error(rng);
263
- if (e && e[0]) printf(" %s\n", e);
262
+ /* the full report: position AND attribute diagnostics ride
263
+ * separate records (#1704 — Jing reports both) */
264
+ const LeptrisRngErrorRecord* rep = NULL;
265
+ size_t n = leptris_rng_error_report(rng, &rep);
266
+ for (size_t i = 0; i < n; i++) {
267
+ if (rep[i].line > 0)
268
+ printf(" %u:%u: error: %s\n", rep[i].line,
269
+ rep[i].column, rep[i].message);
270
+ else
271
+ printf(" error: %s\n", rep[i].message);
272
+ }
273
+ if (n == 0) {
274
+ const char* e = leptris_rng_error(rng);
275
+ if (e && e[0]) printf(" %s\n", e);
276
+ }
264
277
  invalid = 1;
265
278
  }
266
279
  leptris_rng_free(rng);
@@ -3074,7 +3074,10 @@ LEPTRIS_API const char* leptris_status_string(LeptrisStatus status);
3074
3074
  * Evaluate XPath expression
3075
3075
  *
3076
3076
  * @param doc Document (required)
3077
- * @param context Context element (NULL = document root)
3077
+ * @param context Context element (NULL = the document node —
3078
+ * relative paths then resolve against the document's
3079
+ * children, i.e. the root element matches by name, matching
3080
+ * libxml2/Nokogiri document-level query semantics)
3078
3081
  * @param expression XPath expression string
3079
3082
  * @return XPath result or NULL on error
3080
3083
  *
@@ -3133,7 +3136,7 @@ LEPTRIS_API LeptrisXPathResult leptris_xpath_eval(
3133
3136
  * leptris_xpath_eval).
3134
3137
  *
3135
3138
  * @param doc Document to evaluate against
3136
- * @param context Context element (NULL = document root)
3139
+ * @param context Context element (NULL = the document node)
3137
3140
  * @param expression Expression text
3138
3141
  * @param version LEPTRIS_XPATH_10 or LEPTRIS_XPATH_31
3139
3142
  * @param status Optional status out-param
@@ -3689,7 +3692,7 @@ LEPTRIS_API LeptrisXPathResult leptris_xpath_eval_with_vars(
3689
3692
  * root (e.g. relative paths like ".//item[@id = $x]").
3690
3693
  *
3691
3694
  * @param doc Document
3692
- * @param context Context element (NULL = document root)
3695
+ * @param context Context element (NULL = the document node)
3693
3696
  * @param expression XPath expression
3694
3697
  * @param variables Variable set (may be NULL)
3695
3698
  * @return XPath result (caller frees with leptris_xpath_result_free)
@@ -3771,7 +3774,7 @@ LEPTRIS_API LeptrisXPathNsSet leptris_xpath_ns_set_new_from_pairs(
3771
3774
  * declared it with).
3772
3775
  *
3773
3776
  * @param doc Document
3774
- * @param context Context element (NULL = document root)
3777
+ * @param context Context element (NULL = the document node)
3775
3778
  * @param expression XPath expression
3776
3779
  * @param ns Namespace bindings (may be NULL; then behavior equals
3777
3780
  * leptris_xpath_eval_with_vars_context)
@@ -3946,6 +3949,59 @@ LEPTRIS_API LeptrisStatus leptris_document_set_allocators(
3946
3949
  */
3947
3950
  LEPTRIS_API LeptrisStatus leptris_xinclude_process(LeptrisDocument doc, const char* base_url);
3948
3951
 
3952
+ /**
3953
+ * Resource fetch hook for xi:include (TODO.assemble 04).
3954
+ *
3955
+ * Return 1 and fill out_content/out_len to serve the resource yourself;
3956
+ * the engine takes ownership of the buffer and releases it with
3957
+ * free() — allocate it with malloc() (or an allocator compatible
3958
+ * with it).
3959
+ * Return 0 to fall through to the default file loader. Return -1 to
3960
+ * force a resource error (the xi:fallback applies).
3961
+ *
3962
+ * The uri is the resolved include target (no fragment). It is never a
3963
+ * network scheme while no_network is set (the default).
3964
+ */
3965
+ typedef int (*leptris_xinclude_resolver_fn)(const char* uri, void* user,
3966
+ char** out_content,
3967
+ size_t* out_len);
3968
+
3969
+ /**
3970
+ * Per-call options for XInclude processing (TODO.assemble 03/04).
3971
+ * Zero-initialize for the defaults: no resolver, no catalog,
3972
+ * no_network = 1 (remote schemes refuse with a resource error).
3973
+ *
3974
+ * Memory: the strings and the resolver are borrowed for the duration
3975
+ * of the call; nothing here is freed by the engine.
3976
+ */
3977
+ typedef struct leptris_xinclude_opts {
3978
+ leptris_xinclude_resolver_fn resolver; /**< NULL = file loader only */
3979
+ void* resolver_user; /**< passed to the resolver */
3980
+ const char* catalog_path; /**< XML catalog file or NULL */
3981
+ int no_network; /**< default 1 (SSRF posture) */
3982
+ } leptris_xinclude_opts;
3983
+
3984
+ /**
3985
+ * Process XInclude with explicit resolver policy.
3986
+ *
3987
+ * Extends leptris_xinclude_process with:
3988
+ * - xml:base inheritance: relative hrefs resolve against the
3989
+ * nearest xml:base ancestor (RFC 3986 merge), and nested
3990
+ * includes inside an included document resolve against that
3991
+ * document's own location;
3992
+ * - an optional resolver hook (see leptris_xinclude_resolver_fn);
3993
+ * - an optional XML Catalog file (<uri name= uri=> exact mappings);
3994
+ * catalog lookups rewrite the URI before the resolver/loader runs;
3995
+ * - the network policy: with no_network (the default), hrefs whose
3996
+ * resolved URI carries http/https/ftp(s)/file-remote schemes are
3997
+ * resource errors (xi:fallback applies).
3998
+ *
3999
+ * Memory: opts is borrowed for the call; pass NULL for the defaults.
4000
+ */
4001
+ LEPTRIS_API LeptrisStatus leptris_xinclude_process_opts(
4002
+ LeptrisDocument doc, const char* base_url,
4003
+ const leptris_xinclude_opts* opts);
4004
+
3949
4005
  /**
3950
4006
  * Check if element is an XInclude include element
3951
4007
  *
@@ -152,6 +152,14 @@ void leptris_element_set_next_sibling(LeptrisElement elem, LeptrisElement siblin
152
152
 
153
153
  /* Get first attribute — decodes the int32_t offset (TODO 90 Phase 2d). */
154
154
  struct leptris_attribute* leptris_element_get_first_attribute(LeptrisElement elem) {
155
+ /* #1712: FFI consumers hand wrong-type handles to element faces
156
+ * (duck-typed remediation code passes text nodes). The compact
157
+ * overlay puts first_attribute_off 4 bytes past a 32-byte text
158
+ * struct — the next node's type word — so an unchecked decode
159
+ * hands out a dangling attribute handle that kills string
160
+ * readers. Internal callers pass elements by construction; the
161
+ * inline fast path skips this check. */
162
+ if (!LEPTRIS_NODE_IS_ELEMENT((LeptrisNode*)elem)) return NULL;
155
163
  return leptris_elem_first_attribute(elem);
156
164
  }
157
165