nokogiri 1.4.2.1-x86-mswin32 → 1.4.3-x86-mswin32

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 (56) hide show
  1. data/CHANGELOG.ja.rdoc +28 -8
  2. data/CHANGELOG.rdoc +23 -0
  3. data/Manifest.txt +2 -1
  4. data/README.ja.rdoc +1 -1
  5. data/README.rdoc +22 -4
  6. data/Rakefile +6 -2
  7. data/ext/nokogiri/extconf.rb +50 -30
  8. data/ext/nokogiri/nokogiri.h +2 -0
  9. data/ext/nokogiri/xml_document.c +5 -0
  10. data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
  11. data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
  12. data/ext/nokogiri/xml_node.c +58 -12
  13. data/ext/nokogiri/xml_node_set.c +7 -7
  14. data/ext/nokogiri/xml_reader.c +20 -1
  15. data/ext/nokogiri/xml_xpath_context.c +2 -0
  16. data/lib/nokogiri/1.8/nokogiri.so +0 -0
  17. data/lib/nokogiri/1.9/nokogiri.so +0 -0
  18. data/lib/nokogiri/css/generated_parser.rb +155 -148
  19. data/lib/nokogiri/css/generated_tokenizer.rb +2 -1
  20. data/lib/nokogiri/css/parser.y +3 -0
  21. data/lib/nokogiri/css/xpath_visitor.rb +1 -7
  22. data/lib/nokogiri/ffi/libxml.rb +29 -4
  23. data/lib/nokogiri/ffi/xml/document.rb +4 -0
  24. data/lib/nokogiri/ffi/xml/node.rb +27 -19
  25. data/lib/nokogiri/ffi/xml/node_set.rb +3 -3
  26. data/lib/nokogiri/ffi/xml/reader.rb +4 -0
  27. data/lib/nokogiri/html.rb +2 -2
  28. data/lib/nokogiri/html/document_fragment.rb +7 -4
  29. data/lib/nokogiri/version.rb +2 -1
  30. data/lib/nokogiri/xml/builder.rb +1 -1
  31. data/lib/nokogiri/xml/document.rb +1 -2
  32. data/lib/nokogiri/xml/document_fragment.rb +7 -0
  33. data/lib/nokogiri/xml/node.rb +4 -2
  34. data/lib/nokogiri/xml/node_set.rb +25 -0
  35. data/lib/nokogiri/xml/reader.rb +2 -0
  36. data/lib/nokogiri/xml/sax/document.rb +3 -1
  37. data/test/css/test_parser.rb +11 -1
  38. data/test/html/sax/test_parser_context.rb +2 -2
  39. data/test/html/test_document.rb +2 -2
  40. data/test/html/test_document_fragment.rb +34 -6
  41. data/test/test_memory_leak.rb +2 -2
  42. data/test/test_reader.rb +28 -6
  43. data/test/test_xslt_transforms.rb +29 -28
  44. data/test/xml/test_attr.rb +31 -4
  45. data/test/xml/test_builder.rb +5 -5
  46. data/test/xml/test_cdata.rb +3 -3
  47. data/test/xml/test_document.rb +8 -8
  48. data/test/xml/test_document_fragment.rb +2 -2
  49. data/test/xml/test_node.rb +1 -1
  50. data/test/xml/test_node_reparenting.rb +26 -11
  51. data/test/xml/test_node_set.rb +38 -2
  52. data/test/xml/test_text.rb +11 -2
  53. data/test/xml/test_unparented_node.rb +1 -1
  54. data/test/xml/test_xpath.rb +78 -11
  55. metadata +24 -6
  56. data/lib/nokogiri/version_warning.rb +0 -14
@@ -3,6 +3,13 @@ require "helper"
3
3
  module Nokogiri
4
4
  module XML
5
5
  class TestText < Nokogiri::TestCase
6
+ def test_css_path
7
+ doc = Nokogiri.XML "<root> foo <a>something</a> bar bazz </root>"
8
+ node = doc.root.children[2]
9
+ assert_instance_of Nokogiri::XML::Text, node
10
+ assert_equal node, doc.at_css(node.css_path)
11
+ end
12
+
6
13
  def test_inspect
7
14
  node = Text.new('hello world', Document.new)
8
15
  assert_equal "#<#{node.class.name}:#{sprintf("0x%x",node.object_id)} #{node.text.inspect}>", node.inspect
@@ -19,11 +26,13 @@ module Nokogiri
19
26
  100.times { Text.new('hello world', Document.new) }
20
27
  end
21
28
 
22
- # No assertion because this was a segv
23
29
  def test_new_without_document
24
30
  doc = Document.new
