nokogiri 1.8.1-x86-mingw32 → 1.8.2-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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fe55bd331c92bca77cde59b9f8d2a17f9811a7b
4
- data.tar.gz: d0a5aefe04863ddc04fbaa3704ef0262537807c0
3
+ metadata.gz: b321e3e4768e213ed986c4ba762aee5549475452
4
+ data.tar.gz: 2e472c6aca19243500f0e4165982ace41382d0db
5
5
  SHA512:
6
- metadata.gz: 15e895487d61fbb9c05ca7e73bd5a69c8257e1498b65e0dd0e5ea60d6f9d797bdc7140f8179a0c7de5f1f6b3768899e2955284b4f5f9e82bcd2b87d9cff22174
7
- data.tar.gz: 817e795d82f36ee7f89d7205be3e4f6db1cd609f2afe711f6c2854fe833d4f02635aabf2e09226d5e24488cbb807be01122736f9b2643d79773a32deaa09296f
6
+ metadata.gz: 65f2ae8d650911a23aae669f595af1735e38798b7c90fda8ab376d65c8326a31722caa06e8d7f4186724b03898f2d19755f1f2a4c62d9f4f9fa00c8064f66fcd
7
+ data.tar.gz: caafb09e4d1ee36ba986e0bacfa8f79a2f12c894702413e93a9a25d92fc4d5c797d81cb59046c813caa8c254d6ea03080eb5e91d9951f7bd40868183b14cac05
@@ -1,3 +1,5 @@
1
+ 2.5.0:i686-w64-mingw32
2
+ 2.5.0:x86_64-w64-mingw32
1
3
  2.4.0:i686-w64-mingw32
2
4
  2.4.0:x86_64-w64-mingw32
3
5
  2.3.0:i686-w64-mingw32
