moxml 0.5.83 → 0.5.84

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: 47eeb00aed4df2a6ea9474713ed65ba577889375e2ea7a49a8b36ee7fde86090
4
- data.tar.gz: 947e4a25bd867ce42a52015ceea6fe576ded8b1ccf9a232cc5b1a69e1c22b166
3
+ metadata.gz: ff836e409dd2cf77368c7b26015e57de1b0af5e0678489e6e10452a6c70cc61a
4
+ data.tar.gz: a2a09b561505f90fc624089e925c3b41d4ab867668b00fd35f1132787e9dbfde
5
5
  SHA512:
6
- metadata.gz: daaf3e2d077a2fee6b710d61b512a1e8c89922727cbf147aca2fb69147602aa3c50369bdc990cb385e3522296151102fa5498f0df5e11955d1b16424fa18c2b1
7
- data.tar.gz: 55f51e85aa61abcb1bc9ab735cd1e863152c46f284a85ff78355306b0698305772b968c1690d7c0c991715afdd433911ac70fce6ce0fde5f133fa27001748ffc
6
+ metadata.gz: decb847bc6cfd50e816c916d98c74b837d63e9e38a9b49a2d964333a141a8fafd9e55291f83a52739403ad99126884c2a37928567ac9f4f8fdaae3ca9df37692
7
+ data.tar.gz: 59be5497f4f1a4d439e86b4138be240b1bcabb370bc6d991d79b92aa64e9a40f0243b29f090d4171fd45146593ed27fc2da29ae2a2a72d0f542919e3e5aecf3b
@@ -30,6 +30,7 @@ module Moxml
30
30
  ::Nokogiri::XML::DocumentFragment.parse(processed) do |config|
31
31
  config.strict.nonet
32
32
  config.recover
33
+ config.huge
33
34
  end.children.to_a
34
35
  end
35
36
 
@@ -64,12 +65,18 @@ module Moxml
64
65
  config.strict.nonet
65
66
  config.recover unless options[:strict]
66
67
  config.noblanks if options[:noblanks]
68
+ config.huge
67
69
  end
68
70
  else
69
71
  ::Nokogiri::XML(processed_xml, nil, "UTF-8") do |config|
70
72
  config.strict.nonet
71
73
  config.recover unless options[:strict]
72
74
  config.noblanks if options[:noblanks]
75
+ # XML_PARSE_HUGE: lifts libxml2's arbitrary limits —
76
+ # text nodes > 10MB are silently TRUNCATED at 10MB in
77
+ # recover mode, so large documents lose data without
78
+ # it (users parse >10MB XML).
79
+ config.huge
73
80
  end
74
81
  end
75
82
  rescue ::Nokogiri::XML::SyntaxError => e
@@ -89,7 +96,7 @@ module Moxml
89
96
  # malformed input never raises.
90
97
  def parse_html(html, _options = {}, _context = nil)
91
98
  html_string = html.is_a?(IO) || html.is_a?(StringIO) ? html.read : html.to_s
92
- native_doc = ::Nokogiri::HTML(html_string)
99
+ native_doc = ::Nokogiri::HTML(html_string, &:huge)
93
100
  Wrappers::Document.new(native_doc, _context || Context.new(:nokogiri))
94
101
  end
95
102
 
data/lib/moxml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- VERSION = "0.5.83"
4
+ VERSION = "0.5.84"
5
5
  end
@@ -36,4 +36,22 @@ RSpec.describe Moxml::Adapter::Nokogiri do
36
36
  expect(doc.parse_errors).to all(be_a(String))
37
37
  end
38
38
  end
39
+
40
+ # libxml2 truncates text nodes over XML_MAX_TEXT_LENGTH (10MB) —
41
+ # silently in recover mode — unless XML_PARSE_HUGE is set. The
42
+ # adapter always passes huge so large documents keep their data.
43
+ describe "XML_PARSE_HUGE (large documents)" do
44
+ let(:ctx) { Moxml.new(:nokogiri) }
45
+ let(:huge_xml) { "<r>#{'x' * 10_000_001}</r>" }
46
+
47
+ it "keeps text nodes over 10MB intact in recover mode" do
48
+ doc = ctx.parse(huge_xml, strict: false)
49
+ expect(doc.root.children.first.text.length).to eq(10_000_001)
50
+ end
51
+
52
+ it "keeps text nodes over 10MB intact in strict mode" do
53
+ doc = ctx.parse(huge_xml)
54
+ expect(doc.root.children.first.text.length).to eq(10_000_001)
55
+ end
56
+ end
39
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.83
4
+ version: 0.5.84
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.