nokogiri 1.6.8.rc2-java → 1.6.8.rc3-java
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 +4 -4
- data/.travis.yml +5 -0
- data/CHANGELOG.rdoc +30 -4
- data/Gemfile +2 -1
- data/README.md +22 -23
- data/ROADMAP.md +11 -1
- data/Rakefile +30 -12
- data/ext/nokogiri/extconf.rb +89 -59
- data/ext/nokogiri/xml_node.c +17 -0
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +1 -1
- data/test/helper.rb +4 -0
- data/test/html/test_document_fragment.rb +1 -1
- data/test/xml/test_node.rb +11 -0
- data/test_all +17 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a5e58bb62530c4c55b141723a110e00128ff051
|
4
|
+
data.tar.gz: 7102867999ccfaf4220369ffa366ca0cbc28b5ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c647157a41f0e818d30359b07b1a2d365a8cb71efa3f42426f841d86476b9691a1d06dbb75572a138f0da9b1e930d41047c0a1850c1661175cd23488156ae9d
|
7
|
+
data.tar.gz: 86559f6d4d4eb562ab8589b3411187b595711d40c5dcedccea46a24546dbe2a6a0e918a421ad66af43dbbd0bf3fa65f0caefc2b1d9747b7bb6f2cb043cc3996c
|
data/.travis.yml
CHANGED
@@ -8,6 +8,7 @@ rvm:
|
|
8
8
|
- 2.0
|
9
9
|
- 2.1
|
10
10
|
- 2.2.3
|
11
|
+
- 2.3.0
|
11
12
|
- jruby-19mode
|
12
13
|
- jruby-1.7.23
|
13
14
|
- jruby-9.0.4.0
|
@@ -19,6 +20,10 @@ os:
|
|
19
20
|
- osx
|
20
21
|
|
21
22
|
matrix:
|
23
|
+
allow_failures:
|
24
|
+
# https://github.com/travis-ci/travis-ci/issues/5361
|
25
|
+
- os: osx
|
26
|
+
rvm: 2.3.0
|
22
27
|
exclude:
|
23
28
|
- os: osx
|
24
29
|
rvm: ruby-1.9.2
|
data/CHANGELOG.rdoc
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
==== Security Note
|
4
4
|
|
5
|
-
* (MRI) Bundled Libxml2 is upgraded to 2.9.3, which fixes a series of security issues.
|
5
|
+
* (MRI) Bundled Libxml2 is upgraded to 2.9.3, which fixes a series of security issues.
|
6
|
+
These security issues had been patched in the vendored libxml 2.9.2 in the 1.6.7.x branch.
|
7
|
+
See https://mail.gnome.org/archives/xml/2015-November/msg00012.html for more.
|
6
8
|
|
7
9
|
|
8
10
|
==== Features
|
@@ -10,19 +12,23 @@
|
|
10
12
|
Several changes were made to improve performance:
|
11
13
|
|
12
14
|
* [MRI] Simplify NodeSet#to_a with a minor speed-up. (#1397)
|
13
|
-
* XML::Node#ancestors optimization (#1297) (Thanks, Bruno Sutic!)
|
14
|
-
* Use Symbol#to_proc where we weren't previously
|
15
|
+
* XML::Node#ancestors optimization. (#1297) (Thanks, Bruno Sutic!)
|
16
|
+
* Use Symbol#to_proc where we weren't previously. (#1296) (Thanks, Bruno Sutic!)
|
17
|
+
* XML::DTD#each uses implicit block calls. (Thanks, @glaucocustodio!)
|
18
|
+
* Fall back to the `pkg-config` gem if we're having trouble finding the system libxml2. This should help many FreeBSD users. (#1417)
|
15
19
|
|
16
20
|
|
17
21
|
==== Bug Fixes
|
18
22
|
|
19
|
-
* [JRuby] fix load errors when deploying to JRuby/Torquebox (#1114) (Thanks, @atambo!)
|
23
|
+
* [JRuby] fix load errors when deploying to JRuby/Torquebox (#1114) (Thanks, @atambo and @jvshahid!)
|
20
24
|
* [JRuby] fix NPE when inspecting nodes returned by NodeSet#drop (#1042) (Thanks, @mkristian!)
|
21
25
|
* [JRuby] fix nil attriubte node's namespace in reader (#1327) (Thanks, @codekitchen!)
|
22
26
|
* [JRuby] fix Nokogiri munging unicode characters that require more than 2 bytes (#1113) (Thanks, @mkristian!)
|
23
27
|
* [MRI] fix assertion failure while accessing attribute node's namespace in reader (#843) (Thanks, @2potatocakes!)
|
24
28
|
* [MRI] fix issue with GCing namespace nodes returned in an xpath query. (#1155)
|
25
29
|
* [MRI] Ensure C strings are null-terminated. (#1381)
|
30
|
+
* [MRI] Ensure Rubygems is loaded before using mini_portile2 at installation. (#1393, #1411) (Thanks, @JonRowe!)
|
31
|
+
* [MRI] Handling another edge case where the `libxml-ruby` gem's global callbacks were smashing the heap. (#1426). (Thanks to @bbergstrom for providing an isolated test case!)
|
26
32
|
* unescape special characters in CSS queries (#1303) (Thanks, @twalpole!)
|
27
33
|
* consistently handle empty documents (#1349)
|
28
34
|
* Update to mini_portile2 2.1.0 to address whitespace-handling during patching. (#1402)
|
@@ -30,6 +36,26 @@ Several changes were made to improve performance:
|
|
30
36
|
* Work around issue installing Nokogiri on overlayfs (commonly used in Docker containers). (#1370, #1405)
|
31
37
|
|
32
38
|
|
39
|
+
|
40
|
+
==== Other Notes
|
41
|
+
|
42
|
+
* Removed legacy code remaining from Ruby 1.8.x support.
|
43
|
+
* Removed legacy code remaining from REE support.
|
44
|
+
* Removing hacky workarounds for bugs in some older versions of libxml2.
|
45
|
+
* Handling C strings in a forward-compatible manner, see https://github.com/ruby/ruby/blob/v2_2_0/NEWS#L319
|
46
|
+
|
47
|
+
|
48
|
+
=== 1.6.7.2 / 2016-01-20
|
49
|
+
|
50
|
+
This version pulls in several upstream patches to the vendored libxml2 and libxslt to address:
|
51
|
+
|
52
|
+
CVE-2015-7499
|
53
|
+
|
54
|
+
Ubuntu classifies this as "Priority: Low", RedHat classifies this as "Impact: Moderate", and NIST classifies this as "Severity: 5.0 (MEDIUM)".
|
55
|
+
|
56
|
+
MITRE record is https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-7499
|
57
|
+
|
58
|
+
|
33
59
|
=== 1.6.7.1 / 2015-12-16
|
34
60
|
|
35
61
|
This version pulls in several upstream patches to the vendored libxml2 and libxslt to address:
|
data/Gemfile
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
source "https://rubygems.org/"
|
6
6
|
|
7
7
|
gem "mini_portile2", "~>2.1.0"
|
8
|
+
gem "pkg-config", "~>1.1.7"
|
8
9
|
|
9
10
|
gem "rdoc", "~>4.0", :group => [:development, :test]
|
10
11
|
gem "hoe-bundler", ">=1.1", :group => [:development, :test]
|
@@ -14,7 +15,7 @@ gem "hoe-git", ">=1.4", :group => [:development, :test]
|
|
14
15
|
gem "minitest", "~>2.2.2", :group => [:development, :test]
|
15
16
|
gem "rake", ">=0.9", :group => [:development, :test]
|
16
17
|
gem "rake-compiler", "~>0.9.2", :group => [:development, :test]
|
17
|
-
gem "rake-compiler-dock", "~>0.5.
|
18
|
+
gem "rake-compiler-dock", "~>0.5.1", :group => [:development, :test]
|
18
19
|
gem "racc", ">=1.4.6", :group => [:development, :test], :platform => :ruby
|
19
20
|
gem "rexical", ">=1.0.5", :group => [:development, :test], :platform => :ruby
|
20
21
|
gem "hoe", "~>3.14", :group => [:development, :test]
|
data/README.md
CHANGED
@@ -86,29 +86,28 @@ There are open-source tutorials (to which we invite contributions!) here: http:/
|
|
86
86
|
Nokogiri is a large library, but here is example usage for parsing and examining a document:
|
87
87
|
|
88
88
|
```ruby
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
89
|
+
#! /usr/bin/env ruby
|
90
|
+
|
91
|
+
require 'nokogiri'
|
92
|
+
require 'open-uri'
|
93
|
+
|
94
|
+
# Fetch and parse HTML document
|
95
|
+
doc = Nokogiri::HTML(open('http://www.nokogiri.org/tutorials/installing_nokogiri.html'))
|
96
|
+
|
97
|
+
puts "### Search for nodes by css"
|
98
|
+
doc.css('nav ul.menu li a', 'article h2').each do |link|
|
99
|
+
puts link.content
|
100
|
+
end
|
101
|
+
|
102
|
+
puts "### Search for nodes by xpath"
|
103
|
+
doc.xpath('//nav//ul//li/a', '//article//h2').each do |link|
|
104
|
+
puts link.content
|
105
|
+
end
|
106
|
+
|
107
|
+
puts "### Or mix and match."
|
108
|
+
doc.search('nav ul.menu li a', '//article//h2').each do |link|
|
109
|
+
puts link.content
|
110
|
+
end
|
112
111
|
```
|
113
112
|
|
114
113
|
|
data/ROADMAP.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Roadmap for
|
1
|
+
# Roadmap for API Changes
|
2
2
|
|
3
3
|
## overhaul serialize/pretty printing API
|
4
4
|
|
@@ -99,3 +99,13 @@ So, instead, let's make alternative methods like
|
|
99
99
|
`Nokogiri::XML::Document#new_comment`, and recommend those as the
|
100
100
|
proper convention.
|
101
101
|
|
102
|
+
|
103
|
+
## `collect_namespaces` is just broken
|
104
|
+
|
105
|
+
`collect_namespaces` is returning a hash, which means it can't return
|
106
|
+
namespaces with the same prefix. See this issue for background:
|
107
|
+
|
108
|
+
> https://github.com/sparklemotion/nokogiri/issues/885
|
109
|
+
|
110
|
+
Do we care? This seems like a useless method, but then again I hate
|
111
|
+
XML, so what do I know?
|
data/Rakefile
CHANGED
@@ -128,22 +128,22 @@ HOE = Hoe.spec 'nokogiri' do
|
|
128
128
|
|
129
129
|
unless java?
|
130
130
|
self.extra_deps += [
|
131
|
-
#
|
132
|
-
["
|
131
|
+
["mini_portile2", "~> 2.1.0"], # keep version in sync with extconf.rb
|
132
|
+
["pkg-config", "~> 1.1.7"], # keep version in sync with extconf.rb
|
133
133
|
]
|
134
134
|
end
|
135
135
|
|
136
136
|
self.extra_dev_deps += [
|
137
|
-
["hoe-bundler",
|
138
|
-
["hoe-debugging",
|
139
|
-
["hoe-gemspec",
|
140
|
-
["hoe-git",
|
141
|
-
["minitest",
|
142
|
-
["rake",
|
143
|
-
["rake-compiler",
|
144
|
-
["rake-compiler-dock", "~> 0.5.
|
145
|
-
["racc",
|
146
|
-
["rexical",
|
137
|
+
["hoe-bundler", ">= 1.1"],
|
138
|
+
["hoe-debugging", "~> 1.2.1"],
|
139
|
+
["hoe-gemspec", ">= 1.0"],
|
140
|
+
["hoe-git", ">= 1.4"],
|
141
|
+
["minitest", "~> 2.2.2"],
|
142
|
+
["rake", ">= 0.9"],
|
143
|
+
["rake-compiler", "~> 0.9.2"],
|
144
|
+
["rake-compiler-dock", "~> 0.5.1"],
|
145
|
+
["racc", ">= 1.4.6"],
|
146
|
+
["rexical", ">= 1.0.5"]
|
147
147
|
]
|
148
148
|
|
149
149
|
if java?
|
@@ -318,6 +318,24 @@ if Hoe.plugins.include?(:debugging)
|
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
+
task "test:libxml-ruby" do
|
322
|
+
ENV['TEST_NOKOGIRI_WITH_LIBXML_RUBY'] = "1"
|
323
|
+
warn "#{__FILE__}:#{__LINE__}: --- running tests with libxml-ruby loaded ---"
|
324
|
+
Rake::Task[:test].execute
|
325
|
+
ENV['TEST_NOKOGIRI_WITH_LIBXML_RUBY'] = nil
|
326
|
+
end
|
327
|
+
|
328
|
+
Rake::Task["test:libxml-ruby"].prerequisites << :compile
|
329
|
+
|
330
|
+
task "test:valgrind:libxml-ruby" do
|
331
|
+
ENV['TEST_NOKOGIRI_WITH_LIBXML_RUBY'] = "1"
|
332
|
+
warn "#{__FILE__}:#{__LINE__}: --- running tests with libxml-ruby loaded ---"
|
333
|
+
Rake::Task["test:valgrind"].execute
|
334
|
+
ENV['TEST_NOKOGIRI_WITH_LIBXML_RUBY'] = nil
|
335
|
+
end
|
336
|
+
|
337
|
+
Rake::Task["test:valgrind:libxml-ruby"].prerequisites << :compile
|
338
|
+
|
321
339
|
# ----------------------------------------
|
322
340
|
|
323
341
|
def verify_dll(dll, cross_ruby)
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -55,9 +55,9 @@ def do_clean
|
|
55
55
|
# nokogiri.so is yet to be copied to lib.
|
56
56
|
|
57
57
|
# clean the ports build directory
|
58
|
-
Pathname.glob(pwd.join('tmp', '*', 'ports'))
|
58
|
+
Pathname.glob(pwd.join('tmp', '*', 'ports')) do |dir|
|
59
59
|
FileUtils.rm_rf(dir, verbose: true)
|
60
|
-
|
60
|
+
end
|
61
61
|
|
62
62
|
if enable_config('static')
|
63
63
|
# ports installation can be safely removed if statically linked.
|
@@ -70,6 +70,29 @@ def do_clean
|
|
70
70
|
exit! 0
|
71
71
|
end
|
72
72
|
|
73
|
+
# The gem version constraint in the Rakefile is not respected at install time.
|
74
|
+
# Keep this version in sync with the one in the Rakefile !
|
75
|
+
require 'rubygems'
|
76
|
+
gem 'pkg-config', '~> 1.1.7'
|
77
|
+
require 'pkg-config'
|
78
|
+
message "Using pkg-config version #{PKGConfig::VERSION}\n"
|
79
|
+
|
80
|
+
def package_config pkg, options={}
|
81
|
+
package = pkg_config(pkg)
|
82
|
+
return package if package
|
83
|
+
|
84
|
+
return nil unless PKGConfig.have_package(pkg)
|
85
|
+
|
86
|
+
cflags = PKGConfig.cflags(pkg)
|
87
|
+
ldflags = PKGConfig.libs_only_L(pkg)
|
88
|
+
libs = PKGConfig.libs_only_l(pkg)
|
89
|
+
|
90
|
+
Logging::message "PKGConfig package configuration for %s\n", pkg
|
91
|
+
Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n", cflags, ldflags, libs
|
92
|
+
|
93
|
+
[cflags, ldflags, libs]
|
94
|
+
end
|
95
|
+
|
73
96
|
def nokogiri_try_compile
|
74
97
|
args = if defined?(RUBY_VERSION) && RUBY_VERSION <= "1.9.2"
|
75
98
|
["int main() {return 0;}"]
|
@@ -79,6 +102,23 @@ def nokogiri_try_compile
|
|
79
102
|
try_compile(*args)
|
80
103
|
end
|
81
104
|
|
105
|
+
def check_libxml_version version=nil
|
106
|
+
source = if version.nil?
|
107
|
+
<<-SRC
|
108
|
+
#include <libxml/xmlversion.h>
|
109
|
+
SRC
|
110
|
+
else
|
111
|
+
version_int = sprintf "%d%2.2d%2.2d", *(version.split("."))
|
112
|
+
<<-SRC
|
113
|
+
#include <libxml/xmlversion.h>
|
114
|
+
#if LIBXML_VERSION < #{version_int}
|
115
|
+
#error libxml2 is older than #{version}
|
116
|
+
#endif
|
117
|
+
SRC
|
118
|
+
end
|
119
|
+
|
120
|
+
try_cpp source
|
121
|
+
end
|
82
122
|
|
83
123
|
def add_cflags(flags)
|
84
124
|
print "checking if the C compiler accepts #{flags}... "
|
@@ -112,9 +152,9 @@ def asplode(lib)
|
|
112
152
|
end
|
113
153
|
|
114
154
|
def have_iconv?(using = nil)
|
115
|
-
checking_for(using ? "iconv using #{using}" : 'iconv')
|
116
|
-
['', '-liconv'].any?
|
117
|
-
preserving_globals
|
155
|
+
checking_for(using ? "iconv using #{using}" : 'iconv') do
|
156
|
+
['', '-liconv'].any? do |opt|
|
157
|
+
preserving_globals do
|
118
158
|
yield if block_given?
|
119
159
|
|
120
160
|
try_link(<<-'SRC', opt)
|
@@ -128,22 +168,22 @@ int main(void)
|
|
128
168
|
return EXIT_SUCCESS;
|
129
169
|
}
|
130
170
|
SRC
|
131
|
-
|
132
|
-
|
133
|
-
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
134
174
|
end
|
135
175
|
|
136
176
|
def iconv_configure_flags
|
137
177
|
# If --with-iconv-dir or --with-opt-dir is given, it should be
|
138
178
|
# the first priority
|
139
|
-
%w[iconv opt].each
|
179
|
+
%w[iconv opt].each do |name|
|
140
180
|
if (config = preserving_globals { dir_config(name) }).any? &&
|
141
|
-
|
142
|
-
idirs, ldirs = config.map
|
143
|
-
Array(dirs).flat_map
|
181
|
+
have_iconv?("--with-#{name}-* flags") { dir_config(name) }
|
182
|
+
idirs, ldirs = config.map do |dirs|
|
183
|
+
Array(dirs).flat_map do |dir|
|
144
184
|
dir.split(File::PATH_SEPARATOR)
|
145
|
-
|
146
|
-
|
185
|
+
end if dirs
|
186
|
+
end
|
147
187
|
|
148
188
|
return [
|
149
189
|
'--with-iconv=yes',
|
@@ -151,14 +191,14 @@ def iconv_configure_flags
|
|
151
191
|
*("LDFLAGS=#{ldirs.map { |dir| '-L' << dir }.join(' ')}" if ldirs),
|
152
192
|
]
|
153
193
|
end
|
154
|
-
|
194
|
+
end
|
155
195
|
|
156
196
|
if have_iconv?
|
157
197
|
return ['--with-iconv=yes']
|
158
198
|
end
|
159
199
|
|
160
|
-
if (config = preserving_globals {
|
161
|
-
have_iconv?('pkg-config libiconv') {
|
200
|
+
if (config = preserving_globals { package_config('libiconv') }) &&
|
201
|
+
have_iconv?('pkg-config libiconv') { package_config('libiconv') }
|
162
202
|
cflags, ldflags, libs = config
|
163
203
|
|
164
204
|
return [
|
@@ -192,13 +232,13 @@ def process_recipe(name, version, static_p, cross_p)
|
|
192
232
|
|
193
233
|
yield recipe
|
194
234
|
|
195
|
-
env = Hash.new
|
235
|
+
env = Hash.new do |hash, key|
|
196
236
|
hash[key] = "#{ENV[key]}" # (ENV[key].dup rescue '')
|
197
|
-
|
237
|
+
end
|
198
238
|
|
199
239
|
recipe.configure_options.flatten!
|
200
240
|
|
201
|
-
recipe.configure_options.delete_if
|
241
|
+
recipe.configure_options.delete_if do |option|
|
202
242
|
case option
|
203
243
|
when /\A(\w+)=(.*)\z/
|
204
244
|
env[$1] = $2
|
@@ -206,7 +246,7 @@ def process_recipe(name, version, static_p, cross_p)
|
|
206
246
|
else
|
207
247
|
false
|
208
248
|
end
|
209
|
-
|
249
|
+
end
|
210
250
|
|
211
251
|
if static_p
|
212
252
|
recipe.configure_options += [
|
@@ -229,16 +269,16 @@ def process_recipe(name, version, static_p, cross_p)
|
|
229
269
|
end
|
230
270
|
|
231
271
|
if RbConfig::CONFIG['target_cpu'] == 'universal'
|
232
|
-
%w[CFLAGS LDFLAGS].each
|
272
|
+
%w[CFLAGS LDFLAGS].each do |key|
|
233
273
|
unless env[key].include?('-arch')
|
234
274
|
env[key] << ' ' << RbConfig::CONFIG['ARCH_FLAG']
|
235
275
|
end
|
236
|
-
|
276
|
+
end
|
237
277
|
end
|
238
278
|
|
239
|
-
recipe.configure_options += env.map
|
279
|
+
recipe.configure_options += env.map do |key, value|
|
240
280
|
"#{key}=#{value}"
|
241
|
-
|
281
|
+
end
|
242
282
|
|
243
283
|
message <<-"EOS"
|
244
284
|
************************************************************************
|
@@ -250,9 +290,9 @@ Building Nokogiri with a packaged version of #{name}-#{version}#{'.' if recipe.p
|
|
250
290
|
unless recipe.patch_files.empty?
|
251
291
|
message "with the following patches applied:\n"
|
252
292
|
|
253
|
-
recipe.patch_files.each
|
293
|
+
recipe.patch_files.each do |patch|
|
254
294
|
message "\t- %s\n" % File.basename(patch)
|
255
|
-
|
295
|
+
end
|
256
296
|
end
|
257
297
|
|
258
298
|
message <<-"EOS"
|
@@ -368,31 +408,21 @@ when using_system_libraries?
|
|
368
408
|
# Using system libraries means we rely on the system libxml2 with
|
369
409
|
# regard to the iconv support.
|
370
410
|
|
371
|
-
dir_config('xml2').any? or
|
372
|
-
dir_config('xslt').any? or
|
373
|
-
dir_config('exslt').any? or
|
411
|
+
dir_config('xml2').any? or package_config('libxml-2.0')
|
412
|
+
dir_config('xslt').any? or package_config('libxslt')
|
413
|
+
dir_config('exslt').any? or package_config('libexslt')
|
374
414
|
|
375
|
-
|
376
|
-
|
415
|
+
check_libxml_version or abort "ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed."
|
416
|
+
check_libxml_version("2.6.21") or abort "ERROR: libxml2 version 2.6.21 or later is required!"
|
417
|
+
check_libxml_version("2.9.3") or warn "WARNING: libxml2 version 2.9.3 or later is highly recommended, but proceeding anyway."
|
377
418
|
|
378
|
-
#if LIBXML_VERSION < 20621
|
379
|
-
#error libxml2 is way too old
|
380
|
-
#endif
|
381
|
-
SRC
|
382
|
-
|
383
|
-
try_cpp(<<-SRC) or warn "libxml2 version 2.9.3 or later is highly recommended, but proceeding anyway."
|
384
|
-
#include <libxml/xmlversion.h>
|
385
|
-
|
386
|
-
#if LIBXML_VERSION < 20903
|
387
|
-
#error libxml2 is too old
|
388
|
-
#endif
|
389
|
-
SRC
|
390
419
|
else
|
391
420
|
message "Building nokogiri using packaged libraries.\n"
|
392
421
|
|
393
422
|
# The gem version constraint in the Rakefile is not respected at install time.
|
394
423
|
# Keep this version in sync with the one in the Rakefile !
|
395
|
-
|
424
|
+
require 'rubygems'
|
425
|
+
gem 'mini_portile2', '~> 2.1.0'
|
396
426
|
require 'mini_portile2'
|
397
427
|
message "Using mini_portile version #{MiniPortile::VERSION}\n"
|
398
428
|
|
@@ -504,13 +534,13 @@ EOM
|
|
504
534
|
have_library('lzma')
|
505
535
|
}
|
506
536
|
|
507
|
-
$libs = $libs.shellsplit.tap
|
508
|
-
[libxml2_recipe, libxslt_recipe].each
|
537
|
+
$libs = $libs.shellsplit.tap do |libs|
|
538
|
+
[libxml2_recipe, libxslt_recipe].each do |recipe|
|
509
539
|
libname = recipe.name[/\Alib(.+)\z/, 1]
|
510
|
-
File.join(recipe.path, "bin", "#{libname}-config").tap
|
540
|
+
File.join(recipe.path, "bin", "#{libname}-config").tap do |config|
|
511
541
|
# call config scripts explicit with 'sh' for compat with Windows
|
512
542
|
$CPPFLAGS = `sh #{config} --cflags`.strip << ' ' << $CPPFLAGS
|
513
|
-
`sh #{config} --libs`.strip.shellsplit.each
|
543
|
+
`sh #{config} --libs`.strip.shellsplit.each do |arg|
|
514
544
|
case arg
|
515
545
|
when /\A-L(.+)\z/
|
516
546
|
# Prioritize ports' directories
|
@@ -524,8 +554,8 @@ EOM
|
|
524
554
|
else
|
525
555
|
$LDFLAGS << ' ' << arg.shellescape
|
526
556
|
end
|
527
|
-
|
528
|
-
|
557
|
+
end
|
558
|
+
end
|
529
559
|
|
530
560
|
# Defining a macro that expands to a C string; double quotes are significant.
|
531
561
|
$CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATH=\"#{recipe.path}\"".inspect
|
@@ -544,11 +574,11 @@ EOM
|
|
544
574
|
# -lexslt, so add it manually.
|
545
575
|
libs.unshift('-lexslt')
|
546
576
|
end
|
547
|
-
|
548
|
-
|
577
|
+
end
|
578
|
+
end.shelljoin
|
549
579
|
|
550
580
|
if static_p
|
551
|
-
$libs = $libs.shellsplit.map
|
581
|
+
$libs = $libs.shellsplit.map do |arg|
|
552
582
|
case arg
|
553
583
|
when '-lxml2'
|
554
584
|
File.join(libxml2_recipe.path, 'lib', lib_a(arg))
|
@@ -557,7 +587,7 @@ EOM
|
|
557
587
|
else
|
558
588
|
arg
|
559
589
|
end
|
560
|
-
|
590
|
+
end.shelljoin
|
561
591
|
end
|
562
592
|
end
|
563
593
|
|
@@ -565,12 +595,12 @@ end
|
|
565
595
|
"xml2" => ['xmlParseDoc', 'libxml/parser.h'],
|
566
596
|
"xslt" => ['xsltParseStylesheetDoc', 'libxslt/xslt.h'],
|
567
597
|
"exslt" => ['exsltFuncRegister', 'libexslt/exslt.h'],
|
568
|
-
}.each
|
598
|
+
}.each do |lib, (func, header)|
|
569
599
|
have_func(func, header) ||
|
570
600
|
have_library(lib, func, header) ||
|
571
601
|
have_library("lib#{lib}", func, header) or
|
572
602
|
asplode("lib#{lib}")
|
573
|
-
|
603
|
+
end
|
574
604
|
|
575
605
|
have_func('xmlHasFeature') or abort "xmlHasFeature() is missing."
|
576
606
|
have_func('xmlFirstElementChild')
|
@@ -590,14 +620,14 @@ create_makefile('nokogiri/nokogiri')
|
|
590
620
|
|
591
621
|
if enable_config('clean', true)
|
592
622
|
# Do not clean if run in a development work tree.
|
593
|
-
File.open('Makefile', 'at')
|
623
|
+
File.open('Makefile', 'at') do |mk|
|
594
624
|
mk.print <<EOF
|
595
625
|
all: clean-ports
|
596
626
|
|
597
627
|
clean-ports: $(DLLIB)
|
598
628
|
-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static
|
599
629
|
EOF
|
600
|
-
|
630
|
+
end
|
601
631
|
end
|
602
632
|
|
603
633
|
# :startdoc:
|
data/ext/nokogiri/xml_node.c
CHANGED
@@ -233,6 +233,23 @@ ok:
|
|
233
233
|
* uninteresting libxml2 implementation detail). as a result, we cannot
|
234
234
|
* reparent the actual reparentee, so we reparent a duplicate.
|
235
235
|
*/
|
236
|
+
if (reparentee->type == XML_TEXT_NODE && reparentee->_private) {
|
237
|
+
/*
|
238
|
+
* additionally, since we know this C struct isn't going to be related to
|
239
|
+
* a Ruby object anymore, let's break the relationship on this end as
|
240
|
+
* well.
|
241
|
+
*
|
242
|
+
* this is not absolutely necessary unless libxml-ruby is also in effect,
|
243
|
+
* in which case its global callback `rxml_node_deregisterNode` will try
|
244
|
+
* to do things to our data.
|
245
|
+
*
|
246
|
+
* for more details on this particular (and particularly nasty) edge
|
247
|
+
* case, see:
|
248
|
+
*
|
249
|
+
* https://github.com/sparklemotion/nokogiri/issues/1426
|
250
|
+
*/
|
251
|
+
reparentee->_private = NULL ;
|
252
|
+
}
|
236
253
|
nokogiri_root_node(reparentee);
|
237
254
|
if (!(reparentee = xmlDocCopyNode(reparentee, pivot->doc, 1))) {
|
238
255
|
rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
|
data/lib/nokogiri/nokogiri.jar
CHANGED
Binary file
|
data/lib/nokogiri/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -7,6 +7,10 @@ require 'tempfile'
|
|
7
7
|
require 'pp'
|
8
8
|
|
9
9
|
require 'nokogiri'
|
10
|
+
if ENV['TEST_NOKOGIRI_WITH_LIBXML_RUBY']
|
11
|
+
require 'libxml'
|
12
|
+
warn "#{__FILE__}:#{__LINE__}: loaded libxml-ruby '#{LibXML::XML::VERSION}'"
|
13
|
+
end
|
10
14
|
|
11
15
|
warn "#{__FILE__}:#{__LINE__}: version info: #{Nokogiri::VERSION_INFO.inspect}"
|
12
16
|
|
@@ -230,7 +230,7 @@ module Nokogiri
|
|
230
230
|
|
231
231
|
def test_element_children_counts
|
232
232
|
doc = Nokogiri::HTML::DocumentFragment.parse(" <div> </div>\n ")
|
233
|
-
|
233
|
+
assert_equal 1, doc.element_children.count
|
234
234
|
end
|
235
235
|
|
236
236
|
def test_malformed_fragment_is_corrected
|
data/test/xml/test_node.rb
CHANGED
@@ -1228,6 +1228,17 @@ eoxml
|
|
1228
1228
|
subject.lang = "fr"
|
1229
1229
|
assert_equal "fr", subject.lang
|
1230
1230
|
end
|
1231
|
+
|
1232
|
+
def test_text_node_robustness_gh1426
|
1233
|
+
# notably, the original bug report was about libxml-ruby interactions
|
1234
|
+
# this test should blow up under valgrind if we regress on libxml-ruby workarounds
|
1235
|
+
message = "<h2>BOOM!</h2>"
|
1236
|
+
10_000.times do
|
1237
|
+
node = Nokogiri::HTML::DocumentFragment.parse(message)
|
1238
|
+
node.add_previous_sibling(Nokogiri::XML::Text.new('before', node.document))
|
1239
|
+
node.add_next_sibling(Nokogiri::XML::Text.new('after', node.document))
|
1240
|
+
end
|
1241
|
+
end
|
1231
1242
|
end
|
1232
1243
|
end
|
1233
1244
|
end
|
data/test_all
CHANGED
@@ -25,6 +25,14 @@ RUBIES="\
|
|
25
25
|
TEST_LOG=test.log
|
26
26
|
VALGRIND_LOG=valgrind.log
|
27
27
|
|
28
|
+
if ! grep libxml-ruby Gemfile ; then
|
29
|
+
echo "ERROR: please add this line your Gemfile temporarily so we can run libxml-ruby tests:"
|
30
|
+
echo
|
31
|
+
echo "gem 'libxml-ruby', :platform => :mri"
|
32
|
+
echo
|
33
|
+
exit 1
|
34
|
+
fi
|
35
|
+
|
28
36
|
# Load RVM into a shell session *as a function*
|
29
37
|
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
|
30
38
|
source "$HOME/.rvm/scripts/rvm"
|
@@ -83,6 +91,13 @@ for ruby in $RUBIES ; do
|
|
83
91
|
compile
|
84
92
|
echo "** running tests ..."
|
85
93
|
bundle exec rake test 2>&1 | tee -a $TEST_LOG
|
94
|
+
if [[ ! $ruby =~ "jruby" ]] ; then
|
95
|
+
echo "** running tests again with libxml-ruby loaded ..."
|
96
|
+
if ! gem list libxml-ruby | fgrep 2.8.0 ; then
|
97
|
+
gem install libxml-ruby
|
98
|
+
fi
|
99
|
+
bundle exec rake test:libxml-ruby 2>&1 | tee -a $TEST_LOG
|
100
|
+
fi
|
86
101
|
clean
|
87
102
|
done
|
88
103
|
|
@@ -94,6 +109,8 @@ for ruby in $RUBIES ; do
|
|
94
109
|
compile
|
95
110
|
echo "** running valgrind on tests ..."
|
96
111
|
bundle exec rake test:valgrind 2>&1 | tee -a $VALGRIND_LOG
|
112
|
+
echo "** running valgrind again with libxml-ruby loaded ..."
|
113
|
+
bundle exec rake test:valgrind:libxml-ruby 2>&1 | tee -a $VALGRIND_LOG
|
97
114
|
clean
|
98
115
|
fi
|
99
116
|
done
|
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.8.
|
4
|
+
version: 1.6.8.rc3
|
5
5
|
platform: java
|
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: 2016-
|
15
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rdoc
|
@@ -132,12 +132,12 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - ~>
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: 0.5.
|
135
|
+
version: 0.5.1
|
136
136
|
requirement: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
138
|
- - ~>
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: 0.5.
|
140
|
+
version: 0.5.1
|
141
141
|
prerelease: false
|
142
142
|
type: :development
|
143
143
|
- !ruby/object:Gem::Dependency
|