leptris 1.9.344.0-ppc64le-linux → 1.9.345.1-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 +37 -0
- data/Rakefile +52 -2
- data/TODO.final/04-native-bundle-codesign-artifact-sync.md +51 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/libleptris.so +0 -0
- data/rakelib/audit_artifacts.rb +59 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +26 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +80 -1
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +20 -6
- data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +2 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/ns_collision/d.xsd +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/ns_collision/w.xsd +11 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/ns_import_attrs/r.xsd +6 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/ns_import_attrs/w.xsd +9 -0
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +54 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +7 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7570686625e9dbcc29e988a0b4e90485bebf4e6c7ca5a423c39821ae2aea63a2
|
|
4
|
+
data.tar.gz: f5d976f0074d7b24d8dee68ae852398436f876f404c86c829b0266c69b2ddee0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d95a9493eb0109fd95f65a6ea9767085a73223a14aacba0098d07bcee780263a19dffdf496a0c1afbbea5edc2e9b26e8de9016dd0c5aaf8c2a8ef8fd36688368
|
|
7
|
+
data.tar.gz: 7c5864afd4d492716fd78e584f3747d5fd67c0f2c79acbc0c3f22ddf817efcbb4fee258a25d08f6cd2f43bf22ff66958740de2adedf2c622af96457a78c45748
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
## [1.9.345.1] - 2026-10-12
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **TODO.final/04 gates — shipped-artifact codesign + artifact/
|
|
6
|
+
version sync (#388)**: `rake audit:artifacts` (darwin) fails on
|
|
7
|
+
an unsigned/tampered vendored macOS artifact (`codesign
|
|
8
|
+
--verify --strict` against the CURRENT bytes) and on
|
|
9
|
+
engine-version drift (the vendored library's
|
|
10
|
+
`leptris_version()` must equal the Rakefile pin — a half-bumped
|
|
11
|
+
lockstep state can no longer package; the drift path proved
|
|
12
|
+
itself live during development). The darwin platform-gem builds
|
|
13
|
+
ad-hoc sign as the last pre-package step (audit:artifacts
|
|
14
|
+
between compile and pack). Negative proof in
|
|
15
|
+
spec/audit_codesign_spec.rb: flipped-byte and
|
|
16
|
+
stripped-signature copies fail the strict gate; the version
|
|
17
|
+
gate flags drift and accepts the pin.
|
|
18
|
+
|
|
19
|
+
## [1.9.345.0] - 2026-10-12
|
|
20
|
+
|
|
21
|
+
### Fixed — engine sync (libleptris 1.9.345)
|
|
22
|
+
|
|
23
|
+
- **Namespace-keyed lookups in the merged-import schema (#439,
|
|
24
|
+
#440, leptris#1663/#1665)**: the import/include merge flattened
|
|
25
|
+
declarations into one name-keyed table, and OOXML declares the
|
|
26
|
+
same names across namespaces (wml CT_TcPr vs dml, dml's
|
|
27
|
+
particles vs wml's), so validation resolved to the wrong unit's
|
|
28
|
+
declarations — hundreds of false content-model errors per real
|
|
29
|
+
document (#440's tr/tc/tcPr cascade was dml CT_TableRow
|
|
30
|
+
semantics applied to a wordprocessing table) and the r:id
|
|
31
|
+
"not declared (strict)" false positive (#439). Declarations
|
|
32
|
+
carry their declaring targetNamespace; foreign-namespace
|
|
33
|
+
fallback is forbidden once a resolving namespace is in hand.
|
|
34
|
+
Verified against the real wml.xsd: both reported documents
|
|
35
|
+
validate CLEAN. Pinned: cross-namespace same-name resolution
|
|
36
|
+
and imported-attribute (r:id) shapes.
|
|
37
|
+
|
|
1
38
|
## [1.9.344.0] - 2026-10-12
|
|
2
39
|
|
|
3
40
|
### Fixed — engine sync (libleptris 1.9.343-1.9.344)
|
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.345"
|
|
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
|
|
@@ -404,6 +404,45 @@ namespace :audit do
|
|
|
404
404
|
end
|
|
405
405
|
end
|
|
406
406
|
|
|
407
|
+
# TODO.final/04: shipped-macOS-artifact gates — (a) the
|
|
408
|
+
# embedded signature verifies strictly against the CURRENT
|
|
409
|
+
# bytes (a copy/strip/recompress in packaging invalidates the
|
|
410
|
+
# linker's ad-hoc signature and this fails instead of a user
|
|
411
|
+
# machine's dlopen), (b) the vendored library's
|
|
412
|
+
# leptris_version() equals the gem's engine pin (a half-bumped
|
|
413
|
+
# lockstep state can no longer package). Negative proof lives
|
|
414
|
+
# in spec/audit_codesign_spec.rb.
|
|
415
|
+
desc "Fail on unsigned/tampered macOS artifacts or engine-version drift"
|
|
416
|
+
task :artifacts do
|
|
417
|
+
unless RUBY_PLATFORM =~ /darwin/
|
|
418
|
+
puts "audit:artifacts: skipped off-darwin (codesign gates " \
|
|
419
|
+
"the macOS packaging legs)"
|
|
420
|
+
next
|
|
421
|
+
end
|
|
422
|
+
abort "audit:artifacts: codesign unavailable" \
|
|
423
|
+
unless AuditArtifacts.codesign_available?
|
|
424
|
+
libs = AuditArtifacts.darwin_artifacts.select { |f| File.file?(f) }
|
|
425
|
+
abort "audit:artifacts: no vendored macOS artifacts found " \
|
|
426
|
+
"— run rake compile" if libs.empty?
|
|
427
|
+
libs.each do |lib|
|
|
428
|
+
unless AuditArtifacts.signature_ok?(lib)
|
|
429
|
+
abort "audit:artifacts: signature invalid or missing on " \
|
|
430
|
+
"#{lib} — ad-hoc sign before packaging"
|
|
431
|
+
end
|
|
432
|
+
end
|
|
433
|
+
main_lib = libs.find { |f| f.end_with?("libleptris.dylib") }
|
|
434
|
+
pinned = ENV.fetch("LIBLEPTRIS_VERSION", LIBLEPTRIS_VERSION)
|
|
435
|
+
unless AuditArtifacts.version_synced?(
|
|
436
|
+
main_lib, File.dirname(main_lib), pinned)
|
|
437
|
+
vendored = AuditArtifacts.vendored_version(
|
|
438
|
+
main_lib, File.dirname(main_lib))
|
|
439
|
+
abort "audit:artifacts: engine-version drift — vendored " \
|
|
440
|
+
"#{vendored.inspect} != pin #{pinned.inspect}"
|
|
441
|
+
end
|
|
442
|
+
puts "audit:artifacts: #{libs.size} macOS artifacts verify " \
|
|
443
|
+
"strictly and engine-synced (#{pinned})"
|
|
444
|
+
end
|
|
445
|
+
|
|
407
446
|
# Packaging doctrine (#271): every BUILT gem carries the engine
|
|
408
447
|
# source (vendor-src/libleptris build inputs) and the ext sources;
|
|
409
448
|
# platform gems additionally carry the prebuilt libraries and must
|
|
@@ -453,6 +492,8 @@ namespace :audit do
|
|
|
453
492
|
end
|
|
454
493
|
|
|
455
494
|
require "rubygems/package_task"
|
|
495
|
+
require_relative "rakelib/audit_artifacts"
|
|
496
|
+
require "open3"
|
|
456
497
|
|
|
457
498
|
desc "Build the pure-Ruby gem"
|
|
458
499
|
task "gem:native:any" do
|
|
@@ -499,7 +540,16 @@ platforms = [
|
|
|
499
540
|
platforms.each do |platform|
|
|
500
541
|
desc "Build pre-compiled gem for the #{platform} platform"
|
|
501
542
|
task "gem:native:#{platform}" do
|
|
502
|
-
|
|
543
|
+
if platform.end_with?("darwin")
|
|
544
|
+
# TODO.final/04: ad-hoc sign as the LAST step before the
|
|
545
|
+
# packager touches nothing else — the signature must cover
|
|
546
|
+
# the final bytes, and audit:artifacts verifies strictly.
|
|
547
|
+
sh "rake compile platform:#{platform}"
|
|
548
|
+
sh "rake audit:artifacts"
|
|
549
|
+
sh "rake platform:#{platform} gem"
|
|
550
|
+
else
|
|
551
|
+
sh "rake compile platform:#{platform} gem"
|
|
552
|
+
end
|
|
503
553
|
end
|
|
504
554
|
|
|
505
555
|
desc "Define the gem task to build on the #{platform} platform (binary gem)"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# 04 — native-bundle codesign (macOS 14.1+) + artifact/version sync
|
|
2
|
+
|
|
3
|
+
Status: OPEN. Owner: this binding's owning session. Filed from the
|
|
4
|
+
engine-side investigation 2026-10-06 (leptris session); applies to
|
|
5
|
+
every `*-ruby` binding that ships prebuilt native artifacts.
|
|
6
|
+
|
|
7
|
+
## Problem
|
|
8
|
+
|
|
9
|
+
macOS 14.1+ on Apple Silicon kills unsigned or signature-invalidated
|
|
10
|
+
arm64 Mach-O libraries at load (`killed: 9`). CI-built arm64 dylibs
|
|
11
|
+
are linker-ad-hoc-signed, but any packaging step that COPIES or
|
|
12
|
+
re-compresses the artifact can strip/invalidate the ad-hoc
|
|
13
|
+
signature, and a prebuilt gem that installs an unsigned dylib then
|
|
14
|
+
fails at `dlopen` on user machines. Nothing in the current
|
|
15
|
+
packaging or audit path checks this.
|
|
16
|
+
|
|
17
|
+
## Work items
|
|
18
|
+
|
|
19
|
+
1. **Ad-hoc codesign at package time.** For every vendored macOS
|
|
20
|
+
arm64 (and universal) library the gem ships:
|
|
21
|
+
`codesign --force --sign - <lib>` as the LAST packaging step
|
|
22
|
+
(after any copy/strip/recompress), so the signature always
|
|
23
|
+
covers the final bytes. No Apple Developer identity is needed —
|
|
24
|
+
ad-hoc is sufficient for load validation.
|
|
25
|
+
2. **Verify in the audit gate.** Extend the existing
|
|
26
|
+
`rake audit` (the vendor-artifact validator: rake compile +
|
|
27
|
+
audit:symbols + CI) with `codesign --verify --strict` per
|
|
28
|
+
macOS library, so a tampered or unsigned artifact FAILS the
|
|
29
|
+
gate instead of a user machine.
|
|
30
|
+
3. **Artifact/version sync.** At package time (and in audit),
|
|
31
|
+
assert the vendored library's engine version —
|
|
32
|
+
`<engine>_version()` / the dylib's reported version — equals
|
|
33
|
+
the gem's pinned engine version. This closes the manual-pin
|
|
34
|
+
loop: a half-bumped lockstep release can no longer package.
|
|
35
|
+
|
|
36
|
+
## Acceptance
|
|
37
|
+
|
|
38
|
+
- Packaging workflow signs every macOS library it produces.
|
|
39
|
+
- Audit fails on (a) an unsigned/tampered macOS library, (b) a
|
|
40
|
+
vendored library whose version != the gem's engine pin.
|
|
41
|
+
- A deliberate negative test (unsigned copy) proves both gates.
|
|
42
|
+
|
|
43
|
+
## Notes
|
|
44
|
+
|
|
45
|
+
- Vendored artifacts are swapped by CI ONLY (the standing law):
|
|
46
|
+
these gates run inside the packaging/audit workflows, not as
|
|
47
|
+
local shortcuts.
|
|
48
|
+
- Source-compiled installs are unaffected: clang ad-hoc signs the
|
|
49
|
+
freshly built extension on the user's machine.
|
|
50
|
+
- Engine-side context: leptris/leptris session notes 2026-10-06;
|
|
51
|
+
the item is engine-family-wide (l/t/y bindings carry it too).
|
data/lib/leptris/version.rb
CHANGED
data/lib/libleptris.so
CHANGED
|
Binary file
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "open3"
|
|
4
|
+
require "rbconfig"
|
|
5
|
+
|
|
6
|
+
# TODO.final/04: the shipped-artifact gates. Required by
|
|
7
|
+
# Rakefile's audit:artifacts task and by the negative-proof specs
|
|
8
|
+
# (spec/audit_codesign_spec.rb). Not shipped in the gem — this is
|
|
9
|
+
# packaging/CI tooling.
|
|
10
|
+
module AuditArtifacts
|
|
11
|
+
module_function
|
|
12
|
+
|
|
13
|
+
# Every vendored macOS artifact the gem ships (the darwin
|
|
14
|
+
# packaging set, wherever it currently lives).
|
|
15
|
+
def darwin_artifacts
|
|
16
|
+
%w[
|
|
17
|
+
lib/libleptris.dylib
|
|
18
|
+
lib/libutf8proc.3.dylib
|
|
19
|
+
lib/leptris/xml/native.bundle
|
|
20
|
+
] + Dir.glob("lib/leptris/vendor/*-darwin/**/*.{dylib,bundle}")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# (a) tamper gate: --strict verifies the embedded signature
|
|
24
|
+
# covers the CURRENT bytes; a copy/strip/recompress invalidates
|
|
25
|
+
# it and this fails instead of a user machine's dlopen.
|
|
26
|
+
def signature_ok?(path)
|
|
27
|
+
system("codesign", "--verify", "--strict", path,
|
|
28
|
+
out: File::NULL, err: File::NULL)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def codesign_available?
|
|
32
|
+
# codesign has no --version; `which`-style probe via -h
|
|
33
|
+
# (exit 1 with usage output still proves the binary exists —
|
|
34
|
+
# ENOENT returns nil).
|
|
35
|
+
!system("codesign", "-h", out: File::NULL, err: File::NULL).nil?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# (b) artifact/version sync: the vendored library's own
|
|
39
|
+
# leptris_version() must equal the Rakefile's engine pin — a
|
|
40
|
+
# half-bumped lockstep state can no longer package. Runs the
|
|
41
|
+
# vendored library in an isolated interpreter (no gem load).
|
|
42
|
+
def vendored_version(lib, lib_dir)
|
|
43
|
+
env = { "LEPTRIS_LIB_PATH" => lib,
|
|
44
|
+
"DYLD_FALLBACK_LIBRARY_PATH" => lib_dir }
|
|
45
|
+
out, status = Open3.capture2e(env, RbConfig.ruby,
|
|
46
|
+
"-rffi", "-e",
|
|
47
|
+
'require "ffi"; ' \
|
|
48
|
+
'module V; extend FFI::Library; ' \
|
|
49
|
+
'ffi_lib ENV["LEPTRIS_LIB_PATH"]; ' \
|
|
50
|
+
'attach_function :v, :leptris_version, [], :string; end; ' \
|
|
51
|
+
'print V.v')
|
|
52
|
+
status.success? ? out.strip : nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def version_synced?(lib, lib_dir, pinned)
|
|
56
|
+
vendored = vendored_version(lib, lib_dir)
|
|
57
|
+
!vendored.nil? && vendored == pinned
|
|
58
|
+
end
|
|
59
|
+
end
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.345] - 2026-10-12
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **XSD: namespace-keyed lookups in the merged-import schema
|
|
8
|
+
(leptris-ruby#440, leptris-ruby#439, PR #1665).** The
|
|
9
|
+
import/include merge flattened every unit's declarations
|
|
10
|
+
into one name-keyed table - and OOXML declares the same
|
|
11
|
+
names across namespaces (wml CT_TcPr vs dml CT_TcPr, dml's
|
|
12
|
+
global tcPr/tbl elements vs wml's local particles), so
|
|
13
|
+
validation resolved to the wrong unit's declarations:
|
|
14
|
+
hundreds of false content-model errors per real document
|
|
15
|
+
(#440's tcPr/tcW and tblBorders shapes) and the r:id
|
|
16
|
+
"not declared (strict)" false positive (#439).
|
|
17
|
+
Declarations now carry their declaring targetNamespace
|
|
18
|
+
(threaded per-file through the include/import recursion;
|
|
19
|
+
chameleon includes adopt the includer's) and every lookup
|
|
20
|
+
keys by (ns, name) - a foreign-namespace fallback is
|
|
21
|
+
forbidden once a resolving namespace is in hand. Verified
|
|
22
|
+
against the real wml.xsd: both #440 repro documents and the
|
|
23
|
+
#439 headerReference r:id document validate with 0 errors
|
|
24
|
+
(Nokogiri parity). Red-first specs with checked-in
|
|
25
|
+
ns_collision/ and ns_import_attrs/ fixtures. Full suite
|
|
26
|
+
1988/1988.
|
|
27
|
+
|
|
28
|
+
|
|
3
29
|
## [1.9.344] - 2026-10-12
|
|
4
30
|
|
|
5
31
|
### Fixed
|
|
@@ -75,6 +75,8 @@ static XsdCm* xsd_cm_parse(struct leptris_xsd_schema* s,
|
|
|
75
75
|
static XsdAttrDecl* xsd_capture_attr_rows(struct leptris_xsd_schema* s,
|
|
76
76
|
LeptrisElement container,
|
|
77
77
|
int depth);
|
|
78
|
+
XsdCm* xsd_find_complex_ns(struct leptris_xsd_schema* s,
|
|
79
|
+
const char* type_name, const char* uri);
|
|
78
80
|
extern XsdCm* xsd_find_complex(struct leptris_xsd_schema* s,
|
|
79
81
|
const char* type_name);
|
|
80
82
|
extern const XsdTypeAttrs* xsd_find_type_attrs(
|
|
@@ -831,9 +833,18 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
831
833
|
strcmp(tns, s->target_ns) == 0);
|
|
832
834
|
if (subroot &&
|
|
833
835
|
(strcmp(local, "import") == 0 || same_ns)) {
|
|
836
|
+
/* leptris-ruby#440/#439: each captured
|
|
837
|
+
* unit stamps ITS OWN targetNamespace on
|
|
838
|
+
* its declarations — chameleon includes
|
|
839
|
+
* (no tns) adopt the includer's. */
|
|
840
|
+
char* saved_ns = s->target_ns;
|
|
841
|
+
char* sub_ns = tns ? xsd_strdup(tns) : NULL;
|
|
842
|
+
if (sub_ns) s->target_ns = sub_ns;
|
|
834
843
|
s->include_depth++;
|
|
835
844
|
xsd_capture_root(s, subroot);
|
|
836
845
|
s->include_depth--;
|
|
846
|
+
if (sub_ns) free(sub_ns);
|
|
847
|
+
s->target_ns = saved_ns;
|
|
837
848
|
}
|
|
838
849
|
leptris_document_free(sub);
|
|
839
850
|
}
|
|
@@ -853,6 +864,7 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
853
864
|
(XsdElementDecl*)calloc(1, sizeof(*d));
|
|
854
865
|
if (d) {
|
|
855
866
|
d->name = xsd_strdup(nm);
|
|
867
|
+
if (s->target_ns) d->ns = xsd_strdup(s->target_ns);
|
|
856
868
|
d->type = xsd_strdup(xsd_local_name(ty));
|
|
857
869
|
xsd_capture_alternatives(s, (LeptrisElement)n, d);
|
|
858
870
|
d->fixed = xsd_strdup(
|
|
@@ -881,6 +893,7 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
881
893
|
(XsdElementDecl*)calloc(1, sizeof(*d));
|
|
882
894
|
if (d) {
|
|
883
895
|
d->name = xsd_strdup(nm);
|
|
896
|
+
if (s->target_ns) d->ns = xsd_strdup(s->target_ns);
|
|
884
897
|
d->type = xsd_strdup(synth);
|
|
885
898
|
d->next = s->elements;
|
|
886
899
|
s->elements = d;
|
|
@@ -1026,6 +1039,7 @@ LEPTRIS_API void leptris_xsd_free(LeptrisXsdSchema schema) {
|
|
|
1026
1039
|
XsdTypeAttrs* ta = s->type_attrs;
|
|
1027
1040
|
while (ta) {
|
|
1028
1041
|
XsdTypeAttrs* tn = ta->next;
|
|
1042
|
+
free(ta->ns);
|
|
1029
1043
|
XsdAttrDecl* a = ta->attrs;
|
|
1030
1044
|
while (a) {
|
|
1031
1045
|
XsdAttrDecl* an = a->next;
|
|
@@ -1043,6 +1057,7 @@ LEPTRIS_API void leptris_xsd_free(LeptrisXsdSchema schema) {
|
|
|
1043
1057
|
XsdElementDecl* d = s->elements;
|
|
1044
1058
|
while (d) {
|
|
1045
1059
|
XsdElementDecl* dn = d->next;
|
|
1060
|
+
free(d->ns);
|
|
1046
1061
|
XsdAlternative* a = d->alternatives;
|
|
1047
1062
|
while (a) {
|
|
1048
1063
|
XsdAlternative* an = a->next;
|
|
@@ -1141,12 +1156,18 @@ static void xsd_register_complex(struct leptris_xsd_schema* s,
|
|
|
1141
1156
|
char* any_attr_ns) {
|
|
1142
1157
|
if (!root) return;
|
|
1143
1158
|
root->name = xsd_strdup(name);
|
|
1159
|
+
/* leptris-ruby#440: the DECLARING file's targetNamespace — the
|
|
1160
|
+
* merged-import schema is flat, so same-name types from
|
|
1161
|
+
* different namespaces (wml CT_TcPr vs dml CT_TcPr) resolve by
|
|
1162
|
+
* (ns, name). */
|
|
1163
|
+
if (s->target_ns) root->ns = xsd_strdup(s->target_ns);
|
|
1144
1164
|
root->next = s->complex_types;
|
|
1145
1165
|
s->complex_types = root;
|
|
1146
1166
|
if (attrs || any_attr_ns) {
|
|
1147
1167
|
XsdTypeAttrs* ta = (XsdTypeAttrs*)calloc(1, sizeof(*ta));
|
|
1148
1168
|
if (ta) {
|
|
1149
1169
|
ta->type_name = xsd_strdup(name);
|
|
1170
|
+
if (root->ns) ta->ns = xsd_strdup(root->ns);
|
|
1150
1171
|
ta->attrs = attrs;
|
|
1151
1172
|
ta->any_attr_ns = any_attr_ns;
|
|
1152
1173
|
ta->next = s->type_attrs;
|
|
@@ -1282,7 +1303,7 @@ static XsdCm* xsd_capture_complex_model(struct leptris_xsd_schema* s,
|
|
|
1282
1303
|
const char* base = xsd_local_name(base_raw);
|
|
1283
1304
|
XsdCm* base_root =
|
|
1284
1305
|
(base && strncmp(base, "xs:", 3) != 0)
|
|
1285
|
-
?
|
|
1306
|
+
? xsd_find_complex_ns(s, base, s->target_ns)
|
|
1286
1307
|
: NULL;
|
|
1287
1308
|
if (strcmp(dl, "extension") == 0) {
|
|
1288
1309
|
/* base content first, derived content after */
|
|
@@ -1814,6 +1835,23 @@ const XsdElementDecl* xsd_find_element(struct leptris_xsd_schema* s,
|
|
|
1814
1835
|
return NULL;
|
|
1815
1836
|
}
|
|
1816
1837
|
|
|
1838
|
+
/* leptris-ruby#440: prefer (ns, name); fall back to any match. */
|
|
1839
|
+
const XsdElementDecl* xsd_find_element_ns(
|
|
1840
|
+
struct leptris_xsd_schema* s, const char* name, const char* uri) {
|
|
1841
|
+
if (!s || !name) return NULL;
|
|
1842
|
+
if (uri && uri[0]) {
|
|
1843
|
+
for (XsdElementDecl* d = s->elements; d; d = d->next)
|
|
1844
|
+
if (d->ns && strcmp(d->name, name) == 0 &&
|
|
1845
|
+
strcmp(d->ns, uri) == 0)
|
|
1846
|
+
return d;
|
|
1847
|
+
for (XsdElementDecl* d = s->elements; d; d = d->next)
|
|
1848
|
+
if (!d->ns && strcmp(d->name, name) == 0)
|
|
1849
|
+
return d;
|
|
1850
|
+
return NULL;
|
|
1851
|
+
}
|
|
1852
|
+
return xsd_find_element(s, name);
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1817
1855
|
XsdCm* xsd_find_complex(struct leptris_xsd_schema* s,
|
|
1818
1856
|
const char* type_name) {
|
|
1819
1857
|
if (!s || !type_name) return NULL;
|
|
@@ -1822,6 +1860,30 @@ XsdCm* xsd_find_complex(struct leptris_xsd_schema* s,
|
|
|
1822
1860
|
return NULL;
|
|
1823
1861
|
}
|
|
1824
1862
|
|
|
1863
|
+
/* leptris-ruby#440: prefer the (ns, name) exact match — the flat
|
|
1864
|
+
* merged list carries same-name types from every imported
|
|
1865
|
+
* namespace. Falls back to name-only (single-namespace schemas
|
|
1866
|
+
* and unresolvable contexts keep working). */
|
|
1867
|
+
XsdCm* xsd_find_complex_ns(struct leptris_xsd_schema* s,
|
|
1868
|
+
const char* type_name, const char* uri) {
|
|
1869
|
+
if (!s || !type_name) return NULL;
|
|
1870
|
+
if (uri && uri[0]) {
|
|
1871
|
+
for (XsdCm* c = s->complex_types; c; c = c->next)
|
|
1872
|
+
if (c->ns && strcmp(c->name, type_name) == 0 &&
|
|
1873
|
+
strcmp(c->ns, uri) == 0)
|
|
1874
|
+
return c;
|
|
1875
|
+
/* A resolving namespace is in hand: a DIFFERENT
|
|
1876
|
+
* namespace's same-name decl must NOT win (wml CT_TcPr vs
|
|
1877
|
+
* dml CT_TcPr — leptris-ruby#440). Only an unstamped
|
|
1878
|
+
* (unknown-ns) entry may serve as the fallback. */
|
|
1879
|
+
for (XsdCm* c = s->complex_types; c; c = c->next)
|
|
1880
|
+
if (!c->ns && strcmp(c->name, type_name) == 0)
|
|
1881
|
+
return c;
|
|
1882
|
+
return NULL;
|
|
1883
|
+
}
|
|
1884
|
+
return xsd_find_complex(s, type_name);
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1825
1887
|
const XsdSimple* xsd_find_simple_pub(struct leptris_xsd_schema* s,
|
|
1826
1888
|
const char* name) {
|
|
1827
1889
|
return xsd_find_simple(s, name);
|
|
@@ -1839,6 +1901,23 @@ const XsdTypeAttrs* xsd_find_type_attrs(struct leptris_xsd_schema* s,
|
|
|
1839
1901
|
return NULL;
|
|
1840
1902
|
}
|
|
1841
1903
|
|
|
1904
|
+
const XsdTypeAttrs* xsd_find_type_attrs_ns(
|
|
1905
|
+
struct leptris_xsd_schema* s, const char* type_name,
|
|
1906
|
+
const char* uri) {
|
|
1907
|
+
if (!s || !type_name) return NULL;
|
|
1908
|
+
if (uri && uri[0]) {
|
|
1909
|
+
for (XsdTypeAttrs* t = s->type_attrs; t; t = t->next)
|
|
1910
|
+
if (t->ns && strcmp(t->type_name, type_name) == 0 &&
|
|
1911
|
+
strcmp(t->ns, uri) == 0)
|
|
1912
|
+
return t;
|
|
1913
|
+
for (XsdTypeAttrs* t = s->type_attrs; t; t = t->next)
|
|
1914
|
+
if (!t->ns && strcmp(t->type_name, type_name) == 0)
|
|
1915
|
+
return t;
|
|
1916
|
+
return NULL;
|
|
1917
|
+
}
|
|
1918
|
+
return xsd_find_type_attrs(s, type_name);
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1842
1921
|
/* ---- slice 4: instance validation (validate.c engine) ------------ */
|
|
1843
1922
|
|
|
1844
1923
|
LEPTRIS_API int leptris_xsd_validate(LeptrisXsdSchema schema,
|
|
@@ -33,13 +33,18 @@ struct leptris_xsd_schema; /* opaque here; compile.c owns the struct */
|
|
|
33
33
|
|
|
34
34
|
/* The validator reaches the compiled model through accessors the
|
|
35
35
|
* compiler exports (compile.c defines the struct). */
|
|
36
|
+
extern const XsdElementDecl* xsd_find_element_ns(
|
|
37
|
+
struct leptris_xsd_schema* s, const char* name, const char* uri);
|
|
36
38
|
extern const XsdElementDecl* xsd_find_element(
|
|
37
39
|
struct leptris_xsd_schema* s, const char* name);
|
|
38
|
-
extern XsdCm*
|
|
39
|
-
|
|
40
|
+
extern XsdCm* xsd_find_complex_ns(struct leptris_xsd_schema* s,
|
|
41
|
+
const char* type_name, const char* uri);
|
|
42
|
+
XsdCm* xsd_find_complex(struct leptris_xsd_schema* s, const char* type_name);
|
|
40
43
|
extern const XsdSimple* xsd_find_simple_pub(
|
|
41
44
|
struct leptris_xsd_schema* s, const char* name);
|
|
42
45
|
extern const char* xsd_target_ns(struct leptris_xsd_schema* s);
|
|
46
|
+
extern const XsdTypeAttrs* xsd_find_type_attrs_ns(
|
|
47
|
+
struct leptris_xsd_schema* s, const char* name, const char* uri);
|
|
43
48
|
extern const XsdTypeAttrs* xsd_find_type_attrs(
|
|
44
49
|
struct leptris_xsd_schema* s, const char* type_name);
|
|
45
50
|
extern const XsdElementIcs* xsd_find_element_ics(
|
|
@@ -309,7 +314,7 @@ static void validate_children(struct xsd_validator* v,
|
|
|
309
314
|
const char* cl = NULL, *cp = NULL, *cu = NULL;
|
|
310
315
|
leptris_element_expanded_name(ce, &cl, &cp, &cu);
|
|
311
316
|
if (!cl) continue;
|
|
312
|
-
if (
|
|
317
|
+
if (xsd_find_element_ns(s, cl, cu)) {
|
|
313
318
|
validate_element(v, s, ce, 0);
|
|
314
319
|
continue;
|
|
315
320
|
}
|
|
@@ -466,7 +471,9 @@ static void validate_element(struct xsd_validator* v,
|
|
|
466
471
|
const char* local = NULL, *prefix = NULL, *uri = NULL;
|
|
467
472
|
leptris_element_expanded_name(elem, &local, &prefix, &uri);
|
|
468
473
|
if (!local) return;
|
|
469
|
-
const
|
|
474
|
+
const char* guri = NULL;
|
|
475
|
+
leptris_element_expanded_name(elem, NULL, NULL, &guri);
|
|
476
|
+
const XsdElementDecl* d = xsd_find_element_ns(s, local, guri);
|
|
470
477
|
if (!d) {
|
|
471
478
|
/* strict: the instance uses an element the schema never
|
|
472
479
|
* declared (a local particle would have typed it) */
|
|
@@ -510,9 +517,16 @@ static void validate_local(struct xsd_validator* v,
|
|
|
510
517
|
LeptrisElement elem, const char* local,
|
|
511
518
|
const char* type) {
|
|
512
519
|
if (!type) return;
|
|
513
|
-
|
|
520
|
+
/* leptris-ruby#440: resolve the type in the ELEMENT's
|
|
521
|
+
* namespace — the merged-import schema carries same-name types
|
|
522
|
+
* from every imported namespace. */
|
|
523
|
+
const char* euri = NULL;
|
|
524
|
+
leptris_element_expanded_name(elem, NULL, NULL, &euri);
|
|
525
|
+
XsdCm* ct = xsd_find_complex_ns(s, type, euri);
|
|
514
526
|
if (ct) {
|
|
515
|
-
validate_attributes(
|
|
527
|
+
validate_attributes(
|
|
528
|
+
v, s, elem,
|
|
529
|
+
xsd_find_type_attrs_ns(s, type, euri));
|
|
516
530
|
validate_children(v, s, elem, ct);
|
|
517
531
|
/* XSD 1.1: the type's xs:assert list — context is the
|
|
518
532
|
* element; evaluation errors are failures */
|
|
@@ -138,6 +138,7 @@ typedef struct xsd_alternative {
|
|
|
138
138
|
/* A top-level xs:element declaration (slice 3: name + type ref). */
|
|
139
139
|
typedef struct xsd_element_decl {
|
|
140
140
|
char* name;
|
|
141
|
+
char* ns; /* leptris-ruby#440: declaring schema's targetNamespace */
|
|
141
142
|
char* type; /* "xs:string"-style builtin or a local type name */
|
|
142
143
|
XsdAlternative* alternatives; /* XSD 1.1 conditional types */
|
|
143
144
|
char* fixed; /* fixed element content: text must string-equal it */
|
|
@@ -190,6 +191,7 @@ typedef struct xsd_attrgroup_def {
|
|
|
190
191
|
|
|
191
192
|
typedef struct xsd_type_attrs {
|
|
192
193
|
char* type_name;
|
|
194
|
+
char* ns; /* leptris-ruby#440: declaring schema's tns */
|
|
193
195
|
char* any_attr_ns; /* xs:anyAttribute grammar (NULL = absent) */
|
|
194
196
|
XsdAttrDecl* attrs;
|
|
195
197
|
struct xsd_type_attrs* next;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
2
|
+
targetNamespace="urn:d">
|
|
3
|
+
<!-- Same type/element NAMES as w.xsd, different namespace: the
|
|
4
|
+
merged-import compiler must resolve by (ns, name). -->
|
|
5
|
+
<xs:complexType name="CT_T">
|
|
6
|
+
<xs:sequence>
|
|
7
|
+
<xs:element name="dOnly1" minOccurs="0"/>
|
|
8
|
+
<xs:element name="dOnly2" minOccurs="0"/>
|
|
9
|
+
</xs:sequence>
|
|
10
|
+
</xs:complexType>
|
|
11
|
+
<xs:element name="r" type="CT_T"/>
|
|
12
|
+
</xs:schema>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
2
|
+
xmlns:d="urn:d" targetNamespace="urn:w">
|
|
3
|
+
<xs:import namespace="urn:d" schemaLocation="d.xsd"/>
|
|
4
|
+
<xs:complexType name="CT_T">
|
|
5
|
+
<xs:sequence>
|
|
6
|
+
<xs:element name="wOnly" minOccurs="0"/>
|
|
7
|
+
<xs:element name="tcPr" minOccurs="0"/>
|
|
8
|
+
</xs:sequence>
|
|
9
|
+
</xs:complexType>
|
|
10
|
+
<xs:element name="r" type="CT_T"/>
|
|
11
|
+
</xs:schema>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
2
|
+
xmlns:r="urn:r" targetNamespace="urn:w">
|
|
3
|
+
<xs:import namespace="urn:r" schemaLocation="r.xsd"/>
|
|
4
|
+
<xs:complexType name="CT_Ref">
|
|
5
|
+
<xs:attribute ref="r:id" use="optional"/>
|
|
6
|
+
<xs:attribute name="kind" type="xs:string" use="required"/>
|
|
7
|
+
</xs:complexType>
|
|
8
|
+
<xs:element name="ref" type="CT_Ref"/>
|
|
9
|
+
</xs:schema>
|
|
@@ -167,6 +167,60 @@ TEST(XsdCompile, ImportDagCapturesEachUnitOnce) {
|
|
|
167
167
|
leptris_xsd_free(s);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
// leptris-ruby#440/#439: the merged-import schema is FLAT, so
|
|
171
|
+
// same-name declarations from different namespaces collide. Every
|
|
172
|
+
// lookup must key by (declaring targetNamespace, name) — a
|
|
173
|
+
// resolving namespace in hand forbids a foreign-namespace fallback
|
|
174
|
+
// (wml's CT_TcPr vs dml's, dml's global tcPr element hijacking
|
|
175
|
+
// wml's local particle, r:id resolved through the import).
|
|
176
|
+
TEST(XsdCompile, SameNameTypesAcrossImportsResolveByNamespace) {
|
|
177
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
178
|
+
LeptrisXsdSchema s = leptris_xsd_compile_file(
|
|
179
|
+
LEPTRIS_XSD_CASES_DIR "/ns_collision/w.xsd", &st);
|
|
180
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0) << "status " << (int)st;
|
|
181
|
+
const char doc[] =
|
|
182
|
+
"<w:r xmlns:w=\"urn:w\"><w:tcPr/></w:r>";
|
|
183
|
+
LeptrisDocument d = leptris_parse_string(doc, strlen(doc), &st);
|
|
184
|
+
ASSERT_NE(d, nullptr);
|
|
185
|
+
// w's CT_T carries tcPr; d's same-name CT_T carries dOnly1/2 —
|
|
186
|
+
// a cross-namespace mis-resolution rejects this document.
|
|
187
|
+
EXPECT_EQ(leptris_xsd_validate(s, d), 1);
|
|
188
|
+
leptris_document_free(d);
|
|
189
|
+
// The d-namespace element resolves against d's model.
|
|
190
|
+
const char ddoc[] = "<d:r xmlns:d=\"urn:d\"><d:dOnly1/></d:r>";
|
|
191
|
+
LeptrisDocument dd = leptris_parse_string(ddoc, strlen(ddoc), &st);
|
|
192
|
+
ASSERT_NE(dd, nullptr);
|
|
193
|
+
EXPECT_EQ(leptris_xsd_validate(s, dd), 1);
|
|
194
|
+
leptris_document_free(dd);
|
|
195
|
+
leptris_xsd_free(s);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
TEST(XsdCompile, QualifiedAttrFromImportedNamespaceValidates) {
|
|
199
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
200
|
+
LeptrisXsdSchema s = leptris_xsd_compile_file(
|
|
201
|
+
LEPTRIS_XSD_CASES_DIR "/ns_import_attrs/w.xsd", &st);
|
|
202
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0) << "status " << (int)st;
|
|
203
|
+
// r:id resolved through the import; kind required by w's own
|
|
204
|
+
// attribute row.
|
|
205
|
+
const char doc[] =
|
|
206
|
+
"<w:ref xmlns:w=\"urn:w\" xmlns:r=\"urn:r\""
|
|
207
|
+
" r:id=\"rId6\" kind=\"even\"/>";
|
|
208
|
+
LeptrisDocument d = leptris_parse_string(doc, strlen(doc), &st);
|
|
209
|
+
ASSERT_NE(d, nullptr);
|
|
210
|
+
EXPECT_EQ(leptris_xsd_validate(s, d), 1);
|
|
211
|
+
leptris_document_free(d);
|
|
212
|
+
// Negative control: an undeclared qualified attribute still
|
|
213
|
+
// fails strict.
|
|
214
|
+
const char bad[] =
|
|
215
|
+
"<w:ref xmlns:w=\"urn:w\" xmlns:r=\"urn:r\""
|
|
216
|
+
" r:undeclared=\"x\" kind=\"even\"/>";
|
|
217
|
+
LeptrisDocument b = leptris_parse_string(bad, strlen(bad), &st);
|
|
218
|
+
ASSERT_NE(b, nullptr);
|
|
219
|
+
EXPECT_EQ(leptris_xsd_validate(s, b), 0);
|
|
220
|
+
leptris_document_free(b);
|
|
221
|
+
leptris_xsd_free(s);
|
|
222
|
+
}
|
|
223
|
+
|
|
170
224
|
// leptris-ruby#434: the length family counts OCTETS for binary
|
|
171
225
|
// bases (XML Schema Part 2: hexBinary/base64Binary length is in
|
|
172
226
|
// bytes) — the wml ST_LongHexNumber shape (hexBinary + length 4)
|
|
@@ -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.345",
|
|
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.345.1
|
|
5
5
|
platform: ppc64le-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -69,6 +69,7 @@ files:
|
|
|
69
69
|
- LICENSE.md
|
|
70
70
|
- README.adoc
|
|
71
71
|
- Rakefile
|
|
72
|
+
- TODO.final/04-native-bundle-codesign-artifact-sync.md
|
|
72
73
|
- TODO.perf/01-ext-accelerated-default-reads.md
|
|
73
74
|
- TODO.perf/02-auto-enable-native-layer.md
|
|
74
75
|
- TODO.perf/03-bulk-xpath-result-materialization.md
|
|
@@ -189,6 +190,7 @@ files:
|
|
|
189
190
|
- lib/leptris/xml/xslt.rb
|
|
190
191
|
- lib/libleptris.so
|
|
191
192
|
- lib/libutf8proc.so.3
|
|
193
|
+
- rakelib/audit_artifacts.rb
|
|
192
194
|
- scripts/gem_smoke.rb
|
|
193
195
|
- vendor-src/README.md
|
|
194
196
|
- vendor-src/libleptris/CHANGELOG.md
|
|
@@ -1374,6 +1376,10 @@ files:
|
|
|
1374
1376
|
- vendor-src/libleptris/test/xsd/libxml2-cases/ns1_0.xsd
|
|
1375
1377
|
- vendor-src/libleptris/test/xsd/libxml2-cases/ns2_0.xml
|
|
1376
1378
|
- vendor-src/libleptris/test/xsd/libxml2-cases/ns2_0.xsd
|
|
1379
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/ns_collision/d.xsd
|
|
1380
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/ns_collision/w.xsd
|
|
1381
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/ns_import_attrs/r.xsd
|
|
1382
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/ns_import_attrs/w.xsd
|
|
1377
1383
|
- vendor-src/libleptris/test/xsd/libxml2-cases/nvdcve_0.xml
|
|
1378
1384
|
- vendor-src/libleptris/test/xsd/libxml2-cases/nvdcve_0.xsd
|
|
1379
1385
|
- vendor-src/libleptris/test/xsd/libxml2-cases/oss-fuzz-51295_0.xml
|