nokogiri 1.6.7.2-x86-mingw32 → 1.6.8.rc1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -9
  3. data/CHANGELOG.ja.rdoc +18 -0
  4. data/CHANGELOG.rdoc +12 -7
  5. data/CONTRIBUTING.md +42 -0
  6. data/Gemfile +1 -1
  7. data/Manifest.txt +6 -0
  8. data/README.md +1 -1
  9. data/Rakefile +1 -1
  10. data/bin/nokogiri +2 -2
  11. data/dependencies.yml +1 -1
  12. data/ext/nokogiri/extconf.rb +3 -3
  13. data/ext/nokogiri/nokogiri.c +0 -7
  14. data/ext/nokogiri/nokogiri.h +1 -34
  15. data/ext/nokogiri/xml_document.c +2 -4
  16. data/ext/nokogiri/xml_namespace.c +56 -17
  17. data/ext/nokogiri/xml_node.c +12 -36
  18. data/ext/nokogiri/xml_node_set.c +169 -143
  19. data/ext/nokogiri/xml_node_set.h +3 -4
  20. data/ext/nokogiri/xml_sax_parser.c +2 -5
  21. data/ext/nokogiri/xml_syntax_error.c +0 -4
  22. data/ext/nokogiri/xml_syntax_error.h +0 -1
  23. data/ext/nokogiri/xml_xpath_context.c +9 -18
  24. data/lib/nokogiri.rb +3 -0
  25. data/lib/nokogiri/1.9/nokogiri.so +0 -0
  26. data/lib/nokogiri/2.0/nokogiri.so +0 -0
  27. data/lib/nokogiri/2.1/nokogiri.so +0 -0
  28. data/lib/nokogiri/2.2/nokogiri.so +0 -0
  29. data/lib/nokogiri/css/parser.rb +8 -2
  30. data/lib/nokogiri/css/parser.y +7 -2
  31. data/lib/nokogiri/version.rb +1 -1
  32. data/lib/nokogiri/xml/document.rb +7 -1
  33. data/lib/nokogiri/xml/dtd.rb +4 -4
  34. data/lib/nokogiri/xml/node.rb +2 -2
  35. data/test/css/test_parser.rb +7 -1
  36. data/test/files/GH_1042.html +18 -0
  37. data/test/files/namespace_pressure_test.xml +1684 -0
  38. data/test/files/tlm.html +2 -1
  39. data/test/html/sax/test_parser.rb +2 -2
  40. data/test/html/test_document.rb +18 -8
  41. data/test/html/test_document_encoding.rb +46 -54
  42. data/test/html/test_document_fragment.rb +21 -22
  43. data/test/html/test_node.rb +16 -0
  44. data/test/html/test_node_encoding.rb +12 -14
  45. data/test/namespaces/test_namespaces_in_parsed_doc.rb +14 -0
  46. data/test/test_reader.rb +19 -0
  47. data/test/test_xslt_transforms.rb +5 -3
  48. data/test/xml/sax/test_parser.rb +36 -39
  49. data/test/xml/test_document.rb +7 -2
  50. data/test/xml/test_document_encoding.rb +14 -16
  51. data/test/xml/test_dtd_encoding.rb +0 -2
  52. data/test/xml/test_node_encoding.rb +78 -80
  53. data/test/xml/test_reader_encoding.rb +100 -102
  54. data/test/xslt/test_exception_handling.rb +1 -1
  55. metadata +11 -7
@@ -28,8 +28,13 @@ module Nokogiri
28
28
 
29
29
  # issue #1005
30
30
  def test_strict_parsing_empty_doc_should_raise_exception
31
- assert_raises(SyntaxError) do
32
- Nokogiri::XML(StringIO.new('')) { |c| c.strict }
31
+ ["", " "].each do |empty_string|
32
+ assert_raises(SyntaxError, "empty string '#{empty_string}' should raise a SyntaxError") do
33
+ Nokogiri::XML(empty_string) { |c| c.strict }
34
+ end
35
+ assert_raises(SyntaxError, "StringIO of '#{empty_string}' should raise a SyntaxError") do
36
+ Nokogiri::XML(StringIO.new(empty_string)) { |c| c.strict }
37
+ end
33
38
  end
34
39
  end
35
40
 
@@ -2,25 +2,23 @@ require "helper"
2
2
 
3
3
  module Nokogiri
4
4
  module XML