@@ -1,3 +1,29 @@
1
+ # 1.8.2 / 2018-01-29
2
+
3
+ ## Security Notes
4
+
5
+ [MRI] The update of vendored libxml2 from 2.9.5 to 2.9.7 addresses at least one published vulnerability, CVE-2017-15412. [#1714 has complete details]
6
+
7
+
8
+ ## Dependencies
9
+
10
+ * [MRI] libxml2 is updated from 2.9.5 to 2.9.7
11
+ * [MRI] libxml2 is updated from 1.1.30 to 1.1.32
12
+
13
+
14
+ ## Features
15
+
16
+ * [MRI] OpenBSD installation should be a bit easier now. [#1685] (Thanks, @jeremyevans!)
17
+ * [MRI] Cross-built Windows gems now support Ruby 2.5
18
+
19
+
20
+ ## Bug fixes
21
+
22
+ * Node#serialize once again returns UTF-8-encoded strings. [#1659]
23
+ * [JRuby] made SAX parsing of characters consistent with C implementation [#1676] (Thanks, @andrew-aladev!)
24
+ * [MRI] Predefined entities, when inspected, no longer cause a segfault. [#1238]
25
+
26
+
1
27
  # 1.8.1 / 2017-09-19
2
28
 
3
29
  ## Dependencies
data/Gemfile CHANGED
@@ -13,10 +13,10 @@ gem "hoe-git", "~>1.6", :group => [:development, :test]
13
13
  gem "minitest", "~>5.8.4", :group => [:development, :test]
14
14
  gem "rake", "~>12.0", :group => [:development, :test]
15
15
  gem "rake-compiler", "~>1.0.3", :group => [:development, :test]
16
- gem "rake-compiler-dock", "~>0.6.0", :group => [:development, :test]
16
+ gem "rake-compiler-dock", "~>0.6.2", :group => [:development, :test]
17
17
  gem "racc", "~>1.4.14", :group => [:development, :test], :platform => [:ruby, :mingw, :x64_mingw]
18
18
  gem "rexical", "~>1.0.5", :group => [:development, :test], :platform => [:ruby, :mingw, :x64_mingw]
19
- gem "concourse", "~>0.11", :group => [:development, :test]
19
+ gem "concourse", "~>0.15", :group => [:development, :test]
20
20
  gem "rdoc", "~>4.0", :group => [:development, :test]
21
21
  gem "hoe", "~>3.16", :group => [:development, :test]
22
22
 
@@ -217,6 +217,7 @@ lib/nokogiri/xml/dtd.rb
217
217
  lib/nokogiri/xml/element_content.rb
218
218
  lib/nokogiri/xml/element_decl.rb
219
219
  lib/nokogiri/xml/entity_decl.rb
220
+ lib/nokogiri/xml/entity_reference.rb
220
221
  lib/nokogiri/xml/namespace.rb
221
222
  lib/nokogiri/xml/node.rb
222
223
  lib/nokogiri/xml/node/save_options.rb
@@ -297,6 +298,7 @@ test/files/xinclude.xml
297
298
  test/helper.rb
298
299
  test/html/sax/test_parser.rb
299
300
  test/html/sax/test_parser_context.rb
301
+ test/html/sax/test_parser_text.rb
300
302
  test/html/sax/test_push_parser.rb
301
303
  test/html/test_builder.rb
302
304
  test/html/test_document.rb
@@ -324,6 +326,7 @@ test/xml/node/test_save_options.rb
324
326
  test/xml/node/test_subclass.rb
325
327
  test/xml/sax/test_parser.rb
326
328
  test/xml/sax/test_parser_context.rb
329
+ test/xml/sax/test_parser_text.rb
327
330
  test/xml/sax/test_push_parser.rb
328
331
  test/xml/test_attr.rb
329
332
  test/xml/test_attribute_decl.rb
data/Rakefile CHANGED
@@ -137,10 +137,10 @@ HOE = Hoe.spec 'nokogiri' do
137
137
  ["minitest", "~> 5.8.4"],
138
138
  ["rake", "~> 12.0"],
139
139
  ["rake-compiler", "~> 1.0.3"],
140
- ["rake-compiler-dock", "~> 0.6.0"],
140
+ ["rake-compiler-dock", "~> 0.6.2"],
141
141
  ["racc", "~> 1.4.14"],
142
142
  ["rexical", "~> 1.0.5"],
143
- ["concourse", "~> 0.11"],
143
+ ["concourse", "~> 0.15"],
144
144
  ]
145
145
 
146
146
  if java?
@@ -264,10 +264,7 @@ task 'bundler:gemfile' do
264
264
  end
265
265
 
266
266
  file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
267
- racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
268
- racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
269
- racc = %x{command -v racc}.strip if racc.empty?
270
- sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
267
+ sh "racc -l -o #{t.name} #{t.prerequisites.first}"
271
268
  end
272
269
 
273
270
  file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
@@ -1,24 +1,29 @@
1
1
  install:
2
- - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
3
- - SET PATH=C:\MinGW\bin;%PATH%
4
- - SET RAKEOPT=-rdevkit
2
+ - SET PATH=C:\ruby%ruby_version%\bin;%PATH%
3
+ - ps: |
4
+ if ($env:ruby_version -like "*head*") {
5
+ $(new-object net.webclient).DownloadFile("https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-$env:ruby_version.exe", "$pwd/ruby-setup.exe")
6
+ cmd /c ruby-setup.exe /verysilent /dir=C:/Ruby$env:ruby_version
7
+ }
5
8
  - ruby --version
6
9
  - gem --version
10
+ - gem install bundler --conservative
7
11
  - bundle install
8
12
 
9
13
  build: off
10
14
 
11
15
  test_script:
12
- - bundle exec rake
16
+ - bundle exec rake -rdevkit
13
17
 
14
18
  environment:
15
19
  matrix:
16
- - ruby_version: "23"
17
- - ruby_version: "23-x64"
18
- - ruby_version: "22"
19
- - ruby_version: "22-x64"
20
- - ruby_version: "21"
21
- - ruby_version: "21-x64"
22
- - ruby_version: "200"
23
- - ruby_version: "200-x64"
24
- - ruby_version: "193"
20
+ - ruby_version: head-x64
21
+ - ruby_version: 24
22
+ - ruby_version: 23-x64
23
+ - ruby_version: 22
24
+ - ruby_version: 21-x64
25
+ - ruby_version: 200
26
+
27
+ matrix:
28
+ allow_failures:
29
+ - ruby_version: head
@@ -1,10 +1,10 @@
1
1
  libxml2:
2
- version: "2.9.5"
3
- sha256: "4031c1ecee9ce7ba4f313e91ef6284164885cdb69937a123f6a83bb6a72dcd38"
2
+ version: "2.9.7"
3
+ sha256: "f63c5e7d30362ed28b38bfa1ac6313f9a80230720b7fb6c80575eeab3ff5900c"
4
4
  # manually verified checksum:
5
5
  #
6
- # $ gpg --verify libxml2-2.9.5.tar.gz.asc libxml2-2.9.5.tar.gz
7
- # gpg: Signature made Mon 04 Sep 2017 09:00:53 AM EDT using RSA key ID 596BEA5D
6
+ # $ gpg --verify libxml2-2.9.7.tar.gz.asc libxml2-2.9.7.tar.gz
7
+ # gpg: Signature made Thu 02 Nov 2017 04:17:54 PM EDT using RSA key ID 596BEA5D
8
8
  # gpg: Good signature from "Daniel Veillard (Red Hat work email) <veillard@redhat.com>"
9
9
  # gpg: aka "Daniel Veillard <Daniel.Veillard@w3.org>"
10
10
  # gpg: WARNING: This key is not certified with a trusted signature!
@@ -13,25 +13,25 @@ libxml2:
13
13
  # Subkey fingerprint: DB46 681B B91A DCEA 170F A2D4 1558 8B26 596B EA5D
14
14
  #
15
15
  # using this pgp signature:
16
- #
17
16
  # -----BEGIN PGP SIGNATURE-----
18
17
  #
19
- # iQEcBAABAgAGBQJZrU6FAAoJEBVYiyZZa+pd73cIAMZpWcbiWwFqPgEJtscDfUqs
20
- # V0LjMKYXMDZCUs9/SPV/d6yXbOWSx2PgQ0wa7eCq2KmitIKYlcwnqB1WfAgSvNc+
21
- # cK8rVwIF4MfZQTzWie6uBvwukDn3224b3qjXxJtPS6J8HmiyK6suwDX5auEgEF8f
22
- # Ac1xy0K/hfAo+W5x7bm+suPHUduI7d6pWo1hNMwW/lyPiQthT4pPElkMBeKTi4vl
23
- # HTRTVEJKjVkdQ2tJ9b5pUYE0Aa6T54SVpCyBRmTu4d/MoOX5VnXBoiZIJDbSA5cD
24
- # GLQeXjDg/tYdq9DpYuT3otYd+6VWuWdH+f6jM6L2+82rAMtOAjBm97Z45XxH31I=
25
- # =T2TF
18
+ # iQEcBAABAgAGBQJZ+31yAAoJEBVYiyZZa+pd+MMH/RTsPCo8CegAHsSUlNCae2Ay
19
+ # HpM6J7sNWs0b2xwaYRtwhewJ5z/rsCcM5nn7MeGiU8dX7W5MKF69uGXUywufRxzO
20
+ # GFoQSxO0a1z5mtGu7jC/W6DTYHFBeOJcEfMa3zUZjZ0RXqrENRhX55okse4pJPmG
21
+ # dWQphbu9G3qoCuWD7QpyI7Mjhjemmyi4Ai/4vJPO8WtB7VDfdtpuZFVCRLG2cp0X
22
+ # 90SZde+0oWJcN8oIG3FaTd7O4OuJPAceqNhTvF90dLvqSqRBd0RqZNnjYNYZ6uRy
23
+ # FQSlQBVCxdLY0AI7Yooq79TJD+0vcqiQNwQwH7L+hBWgvPos4DKN1M9LaJc/RTk=
24
+ # =5Qzo
26
25
  # -----END PGP SIGNATURE-----
26
+ #
27
27
 
28
28
  libxslt:
29
- version: "1.1.30"
30
- sha256: "ba65236116de8326d83378b2bd929879fa185195bc530b9d1aba72107910b6b3"
29
+ version: "1.1.32"
30
+ sha256: "526ecd0abaf4a7789041622c3950c0e7f2c4c8835471515fd77eec684a355460"
31
31
  # manually verified checksum:
32
32
  #
33
- # $ gpg --verify libxslt-1.1.30.tar.gz.asc libxslt-1.1.30.tar.gz
34
- # gpg: Signature made Mon 04 Sep 2017 09:36:06 AM EDT using RSA key ID 596BEA5D
33
+ # $ gpg --verify libxslt-1.1.32.tar.gz.asc libxslt-1.1.32.tar.gz
34
+ # gpg: Signature made Thu 02 Nov 2017 04:35:04 PM EDT using RSA key ID 596BEA5D
35
35
  # gpg: Good signature from "Daniel Veillard (Red Hat work email) <veillard@redhat.com>"
36
36
  # gpg: aka "Daniel Veillard <Daniel.Veillard@w3.org>"
37
37
  # gpg: WARNING: This key is not certified with a trusted signature!
@@ -43,13 +43,13 @@ libxslt:
43
43
  #
44
44
  # -----BEGIN PGP SIGNATURE-----
45
45
  #
46
- # iQEcBAABAgAGBQJZrVbGAAoJEBVYiyZZa+pdVrMH/Ru0J8zvwx8Geu6PX8ykvdEU
47
- # o5U/izwg8C8a1mtI9M8PcVUsERQinBcngO14Vk0V0dXHLp7/IEpRuXksCYkcTJL9
48
- # HawU2uDXTE/VwUl9aM2OXJOCk9W/JUkElbqEG11LCfU6uGlV+mFpLVO+eMDPxlRZ
49
- # v2LMs/yBFSiwNw757771ADShdRe3QxqhRscikK/yz/BRESdqls3/3y6GSEV2rx2n
50
- # VKVvsuHFisviwEn+1pvqcAGNCm0pIkPX6/nr+ayK3rBX7tmS493Stp6e/qUYKo6e
51
- # 5cmdTkPhpzICQH2yqeUlfMp1M1nN50oShpvQqyjmpI+SV1udw08suIxVTDUCTRc=
52
- # =LjYD
46
+ # iQEcBAABAgAGBQJZ+4F4AAoJEBVYiyZZa+pdy1IIAMX1DpzYGdnv6GCPSKeZ0woD
47
+ # sHmSkygJep0/sUQD1cYunNsNZnGDgWhnsLAvHOn3opJgsiaZhmhJ8Uo7QNlT+ni1
48
+ # AvRFgQoSXLWSF5kkun4u7RvnpDI6jYfCuYSwb9SO4EAYFAQQJXQaKCeFq71gad+p
49
+ # XGHJFAy2TqUVLNZ5I1mQz/oBeDsJ7RzHpYqaBxsLDqrCzRQ9ai23q+dFGS3jvLBr
50
+ # 0gXw0MK73ceOwW12L5aLj4erNbATWmMFMDYZZwftysv3bgx2YfiOoZUTzufrB/Bc
51
+ # MG8hP76aYBwIKNbhiDFGa2qdHGZGF7YQ4mi1/ZDX1K1G2tKKeEYxscM13JwiGb8=
52
+ # =NuQO
53
53
  # -----END PGP SIGNATURE-----
54
54
  #
55
55
 
@@ -393,8 +393,11 @@ when arg_config('--clean')
393
393
  end
394
394
 
395
395
  if openbsd? && !using_system_libraries?
396
- ENV['CC'] ||= find_executable('egcc') or
397
- abort "Please install gcc 4.9+ from ports using `pkg_add -v gcc`"
396
+ if `#{ENV['CC'] || '/usr/bin/cc'} -v 2>&1` !~ /clang/
397
+ ENV['CC'] ||= find_executable('egcc') or
398
+ abort "Please install gcc 4.9+ from ports using `pkg_add -v gcc`"
399
+ end
400
+ ENV['CFLAGS'] = "#{ENV['CFLAGS']} -I /usr/local/include"
398
401
  end
399
402
 
400
403
  RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
Binary file
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.8.1'
3
+ VERSION = '1.8.2'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -23,6 +23,7 @@ require 'nokogiri/xml/builder'
23
23
  require 'nokogiri/xml/reader'
24
24
  require 'nokogiri/xml/notation'
25
25
  require 'nokogiri/xml/entity_decl'
26
+ require 'nokogiri/xml/entity_reference'
26
27
  require 'nokogiri/xml/schema'
27
28
  require 'nokogiri/xml/relax_ng'
28
29
 
@@ -0,0 +1,18 @@
1
+ module Nokogiri
2
+ module XML
3
+ class EntityReference < Nokogiri::XML::Node
4
+ def children
5
+ # libxml2 will create a malformed child node for predefined
6
+ # entities. because any use of that child is likely to cause a
7
+ # segfault, we shall pretend that it doesn't exist.
8
+ #
9
+ # see https://github.com/sparklemotion/nokogiri/issues/1238 for details
10
+ NodeSet.new(document)
11
+ end
12
+
13
+ def inspect_attributes
14
+ [:name]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -624,9 +624,7 @@ module Nokogiri
624
624
  options[:encoding] = encoding
625
625
 
626
626
  outstring = String.new
627
- if encoding && outstring.respond_to?(:force_encoding)
628
- outstring.force_encoding(Encoding.find(encoding))
629
- end
627
+ outstring.force_encoding(Encoding.find(encoding || 'utf-8'))
630
628
  io = StringIO.new(outstring)
631
629
  write_to io, options, &block
632
630
  io.string
@@ -186,6 +186,86 @@ module Nokogiri
186
186
  @processing_instructions << [name, content]
187
187
  end
188
188
  end
189
+
190
+ # This document will help us to test the strict order of items.
191
+
192
+ class DocWithOrderedItems < XML::SAX::Document
193
+ attr_reader :items
194
+
195
+ def initialize
196
+ # [
197
+ # [ :method_1, argument_1, ... ],
198
+ # [ :method_2, argument_2, ... ],
199
+ # ...
200
+ # ]
201
+ @items = Items.new
202
+ end
203
+
204
+ [
205
+ :xmldecl,
206
+ :start_document, :end_document,
207
+ :start_element, :end_element,
208
+ :start_element_namespace, :end_element_namespace,
209
+ :characters, :comment, :cdata_block,
210
+ :processing_instruction,
211
+ :error, :warning
212
+ ]
213
+ .each do |name|
214
+ define_method name do |*arguments|
215
+ @items << [name, *arguments]
216
+ super *arguments
217
+ end
218
+ end
219
+
220
+ class Items < Array
221
+ def get_root_content root_name
222
+ items = clone
223
+ is_inside_root = false
224
+
225
+ items.select! do |item|
226
+ method_name = item[0]
227
+ element_name = item[1]
228
+
229
+ case method_name
230
+ when :start_element, :start_element_namespace
231
+ if element_name == root_name
232
+ is_inside_root = true
233
+ next false
234
+ end
235
+
236
+ when :end_element, :end_element_namespace
237
+ is_inside_root = false if element_name == root_name and is_inside_root
238
+ end
239
+
240
+ is_inside_root
241
+ end
242
+
243
+ items
244
+ end
245
+
246
+ def select_methods(names)
247
+ items = clone
248
+
249
+ items.select! do |item|
250
+ name = item[0]
251
+ names.include? name
252
+ end
253
+
254
+ items
255
+ end
256
+
257
+ def strip_text! method_names
258
+ each do |item|
259
+ method_name = item[0]
260
+ text = item[1]
261
+
262
+ text.strip! if method_names.include? method_name
263
+ end
264
+
265
+ nil
266
+ end
267
+ end
268
+ end
189
269
  end
190
270
  end
191
271
  end
@@ -0,0 +1,163 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "helper"
3
+
4
+ module Nokogiri
5
+ module HTML
6
+ module SAX
7
+ class TestParserText < Nokogiri::SAX::TestCase
8
+ def setup
9
+ super
10
+ @doc = DocWithOrderedItems.new
11
+ @parser = HTML::SAX::Parser.new @doc
12
+ end
13
+
14
+ def test_texts_order
15
+ html = <<-eohtml
16
+ <!DOCTYPE html>
17
+ <html>
18
+ <head></head>
19
+ <body>
20
+ text 0
21
+ <p>
22
+ text 1
23
+ <span>text 2</span>
24
+ text 3
25
+ </p>
26
+
27
+ text 4
28
+ <!--
29
+ text 5
30
+ -->
31
+
32
+ <p>
33
+ <!-- text 6 -->
34
+ <span><!-- text 7 --></span>
35
+ <!-- text 8 -->
36
+ </p>
37
+
38
+ <!-- text 9 -->
39
+ </body>
40
+ </html>
41
+ eohtml
42
+
43
+ @parser.parse html
44
+ items = @doc.items.get_root_content "body"
45
+ items = items.select_methods [
46
+ :start_element, :end_element,
47
+ :characters, :comment
48
+ ]
49
+ items.strip_text! [:characters, :comment]
50
+
51
+ assert_equal [
52
+ [:characters, 'text 0'],
53
+
54
+ [:start_element, 'p', []],
55
+ [:characters, 'text 1'],
56
+
57
+ [:start_element, 'span', []],
58
+ [:characters, 'text 2'],
59
+ [:end_element, 'span'],
60
+
61
+ [:characters, 'text 3'],
62
+ [:end_element, 'p'],
63
+
64
+ [:characters, 'text 4'],
65
+ [:comment, 'text 5'],
66
+ [:characters, ''],
67
+
68
+ [:start_element, 'p', []],
69
+ [:characters, ''],
70
+ [:comment, 'text 6'],
71
+ [:characters, ''],
72
+
73
+ [:start_element, 'span', []],
74
+ [:comment, 'text 7'],
75
+ [:end_element, 'span'],
76
+ [:characters, ''],
77
+
78
+ [:comment, 'text 8'],
79
+ [:characters, ''],
80
+ [:end_element, 'p'],
81
+ [:characters, ''],
82
+
83
+ [:comment, 'text 9'],
84
+ [:characters, '']
85
+ ], items
86
+
87
+ nil
88
+ end
89
+
90
+ def text_whitespace
91
+ html = <<-eohtml
92
+ <!DOCTYPE html>
93
+ <html>
94
+ <head></head>
95
+ <body>
96
+ <p>
97
+ <span></span>
98
+ <span> </span>
99
+ <span>
100
+
101
+ </span>
102
+ </p>
103
+ <p>
104
+ <!---->
105
+ <!-- -->
106
+ <!--
107
+
108
+ -->
109
+ </p>
110
+ </body>
111
+ </html>
112
+ eohtml
113
+
114
+ @parser.parse html
115
+ items = @doc.items.get_root_content "body"
116
+ items = items.select_methods [
117
+ :start_element, :end_element,
118
+ :characters, :comment
119
+ ]
120
+ items.strip_text! [:characters, :comment]
121
+
122
+ assert_equal [
123
+ [:characters, ''],
124
+ [:start_element, 'p', []],
125
+
126
+ [:characters, ''],
127
+ [:start_element, 'span', []],
128
+ [:end_element, 'span'],
129
+ [:characters, ''],
130
+
131
+ [:start_element, 'span', []],
132
+ [:characters, ''],
133
+ [:end_element, 'span'],
134
+ [:characters, ''],
135
+
136
+ [:start_element, 'span', []],
137
+ [:characters, ''],
138
+ [:end_element, 'span'],
139
+ [:characters, ''],
140
+
141
+ [:end_element, 'p'],
142
+ [:characters, ''],
143
+
144
+ [:start_element, 'p', []],
145
+ [:characters, ''],
146
+
147
+ [:comment, ''],
148
+ [:characters, ''],
149
+ [:comment, ''],
150
+ [:characters, ''],
151
+ [:comment, ''],
152
+ [:characters, ''],
153
+
154
+ [:end_element, 'p'],
155
+ [:characters, '']
156
+ ], items
157
+
158
+ nil
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
@@ -26,6 +26,12 @@ module Nokogiri
26
26
  assert_equal @html.serialize, @doc.serialize
27
27
  end
28
28
 
29
+ def test_default_encoding
30
+ doc = Nokogiri::HTML(nil)
31
+ assert_nil doc.encoding
32
+ assert_equal 'UTF-8', doc.serialize.encoding.name
33
+ end
34
+
29
35
  def test_encode_special_chars
30
36
  foo = @html.css('a').first.encode_special_chars('foo')
31
37
  assert_equal 'UTF-8', foo.encoding.name
@@ -0,0 +1,202 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "helper"
3
+
4
+ module Nokogiri
5
+ module XML
6
+ module SAX
7
+ class TestParserText < Nokogiri::SAX::TestCase
8
+ def setup
9
+ super
10
+ @doc = DocWithOrderedItems.new
11
+ @parser = XML::SAX::Parser.new @doc
12
+ end
13
+
14
+ def test_texts_order
15
+ xml = <<-eoxml
16
+ <?xml version="1.0" ?>
17
+ <root>
18
+ text 0
19
+ <p>
20
+ text 1
21
+ <span>text 2</span>
22
+ text 3
23
+ </p>
24
+
25
+ text 4
26
+ <!--
27
+ text 5
28
+ -->
29
+
30
+ <p>
31
+ <!-- text 6 -->
32
+ <span><!-- text 7 --></span>
33
+ <!-- text 8 -->
34
+ </p>
35
+
36
+ <!-- text 9 -->
37
+ <![CDATA[ text 10 ]]>
38
+
39
+ <p>
40
+ <![CDATA[ text 11 ]]>
41
+ <span><![CDATA[ text 12 ]]></span>
42
+ <![CDATA[ text 13 ]]>
43
+ </p>
44
+ </root>
45
+ eoxml
46
+
47
+ @parser.parse xml
48
+ items = @doc.items.get_root_content "root"
49
+ items = items.select_methods [
50
+ :start_element, :end_element,
51
+ :characters, :comment, :cdata_block
52
+ ]
53
+ items.strip_text! [:characters, :comment, :cdata_block]
54
+
55
+ assert_equal [
56
+ [:characters, 'text 0'],
57
+
58
+ [:start_element, 'p', []],
59
+ [:characters, 'text 1'],
60
+
61
+ [:start_element, 'span', []],
62
+ [:characters, 'text 2'],
63
+ [:end_element, 'span'],
64
+
65
+ [:characters, 'text 3'],
66
+ [:end_element, 'p'],
67
+
68
+ [:characters, 'text 4'],
69
+ [:comment, 'text 5'],
70
+ [:characters, ''],
71
+
72
+ [:start_element, 'p', []],
73
+ [:characters, ''],
74
+ [:comment, 'text 6'],
75
+ [:characters, ''],
76
+
77
+ [:start_element, 'span', []],
78
+ [:comment, 'text 7'],
79
+ [:end_element, 'span'],
80
+ [:characters, ''],
81
+
82
+ [:comment, 'text 8'],
83
+ [:characters, ''],
84
+ [:end_element, 'p'],
85
+ [:characters, ''],
86
+
87
+ [:comment, 'text 9'],
88
+ [:characters, ''],
89
+ [:cdata_block, 'text 10'],
90
+ [:characters, ''],
91
+
92
+ [:start_element, 'p', []],
93
+ [:characters, ''],
94
+ [:cdata_block, 'text 11'],
95
+ [:characters, ''],
96
+
97
+ [:start_element, 'span', []],
98
+ [:cdata_block, 'text 12'],
99
+ [:end_element, 'span'],
100
+ [:characters, ''],
101
+
102
+ [:cdata_block, 'text 13'],
103
+ [:characters, ''],
104
+
105
+ [:end_element, 'p'],
106
+ [:characters, '']
107
+ ], items
108
+
109
+ nil
110
+ end
111
+
112
+ def text_whitespace
113
+ xml = <<-eoxml
114
+ <?xml version="1.0" ?>
115
+ <root>
116
+ <p>
117
+ <span></span>
118
+ <span> </span>
119
+ <span>
120
+
121
+ </span>
122
+ </p>
123
+ <p>
124
+ <!---->
125
+ <!-- -->
126
+ <!--
127
+
128
+ -->
129
+ </p>
130
+ <p>
131
+ <![CDATA[]]>
132
+ <![CDATA[ ]]>
133
+ <![CDATA[
134
+
135
+ ]]>
136
+ </p>
137
+ </root>
138
+ eoxml
139
+
140
+ @parser.parse xml
141
+ items = @doc.items.get_root_content "root"
142
+ items = items.select_methods [
143
+ :start_element, :end_element,
144
+ :characters, :comment, :cdata_block
145
+ ]
146
+ items.strip_text! [:characters, :comment, :cdata_block]
147
+
148
+ assert_equal [
149
+ [:characters, ''],
150
+ [:start_element, 'p', []],
151
+
152
+ [:characters, ''],
153
+ [:start_element, 'span', []],
154
+ [:end_element, 'span'],
155
+ [:characters, ''],
156
+
157
+ [:start_element, 'span', []],
158
+ [:characters, ''],
159
+ [:end_element, 'span'],
160
+ [:characters, ''],
161
+
162
+ [:start_element, 'span', []],
163
+ [:characters, ''],
164
+ [:end_element, 'span'],
165
+ [:characters, ''],
166
+
167
+ [:end_element, 'p'],
168
+ [:characters, ''],
169
+
170
+ [:start_element, 'p', []],
171
+ [:characters, ''],
172
+
173
+ [:comment, ''],
174
+ [:characters, ''],
175
+ [:comment, ''],
176
+ [:characters, ''],
177
+ [:comment, ''],
178
+ [:characters, ''],
179
+
180
+ [:end_element, 'p'],
181
+ [:characters, ''],
182
+
183
+ [:start_element, 'p', []],
184
+ [:characters, ''],
185
+
186
+ [:cdata_block, ''],
187
+ [:characters, ''],
188
+ [:cdata_block, ''],
189
+ [:characters, ''],
190
+ [:cdata_block, ''],
191
+ [:characters, ''],
192
+
193
+ [:end_element, 'p'],
194
+ [:characters, '']
195
+ ], items
196
+
197
+ nil
198
+ end
199
+ end
200
+ end
201
+ end
202
+ end
@@ -28,6 +28,17 @@ EOF
28
28
  doc.xpath('/item').first.add_child(lf_node)
29
29
  assert_match(/&#xa;/, doc.to_xml)
30
30
  end
31
+
32
+ def test_children_should_always_be_empty
33
+ # https://github.com/sparklemotion/nokogiri/issues/1238
34
+ #
35
+ # libxml2 will create a malformed child node for predefined
36
+ # entities. because any use of that child is likely to cause a
37
+ # segfault, we shall pretend that it doesn't exist.
38
+ entity = Nokogiri::XML::EntityReference.new(@xml, "amp")
39
+ assert_equal 0, entity.children.length
40
+ entity.inspect # should not segfault
41
+ end
31
42
  end
32
43
 
33
44
  module Common
@@ -13,6 +13,12 @@ module Nokogiri
13
13
  assert_equal @xml.serialize, @doc.serialize
14
14
  end
15
15
 
16
+ def test_default_encoding
17
+ doc = Nokogiri::XML(VEHICLE_XML)
18
+ assert_nil doc.encoding
19
+ assert_equal 'UTF-8', doc.serialize.encoding.name
20
+ end
21
+
16
22
  def test_encoding_GH_1113
17
23
  utf8 = '<frag>shahid ὡ 𐄣 𢂁</frag>'
18
24
  hex = '<frag>shahid &#x1f61; &#x10123; &#x22081;</frag>'
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.1
4
+ version: 1.8.2
5
5
  platform: x86-mingw32
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: 2017-09-19 00:00:00.000000000 Z
15
+ date: 2018-01-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mini_portile2
@@ -132,14 +132,14 @@ dependencies:
132
132
  requirements:
133
133
  - - "~>"
134
134
  - !ruby/object:Gem::Version
135
- version: 0.6.0
135
+ version: 0.6.2
136
136
  type: :development
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: 0.6.0
142
+ version: 0.6.2
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: racc
145
145
  requirement: !ruby/object:Gem::Requirement
@@ -174,14 +174,14 @@ dependencies:
174
174
  requirements:
175
175
  - - "~>"
176
176
  - !ruby/object:Gem::Version
177
- version: '0.11'
177
+ version: '0.15'
178
178
  type: :development
179
179
  prerelease: false
180
180
  version_requirements: !ruby/object:Gem::Requirement
181
181
  requirements:
182
182
  - - "~>"
183
183
  - !ruby/object:Gem::Version
184
- version: '0.11'
184
+ version: '0.15'
185
185
  - !ruby/object:Gem::Dependency
186
186
  name: rdoc
187
187
  requirement: !ruby/object:Gem::Requirement
@@ -366,6 +366,7 @@ files:
366
366
  - lib/nokogiri/2.2/nokogiri.so
367
367
  - lib/nokogiri/2.3/nokogiri.so
368
368
  - lib/nokogiri/2.4/nokogiri.so
369
+ - lib/nokogiri/2.5/nokogiri.so
369
370
  - lib/nokogiri/css.rb
370
371
  - lib/nokogiri/css/node.rb
371
372
  - lib/nokogiri/css/parser.rb
@@ -400,6 +401,7 @@ files:
400
401
  - lib/nokogiri/xml/element_content.rb
401
402
  - lib/nokogiri/xml/element_decl.rb
402
403
  - lib/nokogiri/xml/entity_decl.rb
404
+ - lib/nokogiri/xml/entity_reference.rb
403
405
  - lib/nokogiri/xml/namespace.rb
404
406
  - lib/nokogiri/xml/node.rb
405
407
  - lib/nokogiri/xml/node/save_options.rb
@@ -476,6 +478,7 @@ files:
476
478
  - test/helper.rb
477
479
  - test/html/sax/test_parser.rb
478
480
  - test/html/sax/test_parser_context.rb
481
+ - test/html/sax/test_parser_text.rb
479
482
  - test/html/sax/test_push_parser.rb
480
483
  - test/html/test_builder.rb
481
484
  - test/html/test_document.rb
@@ -503,6 +506,7 @@ files:
503
506
  - test/xml/node/test_subclass.rb
504
507
  - test/xml/sax/test_parser.rb
505
508
  - test/xml/sax/test_parser_context.rb
509
+ - test/xml/sax/test_parser_text.rb
506
510
  - test/xml/sax/test_push_parser.rb
507
511
  - test/xml/test_attr.rb
508
512
  - test/xml/test_attribute_decl.rb
@@ -543,8 +547,8 @@ homepage: http://nokogiri.org
543
547
  licenses:
544
548
  - MIT
545
549
  metadata: {}
546
- post_install_message: 'Nokogiri is built with the packaged libraries: libxml2-2.9.5,
547
- libxslt-1.1.30, zlib-1.2.11, libiconv-1.15.
550
+ post_install_message: 'Nokogiri is built with the packaged libraries: libxml2-2.9.7,
551
+ libxslt-1.1.32, zlib-1.2.11, libiconv-1.15.
548
552
 
549
553
  '
550
554
  rdoc_options:
@@ -559,7 +563,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
559
563
  version: '2.2'
560
564
  - - "<"
561
565
  - !ruby/object:Gem::Version
562
- version: '2.5'
566
+ version: '2.6'
563
567
  required_rubygems_version: !ruby/object:Gem::Requirement
564
568
  requirements:
565
569
  - - ">="
@@ -567,7 +571,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
567
571
  version: '0'
568
572
  requirements: []
569
573
  rubyforge_project:
570
- rubygems_version: 2.6.12
574
+ rubygems_version: 2.6.14
571
575
  signing_key:
572
576
  specification_version: 4
573
577
  summary: Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser