moxml 0.5.130 → 0.5.132
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/Gemfile +1 -1
- data/lib/moxml/adapter/leptris.rb +48 -7
- data/lib/moxml/builder.rb +79 -1
- data/lib/moxml/config.rb +6 -0
- data/lib/moxml/context.rb +5 -2
- data/lib/moxml/version.rb +1 -1
- data/spec/moxml/adapter/leptris_spec.rb +18 -5
- data/spec/moxml/builder_namespaces_spec.rb +95 -0
- data/spec/moxml/recover_mode_spec.rb +61 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e9c4fec61c2e21eec26368889b888c8cdf1b3c553161bafc0334861cef93529
|
|
4
|
+
data.tar.gz: 0d32dcd44ab21957f09078af75e147005d1da6a67a72a17626d488757c6a305c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d8da6f131247d4a9b61bc119e85ec19096bdc8769e35ec545f35da657d23556fb22b9d7b8e00c68684aa875a46134fb3d8845526d123f7d4379ef174ff70a8e
|
|
7
|
+
data.tar.gz: a8d0a826db5dd0de0febc05189048a86f7c23a2f8cb028395d6add3500f331b18d104498a1880c7e28e8786b81aab8beb2b9af8ae9e101b1c13755a3fdbe03ac
|
data/Gemfile
CHANGED
|
@@ -182,6 +182,18 @@ module Moxml
|
|
|
182
182
|
defined?(::Leptris::HTML) &&
|
|
183
183
|
::Leptris::HTML.respond_to?(:parse_fragment)
|
|
184
184
|
|
|
185
|
+
# The engine's recovery mode (moxml#369, engine leptris#1660
|
|
186
|
+
# via binding 1.9.344.0): non-strict parses pass recover:
|
|
187
|
+
# true and keep the best-effort tree (libxml2
|
|
188
|
+
# XML_PARSE_RECOVER semantics — mismatched closers close
|
|
189
|
+
# intermediates, unclosed elements close at EOF) instead of
|
|
190
|
+
# the rescue-to-empty fallback. The kwarg probe pairs the
|
|
191
|
+
# floor (a binding without the kwarg cannot arm).
|
|
192
|
+
RECOVER_MODE =
|
|
193
|
+
Gem::Version.new(::Leptris::VERSION) >= Gem::Version.new("1.9.344.0") &&
|
|
194
|
+
::Leptris::XML::ParseOptions.instance_method(:initialize)
|
|
195
|
+
.parameters.any? { |_, key| key == :recover }
|
|
196
|
+
|
|
185
197
|
# Markup-accumulating builder face (leptris-ruby#374 lever 2,
|
|
186
198
|
# binding 1.9.313): the DSL accumulates markup in a plain
|
|
187
199
|
# String and ONE native crossing (parse + attach) flushes the
|
|
@@ -1031,23 +1043,45 @@ module Moxml
|
|
|
1031
1043
|
# multi-pass consumers (comparison, diff, signature).
|
|
1032
1044
|
# dtdattr: true opts into DTD ATTLIST default materialization
|
|
1033
1045
|
# (off by default since libleptris 1.9.8, matching libxml2).
|
|
1046
|
+
# #369: non-strict parses RECOVER on engines that carry
|
|
1047
|
+
# the mode (1.9.344+) — the best-effort tree survives
|
|
1048
|
+
# recoverable structural errors (libxml2
|
|
1049
|
+
# XML_PARSE_RECOVER semantics). Strict callers never
|
|
1050
|
+
# recover: malformed input raises. Direct adapter calls
|
|
1051
|
+
# are caller-owned-options by contract (Context applies
|
|
1052
|
+
# config.strict_parsing; bypassing it means the caller
|
|
1053
|
+
# chose the mode).
|
|
1054
|
+
recover = !options[:strict] && RECOVER_MODE
|
|
1034
1055
|
native_doc = begin
|
|
1035
1056
|
::Leptris::XML::Document.parse(
|
|
1036
1057
|
processed,
|
|
1037
1058
|
readonly: options[:readonly] == true,
|
|
1038
|
-
options: parse_flags(options,
|
|
1059
|
+
options: parse_flags(options, recover: recover,
|
|
1060
|
+
context: _context),
|
|
1039
1061
|
)
|
|
1040
1062
|
rescue ::Leptris::XML::ParseError => e
|
|
1041
|
-
# libleptris has no recovery mode that survives unclosed
|
|
1042
|
-
# tags; non-strict callers get an empty document, matching
|
|
1043
|
-
# the Libxml adapter's non-strict behavior. The fatal
|
|
1044
|
-
# error rides the document as parse diagnostics (issue
|
|
1045
|
-
# #147) — otherwise nothing says why it came back empty.
|
|
1046
1063
|
raise Moxml::ParseError.new(e.message) if options[:strict]
|
|
1047
1064
|
|
|
1065
|
+
# Engines below the 1.9.344 recover floor (or the
|
|
1066
|
+
# residual unrecoverable edges, e.g. trailing content
|
|
1067
|
+
# after the root close) have no best-effort tree: the
|
|
1068
|
+
# empty-document fallback stands, with the fatal error
|
|
1069
|
+
# as parse diagnostics (issue #147) — otherwise nothing
|
|
1070
|
+
# says why it came back empty.
|
|
1048
1071
|
recover_errors = [e.message]
|
|
1049
1072
|
create_document
|
|
1050
1073
|
end
|
|
1074
|
+
if recover && native_doc.root.nil? && !recover_errors
|
|
1075
|
+
# The recover path answers a rootless document for
|
|
1076
|
+
# input with nothing to recover into (whitespace-only,
|
|
1077
|
+
# declaration-only) — libxml2's recover behaves the
|
|
1078
|
+
# same. Surface WHY on parse_errors so consumers report
|
|
1079
|
+
# it instead of silently holding an empty tree.
|
|
1080
|
+
recover_errors =
|
|
1081
|
+
["leptris parse recovered no document root " \
|
|
1082
|
+
"(empty or whitespace-only input)"]
|
|
1083
|
+
end
|
|
1084
|
+
|
|
1051
1085
|
register_mint_klasses!(native_doc)
|
|
1052
1086
|
ctx = _context || Context.new(:leptris)
|
|
1053
1087
|
doc = Wrappers::Document.new(native_doc, ctx)
|
|
@@ -1191,7 +1225,7 @@ module Moxml
|
|
|
1191
1225
|
::Leptris::XML::ParseOptions.const_defined?(:SKIP_DUP_DETECTION) &&
|
|
1192
1226
|
::Leptris::XML::ParseOptions.const_defined?(:SKIP_SOURCE_POSITIONS)
|
|
1193
1227
|
|
|
1194
|
-
def parse_flags(options, context: nil)
|
|
1228
|
+
def parse_flags(options, recover: false, context: nil)
|
|
1195
1229
|
flags = 0
|
|
1196
1230
|
flags |= ::Leptris::XML::ParseOptions::DTDATTR if options[:dtdattr] == true
|
|
1197
1231
|
flags |= ::Leptris::XML::ParseOptions::KEEP_ENTITY_REFS if NATIVE_ENTITY_REFS &&
|
|
@@ -1203,6 +1237,13 @@ module Moxml
|
|
|
1203
1237
|
flags |= po::SKIP_DUP_DETECTION if options[:skip_dup_detection] == true
|
|
1204
1238
|
flags |= po::SKIP_SOURCE_POSITIONS if options[:skip_source_positions] == true
|
|
1205
1239
|
end
|
|
1240
|
+
if recover
|
|
1241
|
+
# #369: flags and the recover kwarg ride the same
|
|
1242
|
+
# options struct (leptris-ruby's constructor composes
|
|
1243
|
+
# both).
|
|
1244
|
+
return ::Leptris::XML::ParseOptions.new(flags, recover: true)
|
|
1245
|
+
end
|
|
1246
|
+
|
|
1206
1247
|
flags.zero? ? nil : ::Leptris::XML::ParseOptions.new(flags)
|
|
1207
1248
|
end
|
|
1208
1249
|
|
data/lib/moxml/builder.rb
CHANGED
|
@@ -7,7 +7,7 @@ module Moxml
|
|
|
7
7
|
attr_reader :document
|
|
8
8
|
alias_method :doc, :document
|
|
9
9
|
|
|
10
|
-
def initialize(context)
|
|
10
|
+
def initialize(context, strict: nil)
|
|
11
11
|
@context = context
|
|
12
12
|
@current = @document = context.create_document
|
|
13
13
|
@namespaces = {}
|
|
@@ -22,6 +22,22 @@ module Moxml
|
|
|
22
22
|
@face_counts = Hash.new(0)
|
|
23
23
|
@face_deferred = []
|
|
24
24
|
@face_entity_markers = false
|
|
25
|
+
# #371: strict mode — unknown methods raise instead of
|
|
26
|
+
# silently becoming empty elements. Per-build override
|
|
27
|
+
# (Context#build(strict:)), else the context's
|
|
28
|
+
# config.builder_strict.
|
|
29
|
+
@strict = strict.nil? ? context.config.builder_strict : strict
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def strict?
|
|
33
|
+
@strict == true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# The tag-creation face NamespacedTags calls — the private
|
|
37
|
+
# create_element_node stays private.
|
|
38
|
+
def create_tag(tag_name, attrs = {}, text_content: nil, block: nil)
|
|
39
|
+
create_element_node(tag_name, attrs, text_content: text_content,
|
|
40
|
+
block: block, eval_block: false)
|
|
25
41
|
end
|
|
26
42
|
|
|
27
43
|
def build(&block)
|
|
@@ -30,6 +46,61 @@ module Moxml
|
|
|
30
46
|
@document
|
|
31
47
|
end
|
|
32
48
|
|
|
49
|
+
# Namespace-scoped tag syntax (#371, Nokogiri's xml["p"].tag
|
|
50
|
+
# parity): xml["w"].p creates <w:p>. The proxy creates through
|
|
51
|
+
# the same face as plain method_missing — caller-context
|
|
52
|
+
# blocks, text/attributes arguments, trailing-underscore
|
|
53
|
+
# escape — and honors the strict mode.
|
|
54
|
+
def [](namespace_prefix)
|
|
55
|
+
raise ArgumentError, "namespace prefix required" if namespace_prefix.nil? || namespace_prefix.to_s.empty?
|
|
56
|
+
|
|
57
|
+
NamespacedTags.new(self, namespace_prefix.to_s)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Tag proxy bound to one namespace prefix. method_missing maps
|
|
61
|
+
# tag names to prefixed element creation; explicit Builder
|
|
62
|
+
# methods (text, element, ...) stay reachable by holding the
|
|
63
|
+
# builder — the proxy is tags-only by design.
|
|
64
|
+
class NamespacedTags
|
|
65
|
+
def initialize(builder, prefix)
|
|
66
|
+
@builder = builder
|
|
67
|
+
@prefix = prefix
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def [](nested_prefix)
|
|
71
|
+
NamespacedTags.new(@builder, "#{@prefix}:#{nested_prefix}")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def method_missing(method_name, *args, &block)
|
|
75
|
+
# Trailing-underscore escape, same as plain Builder tags
|
|
76
|
+
# (type_ → type under the prefix).
|
|
77
|
+
tag = "#{@prefix}:#{method_name.to_s.chomp('_')}"
|
|
78
|
+
if @builder.strict?
|
|
79
|
+
raise NoMethodError,
|
|
80
|
+
"builder strict mode: unknown tag #{tag.inspect} " \
|
|
81
|
+
"would have silently created an empty element (#371)"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
text_content = args.first.is_a?(String) ? args.shift : nil
|
|
85
|
+
attrs = args.first.is_a?(Hash) ? args.shift : {}
|
|
86
|
+
unless args.empty?
|
|
87
|
+
raise ArgumentError,
|
|
88
|
+
"unexpected arguments for #{tag}: #{args.inspect}"
|
|
89
|
+
end
|
|
90
|
+
if text_content && block
|
|
91
|
+
raise ArgumentError,
|
|
92
|
+
"#{tag}: cannot combine text content with a block"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
@builder.create_tag(tag, attrs,
|
|
96
|
+
text_content: text_content, block: block)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def respond_to_missing?(_method_name, _include_private = false)
|
|
100
|
+
true
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
33
104
|
# Element ops inside a face-accumulated subtree cannot touch the
|
|
34
105
|
# tree yet (nothing exists until the flush): PIs ride the raw
|
|
35
106
|
# hatch in exact position; namespace/entity/declaration/doctype
|
|
@@ -139,6 +210,13 @@ module Moxml
|
|
|
139
210
|
def method_missing(method_name, *args, &block)
|
|
140
211
|
return super if RESERVED_METHOD_PATTERN.match?(method_name.to_s)
|
|
141
212
|
|
|
213
|
+
if @strict
|
|
214
|
+
raise NoMethodError,
|
|
215
|
+
"builder strict mode: unknown method #{method_name.inspect} " \
|
|
216
|
+
"would have silently created an empty <#{method_name}> element " \
|
|
217
|
+
"(#371); call a Builder method or use the explicit element face"
|
|
218
|
+
end
|
|
219
|
+
|
|
142
220
|
text_content = args.first.is_a?(String) ? args.shift : nil
|
|
143
221
|
attrs = args.first.is_a?(Hash) ? args.shift : {}
|
|
144
222
|
|
data/lib/moxml/config.rb
CHANGED
|
@@ -114,6 +114,7 @@ module Moxml
|
|
|
114
114
|
|
|
115
115
|
attr_reader :adapter_name, :default_line_ending
|
|
116
116
|
attr_accessor :strict_parsing,
|
|
117
|
+
:builder_strict,
|
|
117
118
|
:default_encoding,
|
|
118
119
|
:default_indent,
|
|
119
120
|
:restore_entities,
|
|
@@ -173,6 +174,11 @@ module Moxml
|
|
|
173
174
|
@entity_provider = nil
|
|
174
175
|
@namespace_validation_mode = :strict
|
|
175
176
|
@entity_restoration_mode = :lenient
|
|
177
|
+
# #371: Builder method_missing creates elements for unknown
|
|
178
|
+
# methods (the DSL contract). builder_strict flips that to
|
|
179
|
+
# raising NoMethodError — external helper calls stop
|
|
180
|
+
# silently becoming empty elements.
|
|
181
|
+
@builder_strict = false
|
|
176
182
|
@entity_mode = :expand
|
|
177
183
|
end
|
|
178
184
|
|
data/lib/moxml/context.rb
CHANGED
|
@@ -275,8 +275,11 @@ module Moxml
|
|
|
275
275
|
config.adapter.sax_parse(xml, handler)
|
|
276
276
|
end
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
# strict: (issue #371) flips unknown method_missing calls to
|
|
279
|
+
# NoMethodError instead of silently creating empty elements —
|
|
280
|
+
# nil defers to config.builder_strict.
|
|
281
|
+
def build(strict: nil, &block)
|
|
282
|
+
Builder.new(self, strict: strict).build(&block)
|
|
280
283
|
end
|
|
281
284
|
|
|
282
285
|
# Frozen serialization defaults, memoized per context — Node#to_xml
|
data/lib/moxml/version.rb
CHANGED
|
@@ -595,11 +595,24 @@ RSpec.describe Moxml::Adapter::Leptris do
|
|
|
595
595
|
describe "recover-path parse diagnostics" do
|
|
596
596
|
let(:ctx) { Moxml.new(:leptris) }
|
|
597
597
|
|
|
598
|
-
it "records the fatal error on non-strict parses" do
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
598
|
+
it "records the fatal error on non-strict parses below the recover floor" do
|
|
599
|
+
unless Moxml::Adapter::Leptris::RECOVER_MODE
|
|
600
|
+
doc = ctx.parse("<root><unclosed>", strict: false)
|
|
601
|
+
expect(doc.root).to be_nil
|
|
602
|
+
expect(doc.parse_errors).not_to be_empty
|
|
603
|
+
expect(doc.parse_errors).to all(be_a(String))
|
|
604
|
+
end
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
it "recovers an unclosed root at the floor (#369)" do
|
|
608
|
+
if Moxml::Adapter::Leptris::RECOVER_MODE
|
|
609
|
+
doc = ctx.parse("<root><unclosed>", strict: false)
|
|
610
|
+
expect(doc.root).not_to be_nil
|
|
611
|
+
# recovery diagnostics ride parse_errors once leptris-ruby
|
|
612
|
+
# #1200's DOM face lands; today the recovered tree is the
|
|
613
|
+
# contract.
|
|
614
|
+
expect(doc.parse_errors).to eq([])
|
|
615
|
+
end
|
|
603
616
|
end
|
|
604
617
|
|
|
605
618
|
it "answers [] on clean parses" do
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# #371: Builder sharp edges — the namespace-scoped tag proxy
|
|
6
|
+
# (Nokogiri's xml["p"].tag parity) and the strict mode where
|
|
7
|
+
# unknown methods raise instead of silently becoming empty
|
|
8
|
+
# elements.
|
|
9
|
+
RSpec.describe "Builder namespaces + strict mode (#371)" do
|
|
10
|
+
describe "Builder#[] namespace-scoped tags" do
|
|
11
|
+
it "creates prefixed elements with text and attributes" do
|
|
12
|
+
doc = Moxml.new.build do
|
|
13
|
+
element("root") do
|
|
14
|
+
self["w"].p("text", "a" => 1)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
expect(doc.root.children.first.name).to eq("w:p")
|
|
18
|
+
expect(doc.to_xml).to include(%(<w:p a="1">text</w:p>))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "nests blocks in the caller context" do
|
|
22
|
+
doc = Moxml.new.build do
|
|
23
|
+
element("root") do
|
|
24
|
+
self["w"].sub { self["w"].deep("x") }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
sub = doc.root.children.first
|
|
28
|
+
expect(sub.name).to eq("w:sub")
|
|
29
|
+
expect(sub.children.first.name).to eq("w:deep")
|
|
30
|
+
expect(sub.children.first.text).to eq("x")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "strips the trailing-underscore escape under the prefix" do
|
|
34
|
+
doc = Moxml.new.build do
|
|
35
|
+
element("root") { self["epub"].type_ }
|
|
36
|
+
end
|
|
37
|
+
expect(doc.to_xml).to include("<epub:type>")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "composes prefixes through nested []" do
|
|
41
|
+
doc = Moxml.new.build do
|
|
42
|
+
element("root") { self["w"]["ext"].node }
|
|
43
|
+
end
|
|
44
|
+
expect(doc.to_xml).to include("<w:ext:node>")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "rejects a missing prefix" do
|
|
48
|
+
expect { Moxml.new.build { self[nil] } }
|
|
49
|
+
.to raise_error(ArgumentError, /prefix/)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "strict mode" do
|
|
54
|
+
it "raises NoMethodError for unknown methods (the silent-corruption fix)" do
|
|
55
|
+
expect do
|
|
56
|
+
Moxml.new.build(strict: true) do
|
|
57
|
+
element("root") { build_chart_type_unused }
|
|
58
|
+
end
|
|
59
|
+
end.to raise_error(NoMethodError, /build_chart_type_unused/)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "raises for unknown namespaced tags too" do
|
|
63
|
+
expect do
|
|
64
|
+
Moxml.new.build(strict: true) do
|
|
65
|
+
element("root") { self["w"].chart_helper }
|
|
66
|
+
end
|
|
67
|
+
end.to raise_error(NoMethodError, /w:chart_helper/)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "still builds known tags under strict" do
|
|
71
|
+
doc = Moxml.new.build(strict: true) do
|
|
72
|
+
element("root") { text "ok" }
|
|
73
|
+
end
|
|
74
|
+
expect(doc.to_xml).to include("<root>ok</root>")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "defaults off and honors config.builder_strict" do
|
|
78
|
+
expect(Moxml.new.config.builder_strict).to be(false)
|
|
79
|
+
ctx = Moxml.new
|
|
80
|
+
ctx.config.builder_strict = true
|
|
81
|
+
expect do
|
|
82
|
+
ctx.build { element("root") { helperish } }
|
|
83
|
+
end.to raise_error(NoMethodError)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "a per-build false overrides a strict config" do
|
|
87
|
+
ctx = Moxml.new
|
|
88
|
+
ctx.config.builder_strict = true
|
|
89
|
+
doc = ctx.build(strict: false) do
|
|
90
|
+
element("root") { helperish }
|
|
91
|
+
end
|
|
92
|
+
expect(doc.to_xml).to include("<helperish>")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# #369: non-strict parses RECOVER on engines carrying the mode
|
|
6
|
+
# (leptris 1.9.344+, leptris#1660) — the best-effort tree survives
|
|
7
|
+
# recoverable structural errors (libxml2 XML_PARSE_RECOVER
|
|
8
|
+
# semantics) instead of the rescue-to-empty fallback. Strict
|
|
9
|
+
# callers never recover: malformed input raises.
|
|
10
|
+
RSpec.describe "recover mode (#369)" do
|
|
11
|
+
let(:ctx) { Moxml.new(:leptris) }
|
|
12
|
+
|
|
13
|
+
describe "engines with the recover mode" do
|
|
14
|
+
before do
|
|
15
|
+
unless Moxml::Adapter::Leptris::RECOVER_MODE
|
|
16
|
+
skip "binding #{Leptris::VERSION} predates the recover mode"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "recovers a mismatched closer into a tree" do
|
|
21
|
+
doc = ctx.parse("<root><a>x</b></root>", strict: false)
|
|
22
|
+
expect(doc.root).not_to be_nil
|
|
23
|
+
expect(doc.to_xml).to include("<a>x</a>")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "closes unclosed elements at EOF" do
|
|
27
|
+
doc = ctx.parse("<root><a>x</root>", strict: false)
|
|
28
|
+
expect(doc.root).not_to be_nil
|
|
29
|
+
expect(doc.to_xml).to include("<a>x</a>")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "keeps strict parsing raising" do
|
|
33
|
+
expect { ctx.parse("<root><a>x</b></root>", strict: true) }
|
|
34
|
+
.to raise_error(Moxml::ParseError)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "raises by default (Context strict_parsing defaults true)" do
|
|
38
|
+
expect { ctx.parse("<root><a>x</b></root>") }
|
|
39
|
+
.to raise_error(Moxml::ParseError)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "the recovered tree carries no parse errors (diagnostics ride #1200)" do
|
|
43
|
+
doc = ctx.parse("<root><a>x</b></root>", strict: false)
|
|
44
|
+
expect(doc.parse_errors).to eq([])
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "engines below the recover floor" do
|
|
49
|
+
before do
|
|
50
|
+
if Moxml::Adapter::Leptris::RECOVER_MODE
|
|
51
|
+
skip "binding #{Leptris::VERSION} carries the recover mode"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "keeps the empty-document fallback with diagnostics" do
|
|
56
|
+
doc = ctx.parse("<root><a>x</b></root>", strict: false)
|
|
57
|
+
expect(doc.root).to be_nil
|
|
58
|
+
expect(doc.parse_errors).not_to be_empty
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: moxml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.132
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |
|
|
14
14
|
Moxml is a unified XML manipulation library that provides a common API
|
|
@@ -473,6 +473,7 @@ files:
|
|
|
473
473
|
- spec/moxml/at_search_spec.rb
|
|
474
474
|
- spec/moxml/attribute_resolver_spec.rb
|
|
475
475
|
- spec/moxml/attribute_spec.rb
|
|
476
|
+
- spec/moxml/builder_namespaces_spec.rb
|
|
476
477
|
- spec/moxml/builder_spec.rb
|
|
477
478
|
- spec/moxml/c14n/adapter_delegation_spec.rb
|
|
478
479
|
- spec/moxml/c14n/api_spec.rb
|
|
@@ -531,6 +532,7 @@ files:
|
|
|
531
532
|
- spec/moxml/plan_spec.rb
|
|
532
533
|
- spec/moxml/processing_instruction_spec.rb
|
|
533
534
|
- spec/moxml/readonly_parse_spec.rb
|
|
535
|
+
- spec/moxml/recover_mode_spec.rb
|
|
534
536
|
- spec/moxml/sax/namespace_splitter_spec.rb
|
|
535
537
|
- spec/moxml/sax_entity_parity_spec.rb
|
|
536
538
|
- spec/moxml/sax_spec.rb
|