25
31
  node = Nokogiri::XML::Element.new('foo', doc)
26
- text = Text.new('hello world', node)
32
+
33
+ assert_nothing_raised do
34
+ Text.new('hello world', node)
35
+ end
27
36
  end
28
37
 
29
38
  def test_content=
@@ -129,7 +129,7 @@ module Nokogiri
129
129
  def test_add_child_in_same_document
130
130
  child = @node.css('employee').first
131
131
 
132
- assert previous_last_child = child.children.last
132
+ assert child.children.last
133
133
  assert new_child = child.children.first
134
134
 
135
135
  last = child.children.last
@@ -3,10 +3,37 @@ require "helper"
3
3
  module Nokogiri
4
4
  module XML
5
5
  class TestXPath < Nokogiri::TestCase
6
+
7
+ # ** WHY ALL THOSE _if Nokogiri.uses_libxml?_ **
8
+ # Hi, my dear readers,
9
+ #
10
+ # After reading these tests you may be wondering why all those ugly
11
+ # if Nokogiri.uses_libxml? sparsed over the whole document. Well, let
12
+ # me explain it. While using XPath in Java, you need the extension
13
+ # functions to be in a namespace. This is not required by XPath, afaik,
14
+ # but it is an usual convention though.
15
+ #
16
+ # Furthermore, CSS does not support extension functions but it does in
17
+ # Nokogiri. Result: you cannot use them in JRuby impl. At least, until
18
+ # the CSS to XPath parser is patched, and let me say that there are more
19
+ # important features to add before that happens. I hope you will forgive
20
+ # me.
21
+ #
22
+ # Yours truly,
23
+ #
24
+ # The guy whose headaches belong to Nokogiri JRuby impl.
25
+
26
+
6
27
  def setup
7
28
  super
29
+
8
30
  @xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
9
31
 
