nokogiri 1.8.2 → 1.8.3

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -14
  3. data/CHANGELOG.md +43 -1
  4. data/LICENSE.md +2 -1
  5. data/Manifest.txt +3 -0
  6. data/README.md +20 -21
  7. data/Rakefile +2 -8
  8. data/SECURITY.md +19 -0
  9. data/build_all +2 -2
  10. data/dependencies.yml +11 -11
  11. data/ext/nokogiri/extconf.rb +1 -1
  12. data/ext/nokogiri/html_element_description.c +14 -14
  13. data/ext/nokogiri/xml_cdata.c +6 -4
  14. data/ext/nokogiri/xml_document.c +2 -3
  15. data/ext/nokogiri/xml_dtd.c +2 -2
  16. data/ext/nokogiri/xml_io.c +1 -0
  17. data/ext/nokogiri/xml_namespace.c +3 -9
  18. data/ext/nokogiri/xml_namespace.h +2 -0
  19. data/ext/nokogiri/xml_node.c +23 -15
  20. data/ext/nokogiri/xml_node_set.c +5 -4
  21. data/ext/nokogiri/xml_node_set.h +0 -1
  22. data/ext/nokogiri/xslt_stylesheet.c +2 -2
  23. data/lib/nokogiri/css/parser.rb +108 -90
  24. data/lib/nokogiri/css/parser.y +13 -2
  25. data/lib/nokogiri/css/tokenizer.rb +1 -1
  26. data/lib/nokogiri/css/tokenizer.rex +4 -4
  27. data/lib/nokogiri/css/xpath_visitor.rb +10 -3
  28. data/lib/nokogiri/html/document_fragment.rb +11 -1
  29. data/lib/nokogiri/version.rb +1 -1
  30. data/lib/nokogiri/xml/node.rb +58 -0
  31. data/lib/nokogiri/xml/node_set.rb +32 -18
  32. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +78 -0
  33. data/ports/archives/libxml2-2.9.8.tar.gz +0 -0
  34. data/test/css/test_nthiness.rb +21 -21
  35. data/test/css/test_parser.rb +17 -0
  36. data/test/html/test_attributes.rb +85 -0
  37. data/test/html/test_document_fragment.rb +7 -1
  38. data/test/test_css_cache.rb +5 -3
  39. data/test/xml/sax/test_parser.rb +9 -1
  40. data/test/xml/sax/test_push_parser.rb +60 -0
  41. data/test/xml/test_cdata.rb +1 -1
  42. data/test/xml/test_document.rb +5 -5
  43. data/test/xml/test_dtd.rb +4 -4
  44. data/test/xml/test_node.rb +89 -6
  45. data/test/xml/test_node_attributes.rb +3 -3
  46. data/test/xml/test_node_reparenting.rb +18 -0
  47. data/test/xml/test_node_set.rb +31 -4
  48. data/test/xml/test_reader.rb +13 -1
  49. data/test/xml/test_syntax_error.rb +3 -3
  50. data/test/xml/test_xpath.rb +8 -0
  51. metadata +25 -4
  52. data/ports/archives/libxml2-2.9.7.tar.gz +0 -0
@@ -51,6 +51,12 @@ module Nokogiri
51
51
  @list.each { |x| assert_nil x['class'] }
52
52
  end
53
53
 
54
+ def test_remove_attribute
55
+ @list.each { |x| x['class'] = 'blah' }
56
+ assert_equal @list, @list.remove_attribute('class')
57
+ @list.each { |x| assert_nil x['class'] }
58
+ end
59
+
54
60
  def test_add_class
55
61
  assert_equal @list, @list.add_class('bar')
56
62
  @list.each { |x| assert_equal 'bar', x['class'] }
@@ -62,6 +68,17 @@ module Nokogiri
62
68
  @list.each { |x| assert_equal 'bar baz', x['class'] }
63
69
  end
64
70
 
71
+ def test_append_class
72
+ assert_equal @list, @list.append_class('bar')
73
+ @list.each { |x| assert_equal 'bar', x['class'] }
74
+
75
+ @list.append_class('bar')
76
+ @list.each { |x| assert_equal 'bar bar', x['class'] }
77
+
78
+ @list.append_class('baz')
79
+ @list.each { |x| assert_equal 'bar bar baz', x['class'] }
80
+ end
81
+
65
82
  def test_remove_class_with_no_class
66
83
  assert_equal @list, @list.remove_class('bar')