5
- if RUBY_VERSION =~ /^1\.9/
6
- class TestDocumentEncoding < Nokogiri::TestCase
7
- def setup
8
- super
9
- @xml = Nokogiri::XML(File.read(XML_FILE), XML_FILE, 'UTF-8')
10
- end
5
+ class TestDocumentEncoding < Nokogiri::TestCase
6
+ def setup
7
+ super
8
+ @xml = Nokogiri::XML(File.read(XML_FILE), XML_FILE, 'UTF-8')
9
+ end
11
10
 
12
- def test_url
13
- assert_equal @xml.encoding, @xml.url.encoding.name
14
- end
11
+ def test_url
12
+ assert_equal @xml.encoding, @xml.url.encoding.name
13
+ end
15
14
 
16
- def test_encoding
17
- assert_equal @xml.encoding, @xml.encoding.encoding.name
18
- end
15
+ def test_encoding
16
+ assert_equal @xml.encoding, @xml.encoding.encoding.name
17
+ end
19
18
 
20
- def test_dotted_version
21
- if Nokogiri.uses_libxml?
22
- assert_equal 'UTF-8', Nokogiri::LIBXML_VERSION.encoding.name
23
- end
19
+ def test_dotted_version
20
+ if Nokogiri.uses_libxml?
21
+ assert_equal 'UTF-8', Nokogiri::LIBXML_VERSION.encoding.name
24
22
  end
25
23
  end
26
24
  end
@@ -4,7 +4,6 @@ require "helper"
4
4
 
5
5
  module Nokogiri
6
6
  module XML
7
- if RUBY_VERSION =~ /^1\.9/
8
7
  class TestDTDEncoding < Nokogiri::TestCase
9
8
  def setup
10
9
  super
@@ -28,6 +27,5 @@ module Nokogiri
28
27
  end
29
28
  end
30
29
  end
31
- end
32
30
  end
33
31
  end
@@ -2,104 +2,102 @@ require "helper"
2
2
 
3
3
  module Nokogiri
4
4
  module XML
5
- if RUBY_VERSION =~ /^1\.9/
6
- class TestNodeEncoding < Nokogiri::TestCase
7
- def setup
8
- super
9
- @html = Nokogiri::HTML(File.read(HTML_FILE), HTML_FILE)
10
- end
5
+ class TestNodeEncoding < Nokogiri::TestCase
6
+ def setup
7
+ super
8
+ @html = Nokogiri::HTML(File.read(HTML_FILE), HTML_FILE)
9
+ end
11
10
 
12
- def test_get_attribute
13
- node = @html.css('a').first
14
- assert_equal @html.encoding, node['href'].encoding.name
15
- end
11
+ def test_get_attribute
12
+ node = @html.css('a').first
13
+ assert_equal @html.encoding, node['href'].encoding.name
14
+ end
16
15
 
17
- def test_text_encoding_is_utf_8
18
- @html = Nokogiri::HTML(File.open(NICH_FILE))
19
- assert_equal 'UTF-8', @html.text.encoding.name
20
- end
16
+ def test_text_encoding_is_utf_8
17
+ @html = Nokogiri::HTML(File.open(NICH_FILE))
18
+ assert_equal 'UTF-8', @html.text.encoding.name
19
+ end
21
20
 
22
- def test_serialize_encoding_html
23
- @html = Nokogiri::HTML(File.open(NICH_FILE))
24
- assert_equal @html.encoding.downcase,
25
- @html.serialize.encoding.name.downcase
21
+ def test_serialize_encoding_html
22
+ @html = Nokogiri::HTML(File.open(NICH_FILE))
23
+ assert_equal @html.encoding.downcase,
24
+ @html.serialize.encoding.name.downcase
26
25
 
27
- @doc = Nokogiri::HTML(@html.serialize)
28
- assert_equal @html.serialize, @doc.serialize
29
- end
26
+ @doc = Nokogiri::HTML(@html.serialize)
27
+ assert_equal @html.serialize, @doc.serialize
28
+ end
30
29
 
31
- def test_serialize_encoding_xml
32
- @xml = Nokogiri::XML(File.open(SHIFT_JIS_XML))
33
- assert_equal @xml.encoding.downcase,
34
- @xml.serialize.encoding.name.downcase
30
+ def test_serialize_encoding_xml
31
+ @xml = Nokogiri::XML(File.open(SHIFT_JIS_XML))
32
+ assert_equal @xml.encoding.downcase,
33
+ @xml.serialize.encoding.name.downcase
35
34
 
