leptris 1.9.355.0-aarch64-linux → 1.9.356.0-aarch64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d6a2a11a44511db0590c72a46796589812ec26720289d8bac07962e2b601942
4
- data.tar.gz: 8966cf0297c64976e84bc82932c77962673bf957f0a4d23d329fe47bea450b9a
3
+ metadata.gz: d2ab8afbafabc3c7bd0460a1ef2fe6de41dc3bcd7d1f39c1adfd186c6fb48eee
4
+ data.tar.gz: b619aa5c004a702a627d9b65bf7d874ba4fe7ed7039257c83c5dded9b9dd1bea
5
5
  SHA512:
6
- metadata.gz: 0cc863c7d7162739949a98b5425b3f7d1e09884b6ab91bc66e36ad64322c1bcc65ee673cfbe4212b891dfce2ce4a0692a97451cb4dc1e01580146b3df891ed5e
7
- data.tar.gz: 1a71f0e3bbdaf8bfc1dc6d2c15e082135c584925c48d56ec37ef23b295d46f6d2f8d4320523bb87e36e5ce118d91d0e0caa0a86dad6f5727c231497ae86a2b52
6
+ metadata.gz: 3ab8a55c24eceb6f38e8f3a1cdc77343f038674cfdc2d04b7a59fdaa04c3fd32fcacd2092053d4158f2caa7a23011b53d81fbf2df59992f764d49a6a0e44fbd3
7
+ data.tar.gz: e0cebdb1296fe5e2c04da67f5086afeef6f99c55379ef565bad5685775c93ff70ad2088dc72bb8a71f6710d287b7f5f3774bd9da1bf902a67680458703ba11af
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [1.9.356.0] - 2026-10-14
2
+
3
+ ### Fixed — engine sync (libleptris 1.9.356)
4
+
5
+ - **Native attribute faces type-guarded (leptris/leptris#1712,
6
+ PR #453)**: duck-typed consumers (svg_conform's
7
+ NamespaceRemediation) pass text nodes to `#attributes`; the
8
+ unchecked decode handed C a dangling `attr == node + 1` and the
9
+ first string read segfaulted on svg corpora with adjacent
10
+ `<text>` nodes. Non-element handles now answer the empty
11
+ contract (`{}` / `nil`) across `nn_attributes`, `nn_attribute`,
12
+ `nf_fast_attribute2`, `nf_attribute`, and `nf_bulk_attr_faces`.
13
+ The engine-side public-boundary guard rides libleptris
14
+ 1.9.356 (leptris/leptris PR #1713).
15
+
1
16
  ## [1.9.355.0] - 2026-10-14
2
17
 
3
18
  ### Fixed — engine sync (libleptris 1.9.355)
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.355"
11
+ LIBLEPTRIS_VERSION = "1.9.356"
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
@@ -355,9 +355,14 @@ static VALUE nn_content(VALUE self)
355
355
  static VALUE nf_fast_attribute2(VALUE self, VALUE addr, VALUE name)
356
356
  {
357
357
  const char *s;
358
+ void *node = (void *)(uintptr_t)NUM2ULL(addr);
359
+
358
360
  (void)self;
359
- s = f_attr((void *)(uintptr_t)NUM2ULL(addr),
360
- RSTRING_PTR(StringValue(name)));
361
+ /* leptris#1712: non-element handles must not reach the attr
362
+ * chain (same dangling-overlay shape as nn_attributes). */
363
+ if (f_node_type(node) != WS_NODE_ELEMENT)
364
+ return Qnil;
365
+ s = f_attr(node, RSTRING_PTR(StringValue(name)));
361
366
  return s ? rb_utf8_str_new_cstr(s) : Qnil;
362
367
  }
363
368
 
@@ -376,6 +381,10 @@ static VALUE nn_attribute(VALUE self, VALUE name)
376
381
  name = rb_obj_as_string(name);
377
382
  TypedData_Get_Struct(self, struct native_node, &nn_type, n);
378
383
  doc = n->document;
384
+ /* leptris#1712: non-element handles must not reach the attr
385
+ * chain (same dangling-overlay shape as nn_attributes). */
386
+ if (f_node_type(n->ptr) != WS_NODE_ELEMENT)
387
+ return Qnil;
379
388
  /* Single-slot memo first: the last-queried name by VALUE
380
389
  * (callers may mint a fresh String per call) against the same
381
390
  * version. Then the hash memo for other repeat names; both
@@ -1413,6 +1422,14 @@ static VALUE nn_attributes(VALUE self)
1413
1422
 
1414
1423
  TypedData_Get_Struct(self, struct native_node, &nn_type, n);
1415
1424
  hash = rb_hash_new();
1425
+ /* leptris#1712: duck-typed consumers pass non-element handles
1426
+ * (svg_conform's remediation walks text nodes with an
1427
+ * element? probe that answers on #name). The element attr
1428
+ * overlay sits 4 bytes past a 32-byte text struct — the next
1429
+ * node's type word — so an unchecked decode hands C a dangling
1430
+ * attr == node + 1 and the first string read segfaults. */
1431
+ if (f_node_type(n->ptr) != WS_NODE_ELEMENT)
1432
+ return hash;
1416
1433
  attr = f_attr_first(n->ptr);
1417
1434
  while (attr) {
1418
1435
  const char *name = f_attr_name(attr);
@@ -1939,10 +1956,14 @@ static VALUE nf_bulk_attr_faces(VALUE self, VALUE addr, VALUE element)
1939
1956
  void *node = (void *)(uintptr_t)NUM2ULL(addr);
1940
1957
  VALUE faces = rb_hash_new();
1941
1958
  VALUE values = rb_hash_new();
1942
- void *attr = f_attr_first(node);
1959
+ void *attr;
1943
1960
 
1944
1961
  (void)self;
1962
+ /* leptris#1712: same non-element guard as nn_attributes. */
1963
+ if (f_node_type(node) != WS_NODE_ELEMENT)
1964
+ return rb_assoc_new(faces, values);
1945
1965
  resolve_binding_classes();
1966
+ attr = f_attr_first(node);
1946
1967
  while (attr) {
1947
1968
  const char *name = f_attr_name(attr);
1948
1969
  const char *value = f_attr_value(node, attr);
@@ -2981,8 +3002,13 @@ static VALUE nf_element_text(VALUE self, VALUE addr)
2981
3002
  static VALUE nf_attribute(VALUE self, VALUE addr, VALUE name)
2982
3003
  {
2983
3004
  const char *s;
3005
+ void *node = (void *)(uintptr_t)NUM2ULL(addr);
3006
+
2984
3007
  (void)self;
2985
- s = f_attr((void *)(uintptr_t)NUM2ULL(addr), StringValueCStr(name));
3008
+ /* leptris#1712: same non-element guard as nn_attributes. */
3009
+ if (f_node_type(node) != WS_NODE_ELEMENT)
3010
+ return Qnil;
3011
+ s = f_attr(node, StringValueCStr(name));
2986
3012
  return s ? rb_utf8_str_new_cstr(s) : Qnil;
2987
3013
  }
2988
3014
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.355.0"
4
+ VERSION = "1.9.356.0"
5
5
  end
Binary file
data/lib/libleptris.so CHANGED
Binary file
data/vendor-src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Sources vendored in this gem (recompile rights; the ruby
2
2
  variant builds them at install via extconf.rb):
3
3
 
4
- - libleptris v1.9.355
4
+ - libleptris v1.9.356
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,44 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.356] - 2026-10-14
4
+
5
+ ### Fixed
6
+
7
+ - **DOM: type-guard the public first-attribute face
8
+ (leptris#1712, PR #1713).** A wrong-type node handle — a text
9
+ node passed where an element is expected, which duck-typed
10
+ consumers do (svg_conform's NamespaceRemediation probes
11
+ `element?` via `#name`, and the Ruby binding's NativeNode text
12
+ wrapper answers it Nokogiri-compatibly) — decoded the pool word
13
+ at the `element.first_attribute_off` overlay offset. That offset
14
+ sits 4 bytes past a 32-byte text struct: the next pool node's
15
+ type word. A following text node (type == 1) yielded
16
+ `attr == node + 1`, and the first string read on that handle
17
+ segfaulted — deterministically on svg corpora with adjacent
18
+ `<text>` nodes (3.6 MB `fig-a1.svg`: 3064 rects, 170 paths).
19
+ `leptris_element_first_attribute` now answers the empty contract
20
+ (`NULL`) for non-element handles; internal callers keep the
21
+ unchecked inline fast path. Red spec:
22
+ `DomBasics.AttributeFacesRejectNonElementHandles` (parse-carved
23
+ adjacent text nodes reproduce the dangling handle).
24
+ - **RelaxNG: free the include-merge originals (PR #1711
25
+ follow-up).** The define-body deep copy (adoption-by-copy) left
26
+ the included grammar's original pattern trees unreachable but
27
+ unfreed — one 80-byte `RngPattern` tree leaked per merged define
28
+ on every include hop (Linux-ASAN/LSan, `RngInclude.*` aborts).
29
+ The merge now frees the original after the copy, on both the
30
+ success and the failure paths.
31
+
32
+ ### ruby binding (leptris-ruby 1.9.356.0, PR leptris-ruby#453)
33
+
34
+ - Type-guard every native attribute face (`nn_attributes`,
35
+ `nn_attribute`, `nf_fast_attribute2`, `nf_attribute`,
36
+ `nf_bulk_attr_faces`): non-element handles answer the empty
37
+ contract (`{}` / `nil`), matching `nf_attribute_rows`' existing
38
+ check. The svg_conform remediation now completes on the crash
39
+ corpus with byte-identical output to the nokogiri adapter.
40
+
41
+
3
42
  ## [1.9.355] - 2026-10-14
4
43
 
5
44
  ### 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.356
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -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
 
@@ -352,6 +352,33 @@ TEST(DomBasics, AttributeHandleIterationEmptyAndNullContracts) {
352
352
  leptris_document_free(doc);
353
353
  }
354
354
 
355
+ TEST(DomBasics, AttributeFacesRejectNonElementHandles) {
356
+ /* leptris#1712: a text node handed to an element attribute face
357
+ * must not decode pool neighbours as an attribute chain — the
358
+ * compact overlays put element.first_attribute_off 4 bytes past
359
+ * the 32-byte text struct, i.e. on the NEXT node's type word
360
+ * (=1 for a following text node), yielding the dangling
361
+ * handle+1 that kills string readers (svg_conform segfault). */
362
+ const char xml[] = "<r a='1'>x<!--c-->y</r>";
363
+ LeptrisStatus st = LEPTRIS_OK;
364
+ LeptrisDocument doc = leptris_parse_string(xml, std::strlen(xml), &st);
365
+ ASSERT_NE(doc, nullptr);
366
+ LeptrisElement root = leptris_document_root(doc);
367
+
368
+ LeptrisNodeRef text = leptris_node_first_child((LeptrisNodeRef)root);
369
+ ASSERT_NE(text, nullptr);
370
+ ASSERT_EQ(leptris_node_get_type(text), kNodeTypeText);
371
+ LeptrisNodeRef comment = leptris_node_next_sibling(text);
372
+ ASSERT_EQ(leptris_node_get_type(comment), kNodeTypeComment);
373
+ LeptrisNodeRef second_text = leptris_node_next_sibling(comment);
374
+ ASSERT_EQ(leptris_node_get_type(second_text), kNodeTypeText);
375
+
376
+ EXPECT_EQ(leptris_element_first_attribute((LeptrisElement)text),
377
+ nullptr);
378
+
379
+ leptris_document_free(doc);
380
+ }
381
+
355
382
  TEST(DomBasics, AttributeHandleValueExpandsEntities) {
356
383
  const char xml[] = "<r t='a &amp; b &lt; c'/>";
357
384
  LeptrisStatus st = LEPTRIS_OK;
@@ -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.355",
4
+ "version": "1.9.356",
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.355.0
4
+ version: 1.9.356.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Ribose Inc.