nokogiri 1.6.5 → 1.6.6.1

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +5 -0
  3. data/.travis.yml +10 -20
  4. data/CHANGELOG.ja.rdoc +28 -1
  5. data/CHANGELOG.rdoc +28 -1
  6. data/Gemfile +1 -1
  7. data/Manifest.txt +5 -1
  8. data/README.ja.rdoc +10 -9
  9. data/README.rdoc +6 -9
  10. data/ROADMAP.md +15 -3
  11. data/Rakefile +1 -3
  12. data/bin/nokogiri +48 -8
  13. data/ext/nokogiri/extconf.rb +18 -3
  14. data/ext/nokogiri/xml_comment.c +17 -2
  15. data/ext/nokogiri/xml_node.c +66 -6
  16. data/ext/nokogiri/xml_syntax_error.c +4 -0
  17. data/ext/nokogiri/xml_syntax_error.h +1 -0
  18. data/lib/nokogiri.rb +2 -2
  19. data/lib/nokogiri/decorators/slop.rb +7 -8
  20. data/lib/nokogiri/html/document_fragment.rb +0 -2
  21. data/lib/nokogiri/html/sax/push_parser.rb +22 -2
  22. data/lib/nokogiri/version.rb +1 -1
  23. data/lib/nokogiri/xml.rb +1 -0
  24. data/lib/nokogiri/xml/document.rb +4 -4
  25. data/lib/nokogiri/xml/document_fragment.rb +39 -2
  26. data/lib/nokogiri/xml/node.rb +11 -181
  27. data/lib/nokogiri/xml/node_set.rb +41 -85
  28. data/lib/nokogiri/xml/searchable.rb +221 -0
  29. data/ports/patches/sort-patches-by-date +25 -0
  30. data/test/css/test_nthiness.rb +1 -1
  31. data/test/html/sax/test_push_parser.rb +87 -0
  32. data/test/html/test_document.rb +20 -5
  33. data/test/html/test_document_fragment.rb +25 -0
  34. data/test/xml/test_attr.rb +5 -2
  35. data/test/xml/test_builder.rb +27 -1
  36. data/test/xml/test_comment.rb +11 -0
  37. data/test/xml/test_document.rb +34 -0
  38. data/test/xml/test_document_fragment.rb +40 -9
  39. data/test/xml/test_namespace.rb +1 -0
  40. data/test/xml/test_node.rb +37 -1
  41. data/test/xml/test_node_set.rb +56 -36
  42. data/test/xml/test_xpath.rb +65 -19
  43. data/test_all +11 -1
  44. metadata +11 -7
  45. data/tasks/nokogiri.org.rb +0 -24
@@ -13,12 +13,6 @@ module Nokogiri
13
13
  # functions to be in a namespace. This is not required by XPath, afaik,
14
14
  # but it is an usual convention though.
15
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
16
  # Yours truly,
23
17
  #
24
18
  # The guy whose headaches belong to Nokogiri JRuby impl.
@@ -69,6 +63,10 @@ module Nokogiri
69
63
  assert_equal 4, @xml.xpath('//address[@domestic=$value]', nil, :value => 'Yes').length
70
64
  end
71
65
 
66
+ def test_variable_binding_with_search
67
+ assert_equal 4, @xml.search('//address[@domestic=$value]', nil, :value => 'Yes').length
68
+ end
69
+
72
70
  def test_unknown_attribute
73
71
  assert_equal 0, @xml.xpath('//employee[@id="asdfasdf"]/@fooo').length
74
72
  assert_nil @xml.xpath('//employee[@id="asdfasdf"]/@fooo')[0]
@@ -86,12 +84,28 @@ module Nokogiri
86
84
  assert_equal 'foo', @xml.xpath('concat("fo", "o")')
87
85
  end
88
86
 
87
+ def test_node_search_with_multiple_queries
88
+ xml = '<document>
89
+ <thing>
90
+ <div class="title">important thing</div>
91
+ </thing>
92
+ <thing>
93
+ <div class="content">stuff</div>
94
+ </thing>
95
+ <thing>
96
+ <p class="blah">more stuff</div>
97
+ </thing>
98
+ </document>'
99
+ node = Nokogiri::XML(xml).root
100
+ assert_kind_of Nokogiri::XML::Node, node
101
+
102
+ assert_equal 3, node.xpath('.//div', './/p').length
103
+ assert_equal 3, node.css('.title', '.content', 'p').length
104
+ assert_equal 3, node.search('.//div', 'p.blah').length
105
+ end
106
+
89
107
  def test_css_search_uses_custom_selectors_with_arguments