36
- @doc = Nokogiri::XML(@xml.serialize)
37
- assert_equal @xml.serialize, @doc.serialize
38
- end
35
+ @doc = Nokogiri::XML(@xml.serialize)
36
+ assert_equal @xml.serialize, @doc.serialize
37
+ end
39
38
 
40
- def test_encode_special_chars
41
- foo = @html.css('a').first.encode_special_chars('foo')
42
- assert_equal @html.encoding, foo.encoding.name
43
- end
39
+ def test_encode_special_chars
40
+ foo = @html.css('a').first.encode_special_chars('foo')
41
+ assert_equal @html.encoding, foo.encoding.name
42
+ end
44
43
 
45
- def test_content
46
- node = @html.css('a').first
47
- assert_equal @html.encoding, node.content.encoding.name
48
- end
44
+ def test_content
45
+ node = @html.css('a').first
46
+ assert_equal @html.encoding, node.content.encoding.name
47
+ end
49
48
 
50
- def test_name
51
- node = @html.css('a').first
52
- assert_equal @html.encoding, node.name.encoding.name
53
- end
49
+ def test_name
50
+ node = @html.css('a').first
51
+ assert_equal @html.encoding, node.name.encoding.name
52
+ end
54
53
 
55
- def test_path
56
- node = @html.css('a').first
57
- assert_equal @html.encoding, node.path.encoding.name
58
- end
54
+ def test_path
55
+ node = @html.css('a').first
56
+ assert_equal @html.encoding, node.path.encoding.name
57
+ end
59
58
 
60
- def test_namespace
61
- xml = <<-eoxml
59
+ def test_namespace
60
+ xml = <<-eoxml
62
61
  <root>
63
- <car xmlns:part="http://general-motors.com/">
64
- <part:tire>Michelin Model XGV</part:tire>
65
- </car>
66
- <bicycle xmlns:part="http://schwinn.com/">
67
- <part:tire>I'm a bicycle tire!</part:tire>
68
- </bicycle>
62
+ <car xmlns:part="http://general-motors.com/">
63
+ <part:tire>Michelin Model XGV</part:tire>
64
+ </car>
65
+ <bicycle xmlns:part="http://schwinn.com/">
66
+ <part:tire>I'm a bicycle tire!</part:tire>
67
+ </bicycle>
69
68
  </root>
70
- eoxml
71
- doc = Nokogiri::XML(xml, nil, 'UTF-8')
72
- assert_equal 'UTF-8', doc.encoding
73
- n = doc.xpath('//part:tire', { 'part' => 'http://schwinn.com/' }).first
74
- assert n
75
- assert_equal doc.encoding, n.namespace.href.encoding.name
76
- assert_equal doc.encoding, n.namespace.prefix.encoding.name
77
- end
69
+ eoxml
70
+ doc = Nokogiri::XML(xml, nil, 'UTF-8')
71
+ assert_equal 'UTF-8', doc.encoding
72
+ n = doc.xpath('//part:tire', { 'part' => 'http://schwinn.com/' }).first
73
+ assert n
74
+ assert_equal doc.encoding, n.namespace.href.encoding.name
75
+ assert_equal doc.encoding, n.namespace.prefix.encoding.name
76
+ end
78
77
 
79
- def test_namespace_as_hash
80
- xml = <<-eoxml
78
+ def test_namespace_as_hash
79
+ xml = <<-eoxml
81
80
  <root>
82
- <car xmlns:part="http://general-motors.com/">
83
- <part:tire>Michelin Model XGV</part:tire>
84
- </car>
85
- <bicycle xmlns:part="http://schwinn.com/">
86
- <part:tire>I'm a bicycle tire!</part:tire>
87
- </bicycle>
81
+ <car xmlns:part="http://general-motors.com/">
82
+ <part:tire>Michelin Model XGV</part:tire>
83
+ </car>
84
+ <bicycle xmlns:part="http://schwinn.com/">
85
+ <part:tire>I'm a bicycle tire!</part:tire>
86
+ </bicycle>
88
87
  </root>