32
+ @ns = @xml.root.namespaces
33
+
34
+ # TODO: Maybe I should move this to the original code.
35
+ @ns["nokogiri"] = "http://www.nokogiri.org/default_ns/ruby/extensions_functions"
36
+
10
37
  @handler = Class.new {
11
38
  attr_reader :things
12
39
 
@@ -52,7 +79,11 @@ module Nokogiri
52
79
  end
53
80
 
54
81
  def test_css_search_uses_custom_selectors_with_arguments
55
- set = @xml.css('employee > address:my_filter("domestic", "Yes")', @handler)
82
+ set = if Nokogiri.uses_libxml?
83
+ @xml.css('employee > address:my_filter("domestic", "Yes")', @handler)
84
+ else
85
+ @xml.xpath("//employee/address[nokogiri:my_filter(., \"domestic\", \"Yes\")]", @ns, @handler)
86
+ end
56
87
  assert set.length > 0
57
88
  set.each do |node|
58
89
  assert_equal 'Yes', node['domestic']
@@ -61,13 +92,23 @@ module Nokogiri
61
92
 
62
93
  def test_css_search_uses_custom_selectors
63
94
  set = @xml.xpath('//employee')
64
- css_set = @xml.css('employee:thing()', @handler)
95
+ assert_nothing_raised do
96
+ if Nokogiri.uses_libxml?
97
+ @xml.css('employee:thing()', @handler)
98
+ else
99
+ @xml.xpath("//employee[nokogiri:thing(.)]", @ns, @handler)
100
+ end
101
+ end
65
102
  assert_equal(set.length, @handler.things.length)
66
103
  assert_equal(set.to_a, @handler.things.flatten)
67
104
  end
68
105
 
69
106
  def test_pass_self_to_function
70
- set = @xml.xpath('//employee/address[my_filter(., "domestic", "Yes")]', @handler)
107
+ set = if Nokogiri.uses_libxml?
108
+ @xml.xpath('//employee/address[my_filter(., "domestic", "Yes")]', @handler)
109
+ else
110
+ @xml.xpath('//employee/address[nokogiri:my_filter(., "domestic", "Yes")]', @ns, @handler)
111
+ end
71
112
  assert set.length > 0
72
113
  set.each do |node|
73
114
  assert_equal 'Yes', node['domestic']
@@ -76,42 +117,66 @@ module Nokogiri
76
117
 
77
118
  def test_custom_xpath_function_gets_strings
78
119
  set = @xml.xpath('//employee')
79
- @xml.xpath('//employee[thing("asdf")]', @handler)
120
+ if Nokogiri.uses_libxml?
121
+ @xml.xpath('//employee[thing("asdf")]', @handler)
122
+ else
123
+ @xml.xpath('//employee[nokogiri:thing("asdf")]', @ns, @handler)
124
+ end
80
125
  assert_equal(set.length, @handler.things.length)
81
126
  assert_equal(['asdf'] * set.length, @handler.things)
82
127
  end
83
128
 
84
129
  def test_custom_xpath_gets_true_booleans
85
130
  set = @xml.xpath('//employee')
86
- @xml.xpath('//employee[thing(true())]', @handler)
131
+ if Nokogiri.uses_libxml?
132
+ @xml.xpath('//employee[thing(true())]', @handler)
133
+ else
134
+ @xml.xpath("//employee[nokogiri:thing(true())]", @ns, @handler)
135
+ end
87
136
  assert_equal(set.length, @handler.things.length)
88
137
  assert_equal([true] * set.length, @handler.things)
89
138
  end
90
139
 
91
140
  def test_custom_xpath_gets_false_booleans
92
141
  set = @xml.xpath('//employee')
93
- @xml.xpath('//employee[thing(false())]', @handler)
142
+ if Nokogiri.uses_libxml?
143
+ @xml.xpath('//employee[thing(false())]', @handler)
144
+ else
145
+ @xml.xpath("//employee[nokogiri:thing(false())]", @ns, @handler)
146
+ end
94
147
  assert_equal(set.length, @handler.things.length)
95
148
  assert_equal([false] * set.length, @handler.things)
96
149
  end
97
150
 
98
151
  def test_custom_xpath_gets_numbers
99
152
  set = @xml.xpath('//employee')
100
- @xml.xpath('//employee[thing(10)]', @handler)
153
+ if Nokogiri.uses_libxml?
154
+ @xml.xpath('//employee[thing(10)]', @handler)
155
+ else
156
+ @xml.xpath('//employee[nokogiri:thing(10)]', @ns, @handler)
157
+ end
101
158
  assert_equal(set.length, @handler.things.length)
102
159
  assert_equal([10] * set.length, @handler.things)
103
160
  end
104
161
 
105
162
  def test_custom_xpath_gets_node_sets
106
163
  set = @xml.xpath('//employee/name')
107
- @xml.xpath('//employee[thing(name)]', @handler)
164
+ if Nokogiri.uses_libxml?
165
+ @xml.xpath('//employee[thing(name)]', @handler)
166
+ else
167
+ @xml.xpath('//employee[nokogiri:thing(name)]', @ns, @handler)
168
+ end
108
169
  assert_equal(set.length, @handler.things.length)
109
170
  assert_equal(set.to_a, @handler.things.flatten)
110
171
  end
111
172
 
112
173
  def test_custom_xpath_gets_node_sets_and_returns_array
113
174
  set = @xml.xpath('//employee/name')
114
- @xml.xpath('//employee[returns_array(name)]', @handler)
175
+ if Nokogiri.uses_libxml?
176
+ @xml.xpath('//employee[returns_array(name)]', @handler)
177
+ else
178
+ @xml.xpath('//employee[nokogiri:returns_array(name)]', @ns, @handler)
179
+ end
115
180
  assert_equal(set.length, @handler.things.length)
116
181
  assert_equal(set.to_a, @handler.things.flatten)
117
182
  end
@@ -121,7 +186,9 @@ module Nokogiri
121
186
  def awesome! ; end
122
187
  end
123
188
  util_decorate(@xml, x)
124
- set = @xml.xpath('//employee/name')
189
+
190
+ assert @xml.xpath('//employee/name')
191
+
125
192
  @xml.xpath('//employee[saves_node_set(name)]', @handler)
126
193
  assert_equal @xml, @handler.things.document
127
194
  assert @handler.things.respond_to?(:awesome!)
@@ -131,7 +198,7 @@ module Nokogiri
131
198
  doc = "<html><body id='foo'><foo>hi</foo></body></html>"
132
199
  xpath = 'id("foo")//foo'
133
200
  nokogiri = Nokogiri::HTML.parse(doc)
134
- tree = nokogiri.xpath(xpath)
201
+ assert nokogiri.xpath(xpath)
135
202
  end
136
203
  end
137
204
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 1
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 4
8
- - 2
9
- - 1
10
- version: 1.4.2.1
9
+ - 3
10
+ version: 1.4.3
11
11
  platform: x86-mswin32
12
12
  authors:
13
13
  - Aaron Patterson
@@ -16,16 +16,18 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-02 00:00:00 -07:00
19
+ date: 2010-07-28 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rubyforge
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
30
+ hash: 7
29
31
  segments:
30
32
  - 2
31
33
  - 0
@@ -37,9 +39,11 @@ dependencies:
37
39
  name: racc
38
40
  prerelease: false
39
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
40
43
  requirements:
41
44
  - - ">="
42
45
  - !ruby/object:Gem::Version
46
+ hash: 3
43
47
  segments:
44
48
  - 0
45
49
  version: "0"
@@ -49,9 +53,11 @@ dependencies:
49
53
  name: rexical
50
54
  prerelease: false
51
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
52
57
  requirements:
53
58
  - - ">="
54
59
  - !ruby/object:Gem::Version
60
+ hash: 3
55
61
  segments:
56
62
  - 0
57
63
  version: "0"
@@ -61,9 +67,11 @@ dependencies:
61
67
  name: rake-compiler
62
68
  prerelease: false
63
69
  requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
64
71
  requirements:
65
72
  - - ">="
66
73
  - !ruby/object:Gem::Version
74
+ hash: 3
67
75
  segments:
68
76
  - 0
69
77
  version: "0"
@@ -73,9 +81,11 @@ dependencies:
73
81
  name: minitest
74
82
  prerelease: false
75
83
  requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
76
85
  requirements:
77
86
  - - ">="
78
87
  - !ruby/object:Gem::Version
88
+ hash: 15
79
89
  segments:
80
90
  - 1
81
91
  - 6
@@ -87,9 +97,11 @@ dependencies:
87
97
  name: hoe
88
98
  prerelease: false
89
99
  requirement: &id006 !ruby/object:Gem::Requirement
100
+ none: false
90
101
  requirements:
91
102
  - - ">="
92
103
  - !ruby/object:Gem::Version
104
+ hash: 23
93
105
  segments:
94
106
  - 2
95
107
  - 6
@@ -132,6 +144,7 @@ extra_rdoc_files:
132
144
  - ext/nokogiri/xml_entity_decl.c
133
145
  - ext/nokogiri/xml_entity_reference.c
134
146
  - ext/nokogiri/xml_io.c
147
+ - ext/nokogiri/xml_libxml2_hacks.c
135
148
  - ext/nokogiri/xml_namespace.c
136
149
  - ext/nokogiri/xml_node.c
137
150
  - ext/nokogiri/xml_node_set.c
@@ -193,6 +206,8 @@ files:
193
206
  - ext/nokogiri/xml_entity_reference.h
194
207
  - ext/nokogiri/xml_io.c
195
208
  - ext/nokogiri/xml_io.h
209
+ - ext/nokogiri/xml_libxml2_hacks.c
210
+ - ext/nokogiri/xml_libxml2_hacks.h
196
211
  - ext/nokogiri/xml_namespace.c
197
212
  - ext/nokogiri/xml_namespace.h
198
213
  - ext/nokogiri/xml_node.c
@@ -306,7 +321,6 @@ files:
306
321
  - lib/nokogiri/html/sax/parser_context.rb
307
322
  - lib/nokogiri/syntax_error.rb
308
323
  - lib/nokogiri/version.rb
309
- - lib/nokogiri/version_warning.rb
310
324
  - lib/nokogiri/xml.rb
311
325
  - lib/nokogiri/xml/attr.rb
312
326
  - lib/nokogiri/xml/attribute_decl.rb
@@ -437,23 +451,27 @@ rdoc_options:
437
451
  require_paths:
438
452
  - lib
439
453
  required_ruby_version: !ruby/object:Gem::Requirement
454
+ none: false
440
455
  requirements:
441
456
  - - ">="
442
457
  - !ruby/object:Gem::Version
458
+ hash: 3
443
459
  segments:
444
460
  - 0
445
461
  version: "0"
446
462
  required_rubygems_version: !ruby/object:Gem::Requirement
463
+ none: false
447
464
  requirements:
448
465
  - - ">="
449
466
  - !ruby/object:Gem::Version
467
+ hash: 3
450
468
  segments:
451
469
  - 0
452
470
  version: "0"
453
471
  requirements: []
454
472
 
455
473
  rubyforge_project: nokogiri
456
- rubygems_version: 1.3.6
474
+ rubygems_version: 1.3.7
457
475
  signing_key:
458
476
  specification_version: 3
459
477
  summary: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser"
@@ -1,14 +0,0 @@
1
- module Nokogiri
2
- if self.is_2_6_16?
3
- VERSION_INFO['warnings'] << "libxml 2.6.16 is old and buggy."
4
- if !defined?(I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2)
5
- warn <<-eom
6
- HI. You're using libxml2 version 2.6.16 which is over 4 years old and has
7
- plenty of bugs. We suggest that for maximum HTML/XML parsing pleasure, you
8
- upgrade your version of libxml2 and re-install nokogiri. If you like using
9
- libxml2 version 2.6.16, but don't like this warning, please define the constant
10
- I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2 before requring nokogiri.
11
- eom
12
- end
13
- end
14
- end