90
- set = if Nokogiri.uses_libxml?
91
- @xml.css('employee > address:my_filter("domestic", "Yes")', @handler)
92
- else
93
- @xml.xpath("//employee/address[nokogiri:my_filter(., \"domestic\", \"Yes\")]", @ns, @handler)
94
- end
108
+ set = @xml.css('employee > address:my_filter("domestic", "Yes")', @handler)
95
109
  assert set.length > 0
96
110
  set.each do |node|
97
111
  assert_equal 'Yes', node['domestic']
@@ -100,15 +114,31 @@ module Nokogiri
100
114
 
101
115
  def test_css_search_uses_custom_selectors
102
116
  set = @xml.xpath('//employee')
103
- if Nokogiri.uses_libxml?
104
- @xml.css('employee:thing()', @handler)
105
- else
106
- @xml.xpath("//employee[nokogiri:thing(.)]", @ns, @handler)
107
- end
117
+ @xml.css('employee:thing()', @handler)
108
118
  assert_equal(set.length, @handler.things.length)
109
119
  assert_equal(set.to_a, @handler.things.flatten)
110
120
  end
111
121
 
122
+ def test_search_with_css_query_uses_custom_selectors_with_arguments
123
+ set = @xml.search('employee > address:my_filter("domestic", "Yes")', @handler)
124
+ assert set.length > 0
125
+ set.each do |node|
126
+ assert_equal 'Yes', node['domestic']
127
+ end
128
+ end
129
+
130
+ def test_search_with_xpath_query_uses_custom_selectors_with_arguments
131
+ set = if Nokogiri.uses_libxml?
132
+ @xml.search('//employee/address[my_filter(., "domestic", "Yes")]', @handler)
133
+ else
134
+ @xml.search('//employee/address[nokogiri:my_filter(., "domestic", "Yes")]', @ns, @handler)
135
+ end
136
+ assert set.length > 0
137
+ set.each do |node|
138
+ assert_equal 'Yes', node['domestic']
139
+ end
140
+ end
141
+
112
142
  def test_pass_self_to_function
113
143
  set = if Nokogiri.uses_libxml?
114
144
  @xml.xpath('//employee/address[my_filter(., "domestic", "Yes")]', @handler)
@@ -179,6 +209,22 @@ module Nokogiri
179
209
  assert_send [elapsed_time, :<, time_limit], "XPath is taking too long"
180
210
  end
181
211
 
212
+ # issue #1109 (jruby impl's xpath() cache not being cleared on attr removal)
213
+ def test_xpath_results_cache_should_get_cleared_on_attr_removal
214
+ doc = Nokogiri::HTML('<html><div name="foo"></div></html>')
215
+ element = doc.at_xpath('//div[@name="foo"]')
216
+ element.remove_attribute('name')
217
+ assert_nil doc.at_xpath('//div[@name="foo"]')
218
+ end
219
+
220
+ # issue #1109 (jruby impl's xpath() cache not being cleared on attr update )
221
+ def test_xpath_results_cache_should_get_cleared_on_attr_update
222
+ doc = Nokogiri::HTML('<html><div name="foo"></div></html>')
223
+ element = doc.at_xpath('//div[@name="foo"]')
224
+ element['name'] = 'bar'
225
+ assert_nil doc.at_xpath('//div[@name="foo"]')
226
+ end
227
+
182
228
  def test_custom_xpath_function_returns_string
183
229
  if Nokogiri.uses_libxml?
184
230
  result = @xml.xpath('thing("asdf")', @handler)
@@ -332,7 +378,7 @@ END
332
378
  <RecordReference>a</RecordReference>
333
379
  </Product>
334
380
  </ONIXMessage>}
335
-
381
+
336
382
  xml_doc = Nokogiri::XML(xml_string)
337
383
  onix = xml_doc.children.first
338
384
  assert_equal 'a', onix.at_xpath('xmlns:Product').at_xpath('xmlns:RecordReference').text
@@ -350,7 +396,7 @@ END
350
396
  <title>Artikkelin otsikko Hydrangea artiklan 1</title>
351
397
  </titleInfo>
352
398
  </mods>}
353
-
399
+
354
400
  xml_doc = Nokogiri::XML(xml_string)
355
401
  ns_hash = {'mods'=>'http://www.loc.gov/mods/v3'}
356
402
  node = xml_doc.at_xpath('//mods:titleInfo[1]',ns_hash)
@@ -371,7 +417,7 @@ END
371
417
  <title>Artikkelin otsikko Hydrangea artiklan 1</title>
372
418
  </titleInfo>
373
419
  </mods>}
374
-
420
+
375
421
  xml_doc = Nokogiri::XML(xml_string)
376
422
  ns_hash = {'mods'=>'http://www.loc.gov/mods/v3'}
377
423
  node = xml_doc.at_xpath('//mods:titleInfo[1]',ns_hash)
data/test_all CHANGED
@@ -10,7 +10,17 @@
10
10
  # (e.g., 1.9.3's glob_helper). ["rake test:valgrind:suppression"]