89
- eoxml
90
- doc = Nokogiri::XML(xml, nil, 'UTF-8')
91
- assert_equal 'UTF-8', doc.encoding
92
- assert n = doc.xpath('//car').first
88
+ eoxml
89
+ doc = Nokogiri::XML(xml, nil, 'UTF-8')
90
+ assert_equal 'UTF-8', doc.encoding
91
+ assert n = doc.xpath('//car').first
93
92
 
94
- n.namespace_definitions.each do |nd|
95
- assert_equal doc.encoding, nd.href.encoding.name
96
- assert_equal doc.encoding, nd.prefix.encoding.name
97
- end
93
+ n.namespace_definitions.each do |nd|
94
+ assert_equal doc.encoding, nd.href.encoding.name
95
+ assert_equal doc.encoding, nd.prefix.encoding.name
96
+ end
98
97
 
99
- n.namespaces.each do |k,v|
100
- assert_equal doc.encoding, k.encoding.name
101
- assert_equal doc.encoding, v.encoding.name
102
- end
98
+ n.namespaces.each do |k,v|
99
+ assert_equal doc.encoding, k.encoding.name
100
+ assert_equal doc.encoding, v.encoding.name
103
101
  end
104
102
  end
105
103
  end
@@ -3,131 +3,129 @@ require "helper"
3
3
 
4
4
  module Nokogiri
5
5
  module XML
6
- if RUBY_VERSION =~ /^1\.9/
7
- class TestReaderEncoding < Nokogiri::TestCase
8
- def setup
9
- super
10
- @reader = Nokogiri::XML::Reader(
11
- File.read(XML_FILE),
12
- XML_FILE,
13
- 'UTF-8'
14
- )
15
- end
6
+ class TestReaderEncoding < Nokogiri::TestCase
7
+ def setup
8
+ super
9
+ @reader = Nokogiri::XML::Reader(
10
+ File.read(XML_FILE),
11
+ XML_FILE,
12
+ 'UTF-8'
13
+ )
14
+ end
16
15
 
17
- def test_attribute_at
18
- @reader.each do |node|
19
- next unless attribute = node.attribute_at(0)
20
- assert_equal @reader.encoding, attribute.encoding.name
21
- end
16
+ def test_attribute_at
17
+ @reader.each do |node|
18
+ next unless attribute = node.attribute_at(0)
19
+ assert_equal @reader.encoding, attribute.encoding.name
22
20
  end
21
+ end
23
22
 
24
- def test_attributes
25
- @reader.each do |node|
26
- node.attributes.each do |k,v|
27
- assert_equal @reader.encoding, k.encoding.name
28
- assert_equal @reader.encoding, v.encoding.name
29
- end
23
+ def test_attributes
24
+ @reader.each do |node|
25
+ node.attributes.each do |k,v|
26
+ assert_equal @reader.encoding, k.encoding.name
27
+ assert_equal @reader.encoding, v.encoding.name
30
28
  end
31
29
  end
30
+ end
32
31
 
33
- def test_attribute
34
- xml = <<-eoxml
35
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
36
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
37
- </x>
38
- eoxml
39
- reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
40
- reader.each do |node|
41
- next unless attribute = node.attribute('awesome')
42
- assert_equal reader.encoding, attribute.encoding.name
43
- end
32
+ def test_attribute
33
+ xml = <<-eoxml
34
+ <x xmlns:tenderlove='http://tenderlovemaking.com/'>
35
+ <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
36
+ </x>
37
+ eoxml
38
+ reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
39
+ reader.each do |node|
40
+ next unless attribute = node.attribute('awesome')
41
+ assert_equal reader.encoding, attribute.encoding.name
44
42
  end
43
+ end
45
44
 
46
- def test_xml_version
47
- @reader.each do |node|
48
- next unless version = node.xml_version
49
- assert_equal @reader.encoding, version.encoding.name
50
- end
45
+ def test_xml_version
46
+ @reader.each do |node|
47
+ next unless version = node.xml_version
48
+ assert_equal @reader.encoding, version.encoding.name
51
49
  end
50
+ end
52
51
 
53
- def test_lang
54
- xml = <<-eoxml
55
- <awesome>
56
- <p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
57
- <p xml:lang="ja">日本語が上手です</p>
58
- </awesome>
59
- eoxml
52
+ def test_lang
53
+ xml = <<-eoxml
54
+ <awesome>
55
+ <p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
56
+ <p xml:lang="ja">日本語が上手です</p>
57
+ </awesome>
58
+ eoxml
60
59
 