67
84
  @list.each { |e| assert_nil e['class'] }
@@ -408,7 +425,7 @@ module Nokogiri
408
425
  def test_delete_on_empty_set
409
426
  empty_set = Nokogiri::XML::NodeSet.new @xml, []
410
427
  employee = @xml.at_xpath("//employee")
411
- assert_equal nil, empty_set.delete(employee)
428
+ assert_nil empty_set.delete(employee)
412
429
  end
413
430
 
414
431
  def test_unlink
@@ -563,6 +580,8 @@ module Nokogiri
563
580
 
564
581
  assert_equal 3, employees.index(employees[3])
565
582
  assert_nil employees.index(other)
583
+ assert_equal 3, employees.index {|employee| employee.search("employeeId/text()").to_s == "EMP0004" }
584
+ assert_nil employees.index {|employee| employee.search("employeeId/text()").to_s == "EMP0000" }
566
585
  end
567
586
 
568
587
  def test_slice_too_far
@@ -573,9 +592,9 @@ module Nokogiri
573
592
 
574
593
  def test_slice_on_empty_node_set
575
594
  empty_set = Nokogiri::XML::NodeSet.new @xml, []
576
- assert_equal nil, empty_set[99]
577
- assert_equal nil, empty_set[99..101]
578
- assert_equal nil, empty_set[99,2]
595
+ assert_nil empty_set[99]
596
+ assert_nil empty_set[99..101]
597
+ assert_nil empty_set[99,2]
579
598
  end
580
599
 
581
600
  def test_slice_waaaaaay_off_the_end
@@ -653,6 +672,14 @@ module Nokogiri
653
672
  assert ! empty_set.include?(employee)
654
673
  end
655
674
 
675
+ def test_each
676
+ employees = @xml.search("//employee")
677
+ enum = employees.each
678
+ assert_instance_of Enumerator, enum
679
+ assert_equal enum.next, employees[0]
680
+ assert_equal enum.next, employees[1]
681
+ end
682
+
656
683
  def test_children
657
684
  employees = @xml.search("//employee")
658
685
  count = 0
@@ -4,6 +4,18 @@ require "helper"
4
4
  module Nokogiri
5
5
  module XML
6
6
  class TestReader < Nokogiri::TestCase
7
+ class NonStringIO
8
+ def read(size)
9
+ :invalid_object
10
+ end
11
+ end
12
+
13
+ def test_io_non_string
14
+ io = NonStringIO.new
15
+ reader = Nokogiri::XML::Reader(io)
16
+ assert_equal io, reader.source
17
+ end
18
+
7
19
  def test_from_io_sets_io_as_source
8
20
  io = File.open SNUGGLES_FILE
9
21
  reader = Nokogiri::XML::Reader.from_io(io)
@@ -601,7 +613,7 @@ module Nokogiri
601
613
  reader = Nokogiri::XML::Reader("<root xmlns='bob'><el attr='fred' /></root>")
602
614
  reader.read # root
603
615
  reader.read # el
604
- assert_equal nil, reader.attribute('other')
616
+ assert_nil reader.attribute('other')
605
617
  end
606
618
  end
607
619
  end
@@ -27,9 +27,9 @@ module Nokogiri
27
27
  error = bad_doc.errors.first
28
28
 
29
29
  assert_equal "The element type \"root\" must be terminated by the matching end-tag \"</root>\".", error.message
30
- assert_equal nil, error.line
31
- assert_equal nil, error.column
32
- assert_equal nil, error.level
30
+ assert_nil error.line
31
+ assert_nil error.column
32
+ assert_nil error.level
33
33
  end
34
34
  end
35
35
  end
@@ -108,6 +108,14 @@ module Nokogiri
108
108
  assert_equal 3, node.search('.//div', 'p.blah').length
109
109
  end
110
110
 
111
+ def test_css_search_with_ambiguous_integer_or_string_attributes
112
+ # https://github.com/sparklemotion/nokogiri/issues/711
113
+ html = "<body><div><img width=200>"
114
+ doc = Nokogiri::HTML(html)
115
+ assert_not_nil doc.at_css("img[width='200']")
116
+ assert_not_nil doc.at_css("img[width=200]")
117
+ end
118
+
111
119
  def test_css_search_uses_custom_selectors_with_arguments
112
120
  set = @xml.css('employee > address:my_filter("domestic", "Yes")', @handler)