11
11
  #
12
12
 
13
- RUBIES="ruby-2.2.0-preview1 ruby-2.1 ruby-2.0.0-p481 ruby-1.9.3 jruby-1.7.15"
13
+ # I'd add rubinius, but rvm errors when building it on my machine. :(
14
+ RUBIES="\
15
+ ruby-2.2 \
16
+ ruby-2.1 \
17
+ ruby-2.0.0-p598 \
18
+ ruby-1.9.3-p551 \
19
+ ruby-1.9.2-p330 \
20
+ jruby-9.0.0.0.pre1 \
21
+ jruby-1.7.18
22
+ "
23
+
14
24
  TEST_LOG=test.log
15
25
  VALGRIND_LOG=valgrind.log
16
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.5
4
+ version: 1.6.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-11-26 00:00:00.000000000 Z
15
+ date: 2015-01-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mini_portile
@@ -60,16 +60,16 @@ dependencies:
60
60
  name: hoe-debugging
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
- - - '>='
63
+ - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: 1.0.3
65
+ version: 1.2.0
66
66
  type: :development
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - '>='
70
+ - - ~>
71
71
  - !ruby/object:Gem::Version
72
- version: 1.0.3
72
+ version: 1.2.0
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: hoe-gemspec
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -245,6 +245,7 @@ extra_rdoc_files:
245
245
  - ext/nokogiri/xslt_stylesheet.c
246
246
  files:
247
247
  - .autotest
248
+ - .cross_rubies
248
249
  - .editorconfig
249
250
  - .gemtest
250
251
  - .travis.yml
@@ -385,6 +386,7 @@ files:
385
386
  - lib/nokogiri/xml/sax/parser_context.rb
386
387
  - lib/nokogiri/xml/sax/push_parser.rb
387
388
  - lib/nokogiri/xml/schema.rb
389
+ - lib/nokogiri/xml/searchable.rb
388
390
  - lib/nokogiri/xml/syntax_error.rb
389
391
  - lib/nokogiri/xml/text.rb
390
392
  - lib/nokogiri/xml/xpath.rb
@@ -409,12 +411,12 @@ files:
409
411
  - ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
410
412
  - ports/patches/libxslt/0014-Fix-for-bug-436589.patch
411
413
  - ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch
414
+ - ports/patches/sort-patches-by-date
412
415
  - suppressions/README.txt
413
416
  - suppressions/nokogiri_ree-1.8.7.358.supp
414
417
  - suppressions/nokogiri_ruby-1.8.7.370.supp
415
418
  - suppressions/nokogiri_ruby-1.9.2.320.supp
416
419
  - suppressions/nokogiri_ruby-1.9.3.327.supp
417
- - tasks/nokogiri.org.rb
418
420
  - tasks/test.rb
419
421
  - test/css/test_nthiness.rb
420
422
  - test/css/test_parser.rb
@@ -459,6 +461,7 @@ files:
459
461
  - test/helper.rb
460
462
  - test/html/sax/test_parser.rb
461
463
  - test/html/sax/test_parser_context.rb
464
+ - test/html/sax/test_push_parser.rb
462
465
  - test/html/test_builder.rb
463
466
  - test/html/test_document.rb
464
467
  - test/html/test_document_encoding.rb
@@ -595,6 +598,7 @@ test_files:
595
598
  - test/html/test_document_fragment.rb
596
599
  - test/html/sax/test_parser_context.rb
597
600
  - test/html/sax/test_parser.rb
601
+ - test/html/sax/test_push_parser.rb
598
602
  - test/html/test_element_description.rb
599
603
  - test/html/test_document.rb
600
604
  - test/html/test_named_characters.rb
@@ -1,24 +0,0 @@
1
- #
2
- # note that this file will only work if you've got the `nokogiri.org`
3
- # repo checked out, and you've got an rvm gemset "1.8.7@nokogiri"
4
- # bundled with both nokogiri's and nokogiri.org's gems.
5
- #
6
- namespace :docs do
7
- desc "generate HTML docs for nokogiri.org"
8
- task :website do
9
- system 'rvm use 1.8.7@nokogiri' # see above
10
- title = "#{HOE.name}-#{HOE.version} Documentation"
11
-
12
- options = []
13
- options << "--main=#{HOE.readme_file}"
14
- options << '--format=activerecord'
15
- options << '--threads=1'
16
- options << "--title=#{title.inspect}"
17
-
18
- options += HOE.spec.require_paths
19
- options += HOE.spec.extra_rdoc_files
20
- require 'rdoc/rdoc'
21
- ENV['RAILS_ROOT'] ||= File.expand_path(File.join('..', 'nokogiri_ws'))
22
- RDoc::RDoc.new.document options
23
- end
24
- end