nokogiri 1.8.1 → 1.8.2

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: bb5ae2f309f32e6299e28f8163ccde42dd7194c6
4
- data.tar.gz: fe6d320fb028811a39297771a9b5da13836a57ce
3
+ metadata.gz: 8eda887f0620302cc831ef126a36321b38a294b6
4
+ data.tar.gz: c16a8f4170ccb1bb77dca63b595371a806eb49de
5
5
  SHA512:
6
- metadata.gz: f77a7df358ec08fa9f1c78e2a9d7fd0414c15022b42066208af6724db1087ef74a9e21d8750d9411f726311947618a81625713ce4c8064641ed490a014c99950
7
- data.tar.gz: 57adf86c265c43453c50e72b9470a164738eb3c74b229cdfc2eb1c8a8e2b657fdd569c85e01d92c9b63e43da1ef6730937c6c40e666747fd5ee3717ae2713bd4
6
+ metadata.gz: 742e024c0c7d28ae1be933a52f42abeda71eca9b971bd314885c95559e531d8fbb009917e272f418ae6bb5decfe70eabcc9031f83adb1e360e27f18d7d97003f
7
+ data.tar.gz: 44cf0e20486485ea7e586ad87100f8f4df7dd4afbe46f4df8217c513e92bde898ed427403388c7931a8da1e7390f4786c1189154ca881bae1f1b2544706e6fff
@@ -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']
@@ -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: 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: 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
@@ -398,6 +398,7 @@ files:
398
398
  - lib/nokogiri/xml/element_content.rb
399
399
  - lib/nokogiri/xml/element_decl.rb
400
400
  - lib/nokogiri/xml/entity_decl.rb
401
+ - lib/nokogiri/xml/entity_reference.rb
401
402
  - lib/nokogiri/xml/namespace.rb
402
403
  - lib/nokogiri/xml/node.rb
403
404
  - lib/nokogiri/xml/node/save_options.rb
@@ -426,8 +427,8 @@ files:
426
427
  - lib/nokogiri/xslt/stylesheet.rb
427
428
  - lib/xsd/xmlparser/nokogiri.rb
428
429
  - patches/sort-patches-by-date
429
- - ports/archives/libxml2-2.9.5.tar.gz
430
- - ports/archives/libxslt-1.1.30.tar.gz
430
+ - ports/archives/libxml2-2.9.7.tar.gz
431
+ - ports/archives/libxslt-1.1.32.tar.gz
431
432
  - suppressions/README.txt
432
433
  - suppressions/nokogiri_ruby-2.supp
433
434
  - tasks/test.rb
@@ -476,6 +477,7 @@ files:
476
477
  - test/helper.rb
477
478
  - test/html/sax/test_parser.rb
478
479
  - test/html/sax/test_parser_context.rb
480
+ - test/html/sax/test_parser_text.rb
479
481
  - test/html/sax/test_push_parser.rb
480
482
  - test/html/test_builder.rb
481
483
  - test/html/test_document.rb
@@ -503,6 +505,7 @@ files:
503
505
  - test/xml/node/test_subclass.rb
504
506
  - test/xml/sax/test_parser.rb
505
507
  - test/xml/sax/test_parser_context.rb
508
+ - test/xml/sax/test_parser_text.rb
506
509
  - test/xml/sax/test_push_parser.rb
507
510
  - test/xml/test_attr.rb
508
511
  - test/xml/test_attribute_decl.rb