113
121
  assert set.length > 0
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.8.2
4
+ version: 1.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
@@ -9,10 +9,12 @@ authors:
9
9
  - Yoko Harada
10
10
  - Tim Elliott
11
11
  - Akinori MUSHA
12
+ - John Shahid
13
+ - Lars Kanis
12
14
  autorequire:
13
15
  bindir: bin
14
16
  cert_chain: []
15
- date: 2018-01-29 00:00:00.000000000 Z
17
+ date: 2018-06-16 00:00:00.000000000 Z
16
18
  dependencies:
17
19
  - !ruby/object:Gem::Dependency
18
20
  name: mini_portile2
@@ -214,12 +216,27 @@ description: |-
214
216
  Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among
215
217
  Nokogiri's many features is the ability to search documents via XPath
216
218
  or CSS3 selectors.
219
+
220
+ * http://nokogiri.org
221
+ * [Installation Help](http://nokogiri.org/tutorials/installing_nokogiri.html)
222
+ * [Tutorials](http://nokogiri.org)
223
+ * [GitHub](https://github.com/sparklemotion/nokogiri)
224
+ * [Mailing List](https://groups.google.com/group/nokogiri-talk)
225
+ * [Bug Reports](https://github.com/sparklemotion/nokogiri/issues)
226
+ * [Chat/Gitter](https://gitter.im/sparklemotion/nokogiri)
227
+
228
+ [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/nokogiri/jobs/ruby-2.4-system/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/nokogiri?groups=master)
229
+ [![Code Climate](https://codeclimate.com/github/sparklemotion/nokogiri.svg)](https://codeclimate.com/github/sparklemotion/nokogiri)
230
+ [![Version Eye](https://www.versioneye.com/ruby/nokogiri/badge.png)](https://www.versioneye.com/ruby/nokogiri)
231
+ [![Join the chat at https://gitter.im/sparklemotion/nokogiri](https://badges.gitter.im/sparklemotion/nokogiri.svg)](https://gitter.im/sparklemotion/nokogiri?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
217
232
  email:
218
233
  - aaronp@rubyforge.org
219
234
  - mike.dalessio@gmail.com
220
235
  - yokolet@gmail.com
221
236
  - tle@holymonkey.com
222
237
  - knu@idaemons.org
238
+ - jvshahid@gmail.com
239
+ - lars@greiz-reinsdorf.de
223
240
  executables:
224
241
  - nokogiri
225
242
  extensions:
@@ -233,6 +250,7 @@ extra_rdoc_files:
233
250
  - Manifest.txt
234
251
  - README.md
235
252
  - ROADMAP.md
253
+ - SECURITY.md
236
254
  - STANDARD_RESPONSES.md
237
255
  - Y_U_NO_GEMSPEC.md
238
256
  - suppressions/README.txt
@@ -287,6 +305,7 @@ files:
287
305
  - README.md
288
306
  - ROADMAP.md
289
307
  - Rakefile
308
+ - SECURITY.md
290
309
  - STANDARD_RESPONSES.md
291
310
  - Y_U_NO_GEMSPEC.md
292
311
  - appveyor.yml
@@ -426,8 +445,9 @@ files:
426
445
  - lib/nokogiri/xslt.rb
427
446
  - lib/nokogiri/xslt/stylesheet.rb
428
447
  - lib/xsd/xmlparser/nokogiri.rb
448
+ - patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
429
449
  - patches/sort-patches-by-date
430
- - ports/archives/libxml2-2.9.7.tar.gz
450
+ - ports/archives/libxml2-2.9.8.tar.gz
431
451
  - ports/archives/libxslt-1.1.32.tar.gz
432
452
  - suppressions/README.txt
433
453
  - suppressions/nokogiri_ruby-2.supp
@@ -479,6 +499,7 @@ files:
479
499
  - test/html/sax/test_parser_context.rb
480
500
  - test/html/sax/test_parser_text.rb
481
501
  - test/html/sax/test_push_parser.rb
502
+ - test/html/test_attributes.rb
482
503
  - test/html/test_builder.rb
483
504
  - test/html/test_document.rb
484
505
  - test/html/test_document_encoding.rb
@@ -542,7 +563,7 @@ files:
542
563
  - test/xml/test_xpath.rb
543
564
  - test/xslt/test_custom_functions.rb
544
565
  - test/xslt/test_exception_handling.rb
545
- homepage: http://nokogiri.org
566
+ homepage:
546
567
  licenses:
547
568
  - MIT
548
569
  metadata: {}