canon 0.3.47 → 0.3.48

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: 8180f10b0965070c408985ca44868fc14ae2256f24dac607492470aea7e5d076
4
- data.tar.gz: e50498b713b972237a67af3b3f5c2cd5fb0cf1cbc3fef0dbb57f628810ce2341
3
+ metadata.gz: fcfa53c5436e38941e6c789536bf9c268fb5b587930aeaca6020c22993def0a2
4
+ data.tar.gz: a814221d4dd934e35f8f6eb1169f8694fadf2e2fd60e49a9f8f61e6355ff9853
5
5
  SHA512:
6
- metadata.gz: 52c5eb3fcb8ab3e09c7de5b8b7120f2baad191467aeccab6154254cd0007128f76ae2f5dbd26102abf19c3cf9f289f3c0445db88917562d7b7edafe9aef7ae5b
7
- data.tar.gz: 373032bcba62f9685c41f09bb0d3dce294c50fa8785252e3737231a67f9a0fdfdb5372c85f3b28da5983faf39d4cdf89723dfae8397969511d2688afecaf3418
6
+ metadata.gz: 1ac2772108ab1d9cae92a479a98c94cbc02bff2a431a64e3dc9052ff4df5ec595a38c81849c3d9ddc1c1329b6a86bdfbb7d3aeae6b5bbacfa2d6d8d283acc0a6
7
+ data.tar.gz: 7794b9a9392eaa18bb43b85ec7a2e830d3c0f172bfd827e13b7e3f6290c82cb6b3491312090f8230671c1a7442e722a7c1b3d66a44398965b89ab4664ec11a4d
data/CLAUDE.md CHANGED
@@ -145,7 +145,7 @@ Engine A/B testing: `CANON_XML_BACKEND=nokogiri bundle exec rspec` (or `=moxml`
145
145
 
146
146
  ### C14N Engines
147
147
 
148
- `Canon::Xml::C14n.canonicalize` stays on canon's Ruby C14N 1.1 processor by default. leptris' native C-side C14N 1.1 is ~50x faster on large documents and byte-identical on the main corpus, but diverges from the spec on edge cases (attribute ordering, prefix preservation, `>`/tab escaping, document-level PIs leptris#1015, all pinned in `spec/canon/xml/c14n_engine_parity_spec.rb`). `CANON_C14N_BACKEND=leptris` opts in; when the parity gate runs clean the default flips. `canonicalize_subset` and `with_comments: true` always use the Ruby processor.
148
+ `Canon::Xml::C14n.canonicalize` uses leptris' native C-side C14N 1.1 by DEFAULT (since libleptris 1.9.178 / gem 1.9.178.0) 23x faster than the Ruby processor through canon's API (1MB document). The native parse runs `noblanks: true` (compact bytes, matching the Ruby lane's product), relative namespace URIs raise identically, and document-level PIs serialize in spec-correct document order (the Ruby processor's root-first order was non-conformant for prolog PIs). `CANON_C14N_BACKEND=ruby` forces the Ruby processor. `canonicalize_subset` and `with_comments: true` always use the Ruby processor. The parity spec (`spec/canon/xml/c14n_engine_parity_spec.rb`) pins byte-identity; its pending cases track intentional divergences (document-order PIs) and the canon-side CR-reference finding.
149
149
 
150
150
  ### YAML Engines
151
151
 
data/lib/canon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canon
4
- VERSION = "0.3.47"
4
+ VERSION = "0.3.48"
5
5
  end
@@ -23,39 +23,37 @@ module Canon
23
23
  end
24
24
 
25
25
  # leptris' C-side C14N 1.1 — 23x faster than the Ruby processor
26
- # through canon's own API (1MB document) and byte-identical on
27
- # the parity corpus, but OPT-IN (CANON_C14N_BACKEND=leptris)
28
- # pending three families verified against libxml2 ground truth
29
- # (leptris#1096 follow-up): (1) whitespace-only text between
30
- # elements is preserved the Ruby lane's parse drops it and
31
- # compact bytes are canon's product for every pretty-printed
32
- # document; (2) whitespace-only processing-instruction data is
33
- # retained (libxml2 drops it); (3) document-level nodes carry
34
- # no "\n" separators (the Ruby lane, like libxml2, inserts
35
- # them). libleptris 1.9.176/177 (gem 1.9.177.0) closed the
36
- # earlier families attribute ordering, prefix loss and
37
- # rebinding, `>`/TAB escaping, redundant namespace
38
- # redeclarations, xmlns:xml omission and document-level PIs
39
- # now serialize in document order (the Ruby processor's
40
- # root-first order is non-conformant for prolog PIs).
41
- # Relative namespace URIs raise exactly as the Ruby lane does.
42
- # Comments mode keeps the Ruby path (the native seam exposes no
43
- # with-comments form).
26
+ # through canon's own API (1MB document) and the DEFAULT lane
27
+ # since libleptris 1.9.178 (gem 1.9.178.0): the leptris#1117
28
+ # families are closed by the native parse-policy knob
29
+ # (`noblanks: true` same compact bytes as the Ruby lane's
30
+ # parse) and by the canonicalizer itself (whitespace-only PI
31
+ # data dropped, document-level "\n" separators inserted). The
32
+ # one residual byte difference vs the Ruby lane is intentional
33
+ # and a correctness improvement: document-level PIs now
34
+ # serialize in document order (REC-xml-c14n 2.1) instead of
35
+ # the Ruby lane's non-conformant root-first reorder. Relative
36
+ # namespace URIs raise exactly as the Ruby lane does.
37
+ # Comments mode keeps the Ruby path regardless (the native
38
+ # seam exposes no with-comments form). CANON_C14N_BACKEND=ruby
39
+ # forces the stdlib lane.
44
40
  def self.native_canonicalize(xml, with_comments)
45
41
  return nil if with_comments
46
42
  return nil if RUBY_ENGINE == "opal"
47
- return nil unless ENV["CANON_C14N_BACKEND"].to_s.casecmp("leptris").zero?
43
+ return nil if ENV["CANON_C14N_BACKEND"].to_s.casecmp("ruby").zero?
48
44
  return nil unless Canon::XmlBackend.moxml? &&
49
45
  Canon::XmlParsing.moxml_adapter_name == :leptris
50
46
  return nil unless native_c14n_available?
51
47
 
52
48
  validate_relative_namespaces!(xml)
53
49
 
54
- doc = Canon::XmlParsing.moxml_context.parse(xml, readonly: true,
55
- strict: false)
50
+ doc = Canon::XmlParsing.moxml_context.parse(xml,
51
+ readonly: true,
52
+ strict: false,
53
+ noblanks: true)
56
54
  begin
57
- doc.native.canonicalize(::Leptris::XML::FFI::C14N_1_1, nil,
58
- mode: ::Leptris::XML::FFI::C14N_MODE_CANONICAL)
55
+ doc.native.c14n(::Leptris::XML::FFI::C14N_1_1, nil,
56
+ mode: ::Leptris::XML::FFI::C14N_MODE_CANONICAL)
59
57
  ensure
60
58
  doc.free
61
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.47
4
+ version: 0.3.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.