61
- reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
62
- reader.each do |node|
63
- next unless lang = node.lang
64
- assert_equal reader.encoding, lang.encoding.name
65
- end
60
+ reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
61
+ reader.each do |node|
62
+ next unless lang = node.lang
63
+ assert_equal reader.encoding, lang.encoding.name
66
64
  end
65
+ end
67
66
 
68
- def test_value
69
- called = false
70
- @reader.each do |node|
71
- next unless value = node.value
72
- assert_equal @reader.encoding, value.encoding.name
73
- called = true
74
- end
75
- assert called
67
+ def test_value
68
+ called = false
69
+ @reader.each do |node|
70
+ next unless value = node.value
71
+ assert_equal @reader.encoding, value.encoding.name
72
+ called = true
76
73
  end
74
+ assert called
75
+ end
77
76
 
78
- def test_prefix
79
- xml = <<-eoxml
80
- <x xmlns:edi='http://ecommerce.example.org/schema'>
81
- <edi:foo>hello</edi:foo>
82
- </x>
83
- eoxml
84
- reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
85
- reader.each do |node|
86
- next unless prefix = node.prefix
87
- assert_equal reader.encoding, prefix.encoding.name
88
- end
77
+ def test_prefix
78
+ xml = <<-eoxml
79
+ <x xmlns:edi='http://ecommerce.example.org/schema'>
80
+ <edi:foo>hello</edi:foo>
81
+ </x>
82
+ eoxml
83
+ reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
84
+ reader.each do |node|
85
+ next unless prefix = node.prefix
86
+ assert_equal reader.encoding, prefix.encoding.name
89
87
  end
88
+ end
90
89
 
91
- def test_ns_uri
92
- xml = <<-eoxml
93
- <x xmlns:edi='http://ecommerce.example.org/schema'>
94
- <edi:foo>hello</edi:foo>
95
- </x>
96
- eoxml
97
- reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
98
- reader.each do |node|
99
- next unless uri = node.namespace_uri
100
- assert_equal reader.encoding, uri.encoding.name
101
- end
90
+ def test_ns_uri
91
+ xml = <<-eoxml
92
+ <x xmlns:edi='http://ecommerce.example.org/schema'>
93
+ <edi:foo>hello</edi:foo>
94
+ </x>
95
+ eoxml
96
+ reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
97
+ reader.each do |node|
98
+ next unless uri = node.namespace_uri
99
+ assert_equal reader.encoding, uri.encoding.name
102
100
  end
101
+ end
103
102
 
104
- def test_local_name
105
- xml = <<-eoxml
106
- <x xmlns:edi='http://ecommerce.example.org/schema'>
107
- <edi:foo>hello</edi:foo>
108
- </x>
109
- eoxml
110
- reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
111
- reader.each do |node|
112
- next unless lname = node.local_name
113
- assert_equal reader.encoding, lname.encoding.name
114
- end
103
+ def test_local_name
104
+ xml = <<-eoxml
105
+ <x xmlns:edi='http://ecommerce.example.org/schema'>
106
+ <edi:foo>hello</edi:foo>
107
+ </x>
108
+ eoxml
109
+ reader = Nokogiri::XML::Reader(xml, nil, 'UTF-8')
110
+ reader.each do |node|
111
+ next unless lname = node.local_name
112
+ assert_equal reader.encoding, lname.encoding.name
115
113
  end
114
+ end
116
115
 
117
- def test_name
118
- @reader.each do |node|
119
- next unless name = node.name
120
- assert_equal @reader.encoding, name.encoding.name
121
- end
116
+ def test_name
117
+ @reader.each do |node|
118
+ next unless name = node.name
119
+ assert_equal @reader.encoding, name.encoding.name
122
120
  end
121
+ end
123
122
 
124
- def test_value_lookup_segfault
125
- skip("JRuby doesn't do GC.") if Nokogiri.jruby?
126
- stress_memory_while do
127
- while node = @reader.read
128
- nodes = node.send(:attr_nodes)
129
- nodes.first.name if nodes.first
130
- end
123
+ def test_value_lookup_segfault
124
+ skip("JRuby doesn't do GC.") if Nokogiri.jruby?
125
+ stress_memory_while do
126
+ while node = @reader.read
127
+ nodes = node.send(:attr_nodes)
128
+ nodes.first.name if nodes.first
131
129
  end
132
130
  end
133
131
  end