leptris 1.9.420.3-aarch64-linux → 1.9.422.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: 190a79d80eebde0090da1a701daf30c6be40b2d61bd430cc3f5ef4a016dbec49
4
- data.tar.gz: 782f33f1b12f465f57da7d0acd3323a4c1f69b8cfb6c3332df6a621b3843b541
3
+ metadata.gz: 15467f63ed5ead43b6d1b603f8efdffec8a27ce4fa9d7ed420e4ad087148aefd
4
+ data.tar.gz: 896badfac633ff9832485442bd4b3271e608e7a8c87311ff44dcfbde2881197b
5
5
  SHA512:
6
- metadata.gz: d01122d8faf9bf2208142b7a3bc3b24530d71fe7e80510b0599251cce8fff990625612dc84f771a718882b6869041c01e7ba90d3849c1dcb7fd04cb34eb8caed
7
- data.tar.gz: 9b40d6244c2cbbb36501c9f853588346f6a5152b11c86fff1c164afb593f1a254ef8c57666acb5224a627f3cccb30b0558f347d14219110b115fcc39bb16a747
6
+ metadata.gz: 15c465f1044f55d1f5ebc2b2d981cb960c9b07ec823a618566aa98fc78644c5c16f06c99ef6a87c256552657a0b11c176ee76dda445b42b9a96ca34a465b8f2f
7
+ data.tar.gz: 26d52b5464d401c16a19ac4afa00729c4f9444b51d63ebc46d7d32db6ba2faa9a716e7cc3ba6f88ba2a928a1c401410586daea8cc22495fe8320f044f3ec0e12
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.420"
11
+ LIBLEPTRIS_VERSION = "1.9.422"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.420.3"
4
+ VERSION = "1.9.422.0"
5
5
  end
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.420
4
+ - libleptris v1.9.422
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,35 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.422] - 2026-11-15
4
+
5
+ ### Fixed
6
+
7
+ - **xsd: the XSD 1.1 versioning namespace was wrong — every `vc`-marked schema compiled as 1.0** (moxml#556). The version probe looked for `vc:minVersion` in `http://www.w3.org/2001/XMLSchema-versioning`; the namespace per XSD 1.1 §4.3 is **`http://www.w3.org/2007/XMLSchema-versioning`**. The probe therefore missed on every schema in the wild, `version_11` stayed 0, and the whole 1.1 feature set — `xs:assert`, `xs:alternative`, simple-type `xs:assertion` — silently compiled away even though the evaluation machinery was already correct. With the namespace fixed, the exact consumer repro behaves both ways: `sum(a) > 0` passes `<a>5</a>` and fails `<a>-5</a>` with an `assertion` finding. The #1910/#1911 gate fixtures had bound their `vc` prefix to the same wrong 2001 URI; corrected to the spec URI.
8
+
9
+ ### Fixed (Rosetta/QEMU class)
10
+
11
+ - **simd: the AVX2 kernel selection now verifies executability, not CPUID claims** (leptris#2039). Rosetta 2 (and QEMU user-mode) report AVX2 in CPUID but SIGILL on the first vector op — under Rosetta, every parse through the direct-parse face crashed at `leptris_text_scan_run_pristine_avx2+0x4`. The probe now executes a one-instruction canary (`vpaddb` on a register, under a SIGILL guard, cached per process) before blessing the AVX2 level, and `leptris_text_scan_run_pristine` — the one kernel dispatched compile-time-only — rides the runtime dispatch like every other kernel (pre-Haswell x86_64 falls back to the scalar walk too). Verified on the failing platform: Rosetta reports the level as sse4.2 and parses clean.
12
+
13
+ ### Performance
14
+
15
+ - **direct-parse: `dp_add_attr_inline` takes 8 register arguments** (leptris#2032). The 10-argument form overflowed arm64's register window — `name_colon` plus a flags word spilled to the caller's frame, and gcc's prologue (six callee-saved store-pairs plus the stack-arg reload) paid on every attribute. Packing `len|hash<<32` and the two scan flags into scalars is behavior-neutral; the CI-gated attrparse row moved macos −15% to parity (0.98× vs pugixml) with x86's win held. The ubuntu-arm leg improves ~2%; the remaining delta (the caller's stack-frame pressure) is tracked on #2032 with the on-runner profile attached.
16
+
17
+ ### Tooling
18
+
19
+ - **perf-record harness on the CI arm runner** (branch `repro/2032-perf`): `perf record` + report + annotate artifacts under `perf_event_paranoid=1` with the generic linux-tools binary — the on-runner profile that localized both #2032 levers.
20
+
21
+
22
+ ## [1.9.421] - 2026-11-15
23
+ ### Performance
24
+
25
+ - **text: the census-gated pristine scan** (leptris#2033 round 2). The `count3_high` sizing pre-scan already counts `&` and tab/LF/CR for the whole buffer — a document with both counts zero has *provably constant* scan flags, so the text branch dispatches to a term-only kernel (`leptris_text_scan_run_pristine`, NEON/AVX2/scalar) whose vector loop carries only the term compare: the f1/f2 accumulator chains drop out entirely, and the round-1 rescan penalty cannot occur because the census already answered the flags. Gate teeth: a DTD custom entity requires the eager entity path (routed by the scan's has_amp flag — the lazy read cannot resolve custom entities), and the new pin fails when the gate is forced open. Local interleaved A/B on the pristine-class 13MB text shape: median +10%.
26
+
27
+ ### CI
28
+
29
+ - **perf-gate: the configure stage installs `libutf8proc-dev`** — the gate had errored without measuring since Nov 13, when the runner-image update (20261111.370) removed the runner copy of utf8proc the gate had been implicitly relying on (found during the release audit).
30
+
31
+
32
+
3
33
  ## [1.9.420] - 2026-11-13
4
34
  ### Fixed
5
35
 
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.420
6
+ VERSION 1.9.422
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -4,6 +4,13 @@
4
4
  * CPUID via __cpuid — treated as SSE42 baseline for simplicity
5
5
  * (every x86_64 CPU shipping since 2008 has SSE4.2).
6
6
  * arm64: NEON is architectural baseline — constant.
7
+ *
8
+ * #2039: CPUID can claim AVX2 that the execution environment cannot
9
+ * run — Rosetta 2 reports AVX2 in CPUID and SIGILLs on the first
10
+ * vector op; QEMU user-mode carries the same gap class. A claimed
11
+ * AVX2 level is therefore verified with an execute-canary (one
12
+ * vpaddb under a SIGILL guard) before it is blessed; the verdict is
13
+ * computed once per process and rides the same cache as the level.
7
14
  */
8
15
  #include "cpu.h"
9
16
 
@@ -14,12 +21,52 @@
14
21
  # include <intrin.h>
15
22
  #endif
16
23
 
24
+ #if defined(LEPTRIS_X86_GCC_BUILTINS)
25
+ # include <setjmp.h>
26
+ # include <signal.h>
27
+
28
+ static sigjmp_buf leptris_canary_env;
29
+ static volatile sig_atomic_t leptris_canary_fired = 0;
30
+
31
+ static void leptris_canary_sigill(int sig) {
32
+ (void)sig;
33
+ leptris_canary_fired = 1;
34
+ siglongjmp(leptris_canary_env, 1);
35
+ }
36
+
37
+ /* 1 = AVX2 instructions actually execute; 0 = CPUID lied. A probe
38
+ * setup failure trusts CPUID (signal() unavailable is not a case any
39
+ * supported platform hits, and the previous behavior was unconditional
40
+ * trust). */
41
+ static int leptris_avx2_executable(void) {
42
+ void (*old)(int) = signal(SIGILL, leptris_canary_sigill);
43
+ if (old == SIG_ERR) {
44
+ return 1;
45
+ }
46
+ int ok = 1;
47
+ leptris_canary_fired = 0;
48
+ if (sigsetjmp(leptris_canary_env, 1) == 0) {
49
+ /* Reads/writes only xmm0 (caller-saved, clobber-declared): no
50
+ * memory operand, no state change — a pure "can the pipeline
51
+ * retire this opcode" probe. */
52
+ __asm__ volatile("vpaddb %%xmm0, %%xmm0, %%xmm0" : : : "xmm0");
53
+ }
54
+ if (leptris_canary_fired) {
55
+ ok = 0;
56
+ }
57
+ signal(SIGILL, old);
58
+ return ok;
59
+ }
60
+ #endif
61
+
17
62
  leptris_cpu_level leptris_cpu_detect(void) {
18
63
  #if defined(LEPTRIS_ARCH_ARM)
19
64
  return LEPTRIS_CPU_NEON;
20
65
  #elif defined(LEPTRIS_X86_GCC_BUILTINS)
21
66
  __builtin_cpu_init();
22
- if (__builtin_cpu_supports("avx2")) return LEPTRIS_CPU_AVX2;
67
+ if (__builtin_cpu_supports("avx2") && leptris_avx2_executable()) {
68
+ return LEPTRIS_CPU_AVX2;
69
+ }
23
70
  if (__builtin_cpu_supports("sse4.2")) return LEPTRIS_CPU_SSE42;
24
71
  return LEPTRIS_CPU_SCALAR;
25
72
  #elif defined(_MSC_VER) && defined(_M_X64)
@@ -114,6 +114,8 @@ static void (*g_copy3_fn)(char*, const char*, size_t, char, char, char,
114
114
  static int (*g_utf8_fn)(const char*, size_t) = NULL;
115
115
  static ptrdiff_t (*g_scan_run_fn)(const char*, size_t, char, char, char,
116
116
  int*, int*) = NULL;
117
+ static ptrdiff_t (*g_pristine_fn)(const char*, size_t, char,
118
+ int*, int*) = NULL;
117
119
 
118
120
  /* #1842: one pass, three byte classes — the direct parser's text path
119
121
  * (find '<', flag '&'/CR) drops its 48-byte inline loop and up to
@@ -167,6 +169,8 @@ static void count3_high_scalar(const char* s, size_t len,
167
169
  size_t* n0, size_t* n1, size_t* n2,
168
170
  int* saw_high, size_t* amp_count,
169
171
  size_t* valws_count);
172
+ static ptrdiff_t pristine_scalar(const char* s, size_t len, char term,
173
+ int* saw_f1, int* saw_f2);
170
174
 
171
175
  #if defined(_MSC_VER)
172
176
  # pragma section(".CRT$XCU", read)
@@ -190,6 +194,7 @@ static void dispatch_init(void) {
190
194
  g_count_fn = leptris_text_count_char_avx2;
191
195
  g_count3_high_fn = leptris_text_count3_high_avx2;
192
196
  g_scan_run_fn = leptris_text_scan_run_avx2;
197
+ g_pristine_fn = leptris_text_scan_run_pristine_avx2;
193
198
  g_utf8_fn = leptris_utf8_valid_avx2;
194
199
  return;
195
200
  }
@@ -203,6 +208,7 @@ static void dispatch_init(void) {
203
208
  g_count3_high_fn = leptris_text_count3_high_neon;
204
209
  g_copy3_fn = leptris_copy_count3_neon;
205
210
  g_scan_run_fn = leptris_text_scan_run_neon;
211
+ g_pristine_fn = leptris_text_scan_run_pristine_neon;
206
212
  g_utf8_fn = leptris_utf8_valid_neon;
207
213
  return;
208
214
  }
@@ -213,6 +219,7 @@ static void dispatch_init(void) {
213
219
  g_count_fn = count_scalar;
214
220
  g_count3_high_fn = count3_high_scalar;
215
221
  g_scan_run_fn = scan_run_scalar;
222
+ g_pristine_fn = pristine_scalar;
216
223
  g_utf8_fn = leptris_utf8_valid_scalar;
217
224
  }
218
225
 
@@ -321,6 +328,44 @@ ptrdiff_t leptris_text_scan_run(const char* s, size_t len, char term,
321
328
  return g_scan_run_fn(s, len, term, f1, f2, saw_f1, saw_f2);
322
329
  }
323
330
 
331
+ /* leptris#2033 round 2: the census-gated term-only scan. For
332
+ * documents whose count3_high pre-scan proved zero '&' and zero
333
+ * tab/LF/CR, the f1/f2 accumulator chains are dead weight — the
334
+ * flags are constant 0 by census, so the vector loop carries ONLY
335
+ * the term compare and the no-term tail returns immediately (the
336
+ * round-1 rescan penalty cannot occur: the census answered the
337
+ * flags). Arch kernels live in their own TUs. */
338
+ static ptrdiff_t pristine_scalar(const char* s, size_t len, char term,
339
+ int* saw_f1, int* saw_f2) {
340
+ const char* p = s;
341
+ const char* end = s + len;
342
+ while (p < end) {
343
+ if (*p == term) {
344
+ *saw_f1 = 0;
345
+ *saw_f2 = 0;
346
+ return (ptrdiff_t)(p - s);
347
+ }
348
+ p++;
349
+ }
350
+ *saw_f1 = 0;
351
+ *saw_f2 = 0;
352
+ return -1;
353
+ }
354
+
355
+ /* #2039: routed through the RUNTIME cpu level like every other
356
+ * kernel — the compile-time-only gate ran the AVX2 binary on CPUs
357
+ * that cannot execute it (Rosetta/QEMU report AVX2 in CPUID and
358
+ * SIGILL on first use; pre-Haswell x86_64 has none at all). The
359
+ * dispatch verdict already carries the execute-canary verdict from
360
+ * cpu.c. */
361
+ ptrdiff_t leptris_text_scan_run_pristine(const char* s, size_t len,
362
+ char term,
363
+ int* saw_f1, int* saw_f2) {
364
+ if (!g_pristine_fn) dispatch_init();
365
+ if (!g_pristine_fn) g_pristine_fn = pristine_scalar;
366
+ return g_pristine_fn(s, len, term, saw_f1, saw_f2);
367
+ }
368
+
324
369
  /* ---- Structural span scan (TODO 193 Phase 1) ---- */
325
370
 
326
371
  unsigned char leptris_dp_class_table[256];
@@ -98,6 +98,22 @@ ptrdiff_t leptris_text_scan_run(const char* s, size_t len, char term,
98
98
  char f1, char f2,
99
99
  int* saw_f1, int* saw_f2);
100
100
 
101
+ /* The census-gated variant (leptris#2033 round 2): identical
102
+ * contract, for documents whose pre-scan census proved ZERO '&' and
103
+ * zero tab/LF/CR bytes anywhere — the flags are constant 0 and the
104
+ * accumulator chains drop out of the loop. saw_f1/saw_f2 are
105
+ * WRITTEN as 0 (callers read them unconditionally). */
106
+ ptrdiff_t leptris_text_scan_run_pristine(const char* s, size_t len,
107
+ char term,
108
+ int* saw_f1, int* saw_f2);
109
+
110
+ ptrdiff_t leptris_text_scan_run_pristine_neon(const char* s, size_t len,
111
+ char term,
112
+ int* saw_f1, int* saw_f2);
113
+ ptrdiff_t leptris_text_scan_run_pristine_avx2(const char* s, size_t len,
114
+ char term,
115
+ int* saw_f1, int* saw_f2);
116
+
101
117
  /* ---- Structural span scan (TODO 193 Phase 1: parser v3) ----
102
118
  *
103
119
  * Records every byte of the XML structural set in [buf, buf+len)
@@ -370,4 +370,37 @@ int leptris_utf8_valid_avx2(const char* src, size_t len) {
370
370
  if (b >= 0xC2 && b <= 0xF4) start--;
371
371
  }
372
372
  return leptris_utf8_valid_scalar((const char*)(p + start), len - start);
373
- }
373
+ }
374
+
375
+ /* leptris#2033 round 2: the census-gated term-only scan — no
376
+ * accumulator chains (the census proved the flags constant 0). */
377
+ ptrdiff_t leptris_text_scan_run_pristine_avx2(const char* s, size_t len,
378
+ char term,
379
+ int* saw_f1, int* saw_f2) {
380
+ const char* p = s;
381
+ const char* end = s + len;
382
+ const __m256i kt = _mm256_set1_epi8(term);
383
+ while (end - p >= 32) {
384
+ __m256i v = _mm256_loadu_si256((const __m256i*)p);
385
+ uint32_t mt =
386
+ (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v, kt));
387
+ if (mt) {
388
+ unsigned idx = (unsigned)LEPTRIS_CTZ(mt);
389
+ *saw_f1 = 0;
390
+ *saw_f2 = 0;
391
+ return (ptrdiff_t)(p + idx - s);
392
+ }
393
+ p += 32;
394
+ }
395
+ while (p < end) {
396
+ if (*p == term) {
397
+ *saw_f1 = 0;
398
+ *saw_f2 = 0;
399
+ return (ptrdiff_t)(p - s);
400
+ }
401
+ p++;
402
+ }
403
+ *saw_f1 = 0;
404
+ *saw_f2 = 0;
405
+ return -1;
406
+ }
@@ -523,3 +523,34 @@ int leptris_utf8_valid_neon(const char* src, size_t len) {
523
523
  return leptris_utf8_valid_scalar((const char*)(p + start), len - start);
524
524
  }
525
525
  #undef IN_RANGE
526
+
527
+ /* leptris#2033 round 2: the census-gated term-only scan — no
528
+ * accumulator chains (the census proved the flags constant 0). */
529
+ ptrdiff_t leptris_text_scan_run_pristine_neon(const char* s, size_t len,
530
+ char term,
531
+ int* saw_f1, int* saw_f2) {
532
+ const char* p = s;
533
+ const char* end = s + len;
534
+ const uint8x16_t kt = vdupq_n_u8((uint8_t)term);
535
+ while (end - p >= 16) {
536
+ if (vmaxvq_u8(vceqq_u8(vld1q_u8((const uint8_t*)p), kt)) != 0) {
537
+ int i = 0;
538
+ while (p[i] != term) i++;
539
+ *saw_f1 = 0;
540
+ *saw_f2 = 0;
541
+ return (ptrdiff_t)(p + i - s);
542
+ }
543
+ p += 16;
544
+ }
545
+ while (p < end) {
546
+ if (*p == term) {
547
+ *saw_f1 = 0;
548
+ *saw_f2 = 0;
549
+ return (ptrdiff_t)(p - s);
550
+ }
551
+ p++;
552
+ }
553
+ *saw_f1 = 0;
554
+ *saw_f2 = 0;
555
+ return -1;
556
+ }
@@ -587,11 +587,21 @@ static int dp_dup_seen_or_add(DParser* p, uint32_t dh) {
587
587
  * value pool_strdup entirely — direct_parse path excludes entity
588
588
  * inputs, so has_entities is always 0. */
589
589
  static inline int dp_add_attr_inline(DParser* p, LeptrisElement elem,
590
- char* name, size_t name_len,
591
- uint32_t name_hash,
592
- char* val, size_t val_len,
593
- int has_amp, int has_ws,
590
+ char* name, char* val,
591
+ uint64_t name_len_hash,
592
+ size_t val_len, uint32_t ws_amp,
594
593
  const char* name_colon) {
594
+ /* #2032 arm64 codegen: the 10-argument form overflowed the 8
595
+ * register-argument window — name_colon plus a flags word spilled
596
+ * to the caller's frame, and the entry reload dominated the
597
+ * on-runner profile (the prologue's six store-pairs plus the
598
+ * stack-arg reload were ~13% of the function's samples under
599
+ * gcc-13). Packing len|hash<<32 and the two scan flags into
600
+ * scalars keeps every argument in a register. */
601
+ size_t name_len = (size_t)(name_len_hash & 0xFFFFFFFFu);
602
+ uint32_t name_hash = (uint32_t)(name_len_hash >> 32);
603
+ int has_amp = (int)(ws_amp & 1u);
604
+ int has_ws = (int)((ws_amp >> 1) & 1u);
595
605
  /* Raw-view pointer (pre-normalization) — the #635 surface shows
596
606
  * source views; the normalized/entity-expanded replacements
597
607
  * below rebind val. */
@@ -1315,9 +1325,13 @@ static int dp_parse_attrs(DParser* p, LeptrisElement elem) {
1315
1325
 
1316
1326
  /* Regular attribute — zero-copy name/value, bulk-allocated
1317
1327
  * struct. 1 = duplicate skipped: neither surface sees it. */
1318
- int arc = dp_add_attr_inline(p, elem, name_start, name_len,
1319
- dh, val_start, val_len, has_amp,
1320
- has_ws, attr_colon);
1328
+ int arc = dp_add_attr_inline(p, elem, name_start, val_start,
1329
+ (uint64_t)name_len |
1330
+ ((uint64_t)dh << 32),
1331
+ val_len,
1332
+ (uint32_t)has_amp |
1333
+ ((uint32_t)has_ws << 1),
1334
+ attr_colon);
1321
1335
  if (arc < 0) return -1;
1322
1336
  }
1323
1337
  /* for (;;): every exit is a return inside the loop (0 = tag
@@ -1574,6 +1588,12 @@ static struct leptris_document* direct_parse_internal(char* buf, size_t len,
1574
1588
  * structural use (pretty-printed docs) conservatively re-arms
1575
1589
  * it, and CR-only line endings keep it armed. */
1576
1590
  int has_copy_sources = (amp_count_in != 0 || valws_count_in != 0);
1591
+ /* leptris#2033 round 2: the census proved zero '&' and zero
1592
+ * tab/LF/CR in the whole buffer — text runs cannot carry the
1593
+ * f1/f2 flags, so the term-only kernel drops the accumulator
1594
+ * chains. The entity/CR branches downstream are unreachable on
1595
+ * this class by the same census. */
1596
+ int pristine_text = (amp_count_in == 0 && valws_count_in == 0);
1577
1597
  /* Track D A3d: the pristine copy exists so doc->xml_buffer stays
1578
1598
  * byte-identical to the input — the lazy line table (#223)
1579
1599
  * counts '\n' against it, and dp_nul may clobber a newline that
@@ -1902,9 +1922,14 @@ static struct leptris_document* direct_parse_internal(char* buf, size_t len,
1902
1922
  int has_cr = 0;
1903
1923
  {
1904
1924
  int saw_amp = 0, saw_cr = 0;
1905
- ptrdiff_t t_off = leptris_text_scan_run(
1906
- p.pos, (size_t)(p.end - p.pos), '<', '&', '\r',
1907
- &saw_amp, &saw_cr);
1925
+ ptrdiff_t t_off =
1926
+ pristine_text
1927
+ ? leptris_text_scan_run_pristine(
1928
+ p.pos, (size_t)(p.end - p.pos), '<',
1929
+ &saw_amp, &saw_cr)
1930
+ : leptris_text_scan_run(
1931
+ p.pos, (size_t)(p.end - p.pos), '<', '&',
1932
+ '\r', &saw_amp, &saw_cr);
1908
1933
  lt = (t_off >= 0) ? (char*)(p.pos + t_off) : NULL;
1909
1934
  has_amp |= saw_amp;
1910
1935
  has_cr |= saw_cr;
@@ -2141,10 +2141,10 @@ static LeptrisXsdSchema xsd_compile_impl(const char* xsd_text,
2141
2141
  * alternatives away for every vc-marked schema. */
2142
2142
  const char* ver = leptris_element_attribute(root, "version");
2143
2143
  const char* vmin = leptris_element_attribute_ns(
2144
- root, "http://www.w3.org/2001/XMLSchema-versioning",
2144
+ root, "http://www.w3.org/2007/XMLSchema-versioning",
2145
2145
  "minVersion");
2146
2146
  const char* vmax = leptris_element_attribute_ns(
2147
- root, "http://www.w3.org/2001/XMLSchema-versioning",
2147
+ root, "http://www.w3.org/2007/XMLSchema-versioning",
2148
2148
  "maxVersion");
2149
2149
  int is11 = (ver && strcmp(ver, "1.1") == 0) ||
2150
2150
  (vmin && strcmp(vmin, "1.1") == 0);
@@ -1064,3 +1064,25 @@ TEST(RoundTrip, OoxmlRunPropertiesKeepValAttributes) {
1064
1064
  leptris_free_string(out);
1065
1065
  leptris_document_free(doc);
1066
1066
  }
1067
+
1068
+ /* leptris#2033 round 2 gate teeth: a DTD custom entity requires the
1069
+ * EAGER entity path (the lazy read cannot resolve custom entities),
1070
+ * routed by the text scan's has_amp flag. The census-gated
1071
+ * pristine-text kernel must NEVER take a document whose census
1072
+ * counts '&' — forcing it leaves the entity reference raw. */
1073
+ TEST(Parser, DtdCustomEntityExpandsThroughTheEagerPath) {
1074
+ const char* xml =
1075
+ "<!DOCTYPE r [<!ENTITY x \"hello\">]><r>&x; world</r>";
1076
+ LeptrisStatus st = LEPTRIS_OK;
1077
+ LeptrisDocument doc =
1078
+ leptris_parse_string(xml, std::strlen(xml), &st);
1079
+ ASSERT_EQ(st, LEPTRIS_OK);
1080
+ ASSERT_NE(doc, nullptr);
1081
+ LeptrisElement root = leptris_document_root(doc);
1082
+ ASSERT_NE(root, nullptr);
1083
+ LeptrisNodeRef text =
1084
+ leptris_node_first_child(leptris_element_as_node(root));
1085
+ ASSERT_NE(text, nullptr);
1086
+ EXPECT_STREQ(leptris_text_node_get_content(text), "hello world");
1087
+ leptris_document_free(doc);
1088
+ }
@@ -2644,6 +2644,24 @@ TEST(XsdAssert11, ExtensionAssertionEnforces) {
2644
2644
 
2645
2645
  /* 1.0-labelled schemas ignore the construct (XSD 1.0 validators
2646
2646
  * see unknown elements) — no assertion enforcement */
2647
+ // moxml#556: the vc:minVersion spelling marks 1.1 too — the
2648
+ // versioning namespace is http://www.w3.org/2007/XMLSchema-versioning
2649
+ // (the engine probed 2001 and silently skipped every vc-marked
2650
+ // schema's asserts and alternatives)
2651
+ TEST(XsdAssert11, VcMinVersionMarksSchema11) {
2652
+ const char* x =
2653
+ "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
2654
+ " vc:minVersion=\"1.1\""
2655
+ " xmlns:vc=\"http://www.w3.org/2007/XMLSchema-versioning\">"
2656
+ "<xs:element name=\"doc\"><xs:complexType>"
2657
+ "<xs:sequence><xs:element name=\"a\" type=\"xs:int\""
2658
+ " maxOccurs=\"unbounded\"/></xs:sequence>"
2659
+ "<xs:assert test=\"sum(a) &gt; 0\"/>"
2660
+ "</xs:complexType></xs:element></xs:schema>";
2661
+ EXPECT_EQ(validate_doc(x, "<doc><a>5</a></doc>"), 1);
2662
+ EXPECT_EQ(validate_doc(x, "<doc><a>-5</a></doc>"), 0);
2663
+ }
2664
+
2647
2665
  TEST(XsdAssert11, Version10IgnoresAssertions) {
2648
2666
  const char* x =
2649
2667
  "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
@@ -4900,7 +4918,7 @@ TEST(Xsd11Gate, CtaSelectsAlternativeType) {
4900
4918
  const char xsd[] =
4901
4919
  "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
4902
4920
  " vc:minVersion=\"1.1\""
4903
- " xmlns:vc=\"http://www.w3.org/2001/XMLSchema-versioning\">"
4921
+ " xmlns:vc=\"http://www.w3.org/2007/XMLSchema-versioning\">"
4904
4922
  "<xs:element name=\"shape\" type=\"Shape\">"
4905
4923
  "<xs:alternative test=\"@kind='circle'\" type=\"Circle\"/>"
4906
4924
  "</xs:element>"
@@ -4934,7 +4952,7 @@ TEST(Xsd11Gate, AssertIsEvaluated) {
4934
4952
  const char xsd[] =
4935
4953
  "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
4936
4954
  " vc:minVersion=\"1.1\""
4937
- " xmlns:vc=\"http://www.w3.org/2001/XMLSchema-versioning\">"
4955
+ " xmlns:vc=\"http://www.w3.org/2007/XMLSchema-versioning\">"
4938
4956
  "<xs:element name=\"size\">"
4939
4957
  "<xs:complexType><xs:sequence>"
4940
4958
  "<xs:element name=\"w\" type=\"xs:integer\"/>"
@@ -4972,7 +4990,7 @@ TEST(Xsd11Gate, OverrideLoadsBaseAndReplacesComponents) {
4972
4990
  "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
4973
4991
  " targetNamespace=\"urn:b\" xmlns=\"urn:b\""
4974
4992
  " elementFormDefault=\"qualified\" vc:minVersion=\"1.1\""
4975
- " xmlns:vc=\"http://www.w3.org/2001/XMLSchema-versioning\">"
4993
+ " xmlns:vc=\"http://www.w3.org/2007/XMLSchema-versioning\">"
4976
4994
  "<xs:override schemaLocation=\"ovr1913_base.xsd\">"
4977
4995
  "<xs:complexType name=\"Doc\">"
4978
4996
  "<xs:sequence><xs:element name=\"b\" type=\"xs:integer\"/>"
@@ -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.420",
4
+ "version": "1.9.422",
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.420.3
4
+ version: 1.9.422.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Ribose Inc.