braintree 4.32.0 → 4.33.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e524f55d0d9990e6d2c25d6dbd81b3d75833ef145a624c70af52119d2b71fd8
|
|
4
|
+
data.tar.gz: c060e46e74b749cd934e7eecef42f4d783e6e8252ed59aff41acf574379141a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2796040657fc77358e616b12dea6b8e1e9ebb1b06bd0d0d284b7ee2cb14f2e12d34e5570ed9d512b07293ef5605751ba2116a637077b0b19f0a2d6fd11704ada
|
|
7
|
+
data.tar.gz: 31ce1b5335dd36150b8f2dc46df425e17ea4e10bf2e8d0a6b44d2d0f72732c72e3d3b6f9f0a9362de56ded2ca70037a707210f72cff45955947407a8bc61273a
|
data/lib/braintree/version.rb
CHANGED
|
@@ -2,22 +2,20 @@
|
|
|
2
2
|
# under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
|
|
3
3
|
module Braintree
|
|
4
4
|
module Xml
|
|
5
|
-
module
|
|
6
|
-
|
|
5
|
+
module Nokogiri
|
|
6
|
+
NOKOGIRI_XML_LIMIT = 30000000
|
|
7
7
|
|
|
8
8
|
def self.parse(xml_string)
|
|
9
|
-
|
|
10
|
-
::
|
|
11
|
-
|
|
12
|
-
_node_to_hash(root_node)
|
|
13
|
-
ensure
|
|
14
|
-
::LibXML::XML.default_keep_blanks = old_keep_blanks_setting
|
|
9
|
+
require "nokogiri" unless defined?(::Nokogiri)
|
|
10
|
+
doc = ::Nokogiri::XML(xml_string.strip)
|
|
11
|
+
_node_to_hash(doc.root)
|
|
15
12
|
end
|
|
16
13
|
|
|
17
14
|
def self._node_to_hash(node, hash = {})
|
|
18
|
-
if node.text?
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if node.text? || (node.children.size == 1 && node.children.first.text?)
|
|
16
|
+
content = node.text? ? node.content : node.children.first.content
|
|
17
|
+
raise "Content too large" if content.length >= NOKOGIRI_XML_LIMIT
|
|
18
|
+
hash[CONTENT_ROOT] = content
|
|
21
19
|
else
|
|
22
20
|
sub_hash = _build_sub_hash(hash, node.name)
|
|
23
21
|
_attributes_to_hash(node, sub_hash)
|
|
@@ -44,26 +42,28 @@ module Braintree
|
|
|
44
42
|
end
|
|
45
43
|
|
|
46
44
|
def self._children_to_hash(node, hash={})
|
|
47
|
-
node.each { |child| _node_to_hash(child, hash) }
|
|
45
|
+
node.children.each { |child| _node_to_hash(child, hash) unless child.text? && child.content.strip.empty? }
|
|
48
46
|
_attributes_to_hash(node, hash)
|
|
49
47
|
hash
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
def self._attributes_to_hash(node, hash={})
|
|
53
|
-
node.
|
|
51
|
+
node.attributes.each { |name, attr| hash[name] = attr.value }
|
|
54
52
|
hash
|
|
55
53
|
end
|
|
56
54
|
|
|
57
55
|
def self._children_array_to_hash(node, hash={})
|
|
58
|
-
|
|
56
|
+
first_child = node.children.find { |child| !child.text? }
|
|
57
|
+
hash[first_child.name] = node.children.select { |child| !child.text? }.map do |child|
|
|
59
58
|
_children_to_hash(child, {})
|
|
60
59
|
end
|
|
61
60
|
hash
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
def self._array?(node)
|
|
65
|
-
|
|
64
|
+
non_text_children = node.children.select { |child| !child.text? }
|
|
65
|
+
non_text_children.size > 1 && non_text_children.first.name == non_text_children[1].name
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
|
-
end
|
|
69
|
+
end
|
data/lib/braintree/xml/parser.rb
CHANGED
|
@@ -18,10 +18,10 @@ module Braintree
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def self._determine_parser
|
|
21
|
-
# If
|
|
22
|
-
#
|
|
23
|
-
if defined?(::
|
|
24
|
-
::Braintree::Xml::
|
|
21
|
+
# If Nokogiri is available, use it for better performance
|
|
22
|
+
# Otherwise fall back to REXML for JRuby compatibility
|
|
23
|
+
if defined?(::Nokogiri)
|
|
24
|
+
::Braintree::Xml::Nokogiri
|
|
25
25
|
else
|
|
26
26
|
::Braintree::Xml::Rexml
|
|
27
27
|
end
|
data/lib/braintree.rb
CHANGED
|
@@ -203,6 +203,6 @@ require "braintree/webhook_testing"
|
|
|
203
203
|
require "braintree/webhook_testing_gateway"
|
|
204
204
|
require "braintree/xml"
|
|
205
205
|
require "braintree/xml/generator"
|
|
206
|
-
require "braintree/xml/
|
|
206
|
+
require "braintree/xml/nokogiri"
|
|
207
207
|
require "braintree/xml/rexml"
|
|
208
208
|
require "braintree/xml/parser"
|
data/spec/spec_helper.rb
CHANGED
|
@@ -3,7 +3,6 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
3
3
|
project_root = File.expand_path(File.dirname(__FILE__) + "/..")
|
|
4
4
|
require "rubygems"
|
|
5
5
|
require "bundler/setup"
|
|
6
|
-
require "libxml"
|
|
7
6
|
require "rspec"
|
|
8
7
|
require "pry"
|
|
9
8
|
|
|
@@ -195,10 +194,10 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
195
194
|
end
|
|
196
195
|
|
|
197
196
|
def matches?(xml_string)
|
|
198
|
-
@
|
|
199
|
-
if @
|
|
200
|
-
@results = @
|
|
201
|
-
@failed_parser = "
|
|
197
|
+
@xml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string)
|
|
198
|
+
if @xml_parse != @expected_hash
|
|
199
|
+
@results = @xml_parse
|
|
200
|
+
@failed_parser = "xml"
|
|
202
201
|
false
|
|
203
202
|
else
|
|
204
203
|
true
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
2
|
|
|
3
|
-
describe Braintree::Xml::
|
|
3
|
+
describe Braintree::Xml::Nokogiri do
|
|
4
4
|
describe "self.parse" do
|
|
5
5
|
it "typecasts integers" do
|
|
6
6
|
xml = "<root><foo type=\"integer\">123</foo></root>"
|
|
7
|
-
expect(Braintree::Xml::
|
|
7
|
+
expect(Braintree::Xml::Nokogiri.parse(xml)).to eq({"root"=>{"foo"=>{"__content__"=>"123", "type"=>"integer"}}})
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "works with dashes or underscores" do
|
|
@@ -14,7 +14,7 @@ describe Braintree::Xml::Libxml do
|
|
|
14
14
|
<under_scores />
|
|
15
15
|
</root>
|
|
16
16
|
END
|
|
17
|
-
expect(Braintree::Xml::
|
|
17
|
+
expect(Braintree::Xml::Nokogiri.parse(xml)).to eq({"root"=>{"dash-es"=>{}, "under_scores"=>{}}})
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "uses nil if nil=true, otherwise uses empty string" do
|
|
@@ -24,7 +24,7 @@ describe Braintree::Xml::Libxml do
|
|
|
24
24
|
<an_empty_string></an_empty_string>
|
|
25
25
|
</root>
|
|
26
26
|
END
|
|
27
|
-
expect(Braintree::Xml::
|
|
27
|
+
expect(Braintree::Xml::Nokogiri.parse(xml)).to eq({"root"=>{"a_nil_value"=>{"nil"=>"true"}, "an_empty_string"=>{}}})
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "typecasts dates and times" do
|
|
@@ -33,7 +33,7 @@ describe Braintree::Xml::Libxml do
|
|
|
33
33
|
<created-at type="datetime">2009-10-28T10:19:49Z</created-at>
|
|
34
34
|
</root>
|
|
35
35
|
END
|
|
36
|
-
expect(Braintree::Xml::
|
|
36
|
+
expect(Braintree::Xml::Nokogiri.parse(xml)).to eq({"root"=>{"created-at"=>{"__content__"=>"2009-10-28T10:19:49Z", "type"=>"datetime"}}})
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "builds an array if type=array" do
|
|
@@ -45,7 +45,7 @@ describe Braintree::Xml::Libxml do
|
|
|
45
45
|
</customers>
|
|
46
46
|
</root>
|
|
47
47
|
END
|
|
48
|
-
expect(Braintree::Xml::
|
|
48
|
+
expect(Braintree::Xml::Nokogiri.parse(xml)).to eq({"root"=>{"customers"=>{"type"=>"array", "customer"=>[{"name"=>{"__content__"=>"Adam"}}, {"name"=>{"__content__"=>"Ben"}}]}}})
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
end
|
|
51
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: braintree
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.33.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Braintree
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-10-
|
|
11
|
+
date: 2025-10-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: builder
|
|
@@ -236,7 +236,7 @@ files:
|
|
|
236
236
|
- lib/braintree/webhook_testing_gateway.rb
|
|
237
237
|
- lib/braintree/xml.rb
|
|
238
238
|
- lib/braintree/xml/generator.rb
|
|
239
|
-
- lib/braintree/xml/
|
|
239
|
+
- lib/braintree/xml/nokogiri.rb
|
|
240
240
|
- lib/braintree/xml/parser.rb
|
|
241
241
|
- lib/braintree/xml/rexml.rb
|
|
242
242
|
- lib/ssl/api_braintreegateway_com.ca.crt
|
|
@@ -390,7 +390,7 @@ files:
|
|
|
390
390
|
- spec/unit/braintree/venmo_profile_data_spec.rb
|
|
391
391
|
- spec/unit/braintree/visa_checkout_card_spec.rb
|
|
392
392
|
- spec/unit/braintree/webhook_notification_spec.rb
|
|
393
|
-
- spec/unit/braintree/xml/
|
|
393
|
+
- spec/unit/braintree/xml/nokogiri_spec.rb
|
|
394
394
|
- spec/unit/braintree/xml/parser_spec.rb
|
|
395
395
|
- spec/unit/braintree/xml/rexml_spec.rb
|
|
396
396
|
- spec/unit/braintree/xml_spec.rb
|