nokogiri 1.7.2-x64-mingw32 → 1.8.0-x64-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 +4 -4
- data/.cross_rubies +4 -4
- data/.travis.yml +43 -24
- data/CHANGELOG.md +54 -6
- data/Gemfile +8 -7
- data/Gemfile-libxml-ruby +3 -0
- data/LICENSE-DEPENDENCIES.md +1612 -0
- data/{LICENSE.txt → LICENSE.md} +1 -1
- data/Manifest.txt +5 -8
- data/README.md +8 -5
- data/Rakefile +15 -31
- data/appveyor.yml +2 -0
- data/dependencies.yml +12 -7
- data/ext/nokogiri/extconf.rb +12 -17
- data/ext/nokogiri/nokogiri.h +0 -10
- data/ext/nokogiri/xml_attr.c +12 -8
- data/ext/nokogiri/xml_node.c +17 -14
- data/ext/nokogiri/xml_sax_push_parser.c +56 -12
- data/lib/nokogiri/2.2/nokogiri.so +0 -0
- data/lib/nokogiri/2.3/nokogiri.so +0 -0
- data/lib/nokogiri/2.4/nokogiri.so +0 -0
- data/lib/nokogiri/html/sax/parser.rb +10 -0
- data/lib/nokogiri/version.rb +5 -4
- data/lib/nokogiri/xml/document.rb +9 -9
- data/lib/nokogiri/xml/node.rb +7 -7
- data/lib/nokogiri/xml/node_set.rb +12 -7
- data/lib/nokogiri/xml/sax/parser.rb +6 -7
- data/lib/nokogiri/xml/searchable.rb +34 -25
- data/lib/nokogiri/xml/syntax_error.rb +24 -1
- data/test/decorators/test_slop.rb +4 -1
- data/test/helper.rb +10 -0
- data/test/html/sax/test_parser.rb +27 -0
- data/test/html/test_document.rb +12 -1
- data/test/html/test_document_encoding.rb +1 -3
- data/test/html/test_document_fragment.rb +3 -0
- data/test/xml/sax/test_push_parser.rb +48 -0
- data/test/xml/test_attr.rb +7 -0
- data/test/xml/test_document.rb +1 -1
- data/test/xml/test_document_fragment.rb +27 -0
- data/test/xml/test_entity_reference.rb +2 -2
- data/test/xml/test_node.rb +12 -15
- data/test/xml/test_node_reparenting.rb +14 -0
- data/test/xml/test_node_set.rb +8 -6
- data/test/xml/test_reader.rb +19 -0
- data/test/xml/test_syntax_error.rb +21 -15
- data/test/xml/test_unparented_node.rb +54 -11
- data/test/xml/test_xpath.rb +23 -6
- metadata +36 -24
- data/lib/nokogiri/2.1/nokogiri.so +0 -0
- data/suppressions/nokogiri_ree-1.8.7.358.supp +0 -61
- data/suppressions/nokogiri_ruby-1.8.7.370.supp +0 -0
- data/suppressions/nokogiri_ruby-1.9.2.320.supp +0 -28
- data/suppressions/nokogiri_ruby-1.9.3.327.supp +0 -28
- data/test_all +0 -105
data/{LICENSE.txt → LICENSE.md}
RENAMED
data/Manifest.txt
CHANGED
@@ -7,7 +7,9 @@ CHANGELOG.md
|
|
7
7
|
CONTRIBUTING.md
|
8
8
|
C_CODING_STYLE.rdoc
|
9
9
|
Gemfile
|
10
|
-
|
10
|
+
Gemfile-libxml-ruby
|
11
|
+
LICENSE-DEPENDENCIES.md
|
12
|
+
LICENSE.md
|
11
13
|
Manifest.txt
|
12
14
|
README.md
|
13
15
|
ROADMAP.md
|
@@ -54,7 +56,6 @@ ext/java/nokogiri/internals/ClosedStreamException.java
|
|
54
56
|
ext/java/nokogiri/internals/HtmlDomParserContext.java
|
55
57
|
ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java
|
56
58
|
ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java
|
57
|
-
ext/java/nokogiri/internals/NokogiriDocumentCache.java
|
58
59
|
ext/java/nokogiri/internals/NokogiriDomParser.java
|
59
60
|
ext/java/nokogiri/internals/NokogiriEncodingReaderWrapper.java
|
60
61
|
ext/java/nokogiri/internals/NokogiriEntityResolver.java
|
@@ -75,10 +76,10 @@ ext/java/nokogiri/internals/ReaderNode.java
|
|
75
76
|
ext/java/nokogiri/internals/SaveContextVisitor.java
|
76
77
|
ext/java/nokogiri/internals/SchemaErrorHandler.java
|
77
78
|
ext/java/nokogiri/internals/UncloseableInputStream.java
|
79
|
+
ext/java/nokogiri/internals/XalanDTMManagerPatch.java
|
78
80
|
ext/java/nokogiri/internals/XmlDeclHandler.java
|
79
81
|
ext/java/nokogiri/internals/XmlDomParserContext.java
|
80
82
|
ext/java/nokogiri/internals/XmlSaxParser.java
|
81
|
-
ext/java/nokogiri/internals/XsltExtensionFunction.java
|
82
83
|
ext/java/nokogiri/internals/c14n/AttrCompare.java
|
83
84
|
ext/java/nokogiri/internals/c14n/C14nHelper.java
|
84
85
|
ext/java/nokogiri/internals/c14n/CanonicalFilter.java
|
@@ -106,6 +107,7 @@ ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java
|
|
106
107
|
ext/java/nokogiri/internals/c14n/NodeFilter.java
|
107
108
|
ext/java/nokogiri/internals/c14n/UtfHelpper.java
|
108
109
|
ext/java/nokogiri/internals/c14n/XMLUtils.java
|
110
|
+
ext/java/org/apache/xml/dtm/ref/dom2dtm/DOM2DTMExt.java
|
109
111
|
ext/nokogiri/depend
|
110
112
|
ext/nokogiri/extconf.rb
|
111
113
|
ext/nokogiri/html_document.c
|
@@ -253,10 +255,6 @@ patches/libxslt/0001-Fix-heap-overread-in-xsltFormatNumberConversion.patch
|
|
253
255
|
patches/libxslt/0002-Check-for-integer-overflow-in-xsltAddTextString.patch
|
254
256
|
patches/sort-patches-by-date
|
255
257
|
suppressions/README.txt
|
256
|
-
suppressions/nokogiri_ree-1.8.7.358.supp
|
257
|
-
suppressions/nokogiri_ruby-1.8.7.370.supp
|
258
|
-
suppressions/nokogiri_ruby-1.9.2.320.supp
|
259
|
-
suppressions/nokogiri_ruby-1.9.3.327.supp
|
260
258
|
tasks/test.rb
|
261
259
|
test/css/test_nthiness.rb
|
262
260
|
test/css/test_parser.rb
|
@@ -366,4 +364,3 @@ test/xml/test_xinclude.rb
|
|
366
364
|
test/xml/test_xpath.rb
|
367
365
|
test/xslt/test_custom_functions.rb
|
368
366
|
test/xslt/test_exception_handling.rb
|
369
|
-
test_all
|
data/README.md
CHANGED
@@ -10,10 +10,13 @@
|
|
10
10
|
|
11
11
|
## Status
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
[![
|
16
|
-
[![
|
13
|
+
|System|Status|
|
14
|
+
|--|--|
|
15
|
+
| Concourse | [![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) |
|
16
|
+
| Travis | [![Travis Build Status](https://travis-ci.org/sparklemotion/nokogiri.svg?branch=master)](https://travis-ci.org/sparklemotion/nokogiri) |
|
17
|
+
| Appveyor | [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/sparklemotion/nokogiri?branch=master&svg=true)](https://ci.appveyor.com/project/flavorjones/nokogiri?branch=master) |
|
18
|
+
| Code Climate | [![Code Climate](https://codeclimate.com/github/sparklemotion/nokogiri.svg)](https://codeclimate.com/github/sparklemotion/nokogiri) |
|
19
|
+
| Version Eye | [![Version Eye](https://www.versioneye.com/ruby/nokogiri/badge.png)](https://www.versioneye.com/ruby/nokogiri) |
|
17
20
|
|
18
21
|
|
19
22
|
## Description
|
@@ -167,4 +170,4 @@ explicitly setting the encoding to EUC-JP on the parser:
|
|
167
170
|
|
168
171
|
## License
|
169
172
|
|
170
|
-
MIT. See the `LICENSE.
|
173
|
+
MIT. See the `LICENSE.md` file.
|
data/Rakefile
CHANGED
@@ -125,25 +125,29 @@ HOE = Hoe.spec 'nokogiri' do
|
|
125
125
|
|
126
126
|
unless java?
|
127
127
|
self.extra_deps += [
|
128
|
-
["mini_portile2", "~> 2.
|
128
|
+
["mini_portile2", "~> 2.2.0"], # keep version in sync with extconf.rb
|
129
129
|
]
|
130
130
|
end
|
131
131
|
|
132
132
|
self.extra_dev_deps += [
|
133
133
|
["hoe-bundler", "~> 1.2.0"],
|
134
|
-
["hoe-debugging", "~> 1.
|
134
|
+
["hoe-debugging", "~> 1.3.0"],
|
135
135
|
["hoe-gemspec", "~> 1.0.0"],
|
136
136
|
["hoe-git", "~> 1.6.0"],
|
137
137
|
["minitest", "~> 5.8.4"],
|
138
|
-
["rake", "~>
|
139
|
-
["rake-compiler", "~> 0.
|
140
|
-
["rake-compiler-dock", "~> 0.
|
138
|
+
["rake", "~> 12.0"],
|
139
|
+
["rake-compiler", "~> 1.0.3"],
|
140
|
+
["rake-compiler-dock", "~> 0.6.0"],
|
141
141
|
["racc", "~> 1.4.14"],
|
142
|
-
["rexical", "~> 1.0.5"]
|
142
|
+
["rexical", "~> 1.0.5"],
|
143
|
+
["concourse", "~> 0.11"],
|
143
144
|
]
|
144
145
|
|
145
146
|
if java?
|
146
|
-
self.spec_extras = {
|
147
|
+
self.spec_extras = {
|
148
|
+
:platform => 'java',
|
149
|
+
:required_ruby_version => '>= 1.9.3' # JRuby >= 1.7
|
150
|
+
}
|
147
151
|
else
|
148
152
|
self.spec_extras = {
|
149
153
|
:extensions => ["ext/nokogiri/extconf.rb"],
|
@@ -230,11 +234,6 @@ else
|
|
230
234
|
ext.cross_compiling do |spec|
|
231
235
|
libs = dependencies.map { |name, dep| "#{name}-#{dep["version"]}" }.join(', ')
|
232
236
|
|
233
|
-
spec.required_ruby_version = [
|
234
|
-
'>= 2.1.0',
|
235
|
-
"< #{CROSS_RUBIES.max_by(&:ver).minor_ver.succ}"
|
236
|
-
]
|
237
|
-
|
238
237
|
spec.post_install_message = <<-EOS
|
239
238
|
Nokogiri is built with the packaged libraries: #{libs}.
|
240
239
|
EOS
|
@@ -259,7 +258,7 @@ task 'bundler:gemfile' do
|
|
259
258
|
old_gemfile_task.invoke if old_gemfile_task
|
260
259
|
|
261
260
|
lines = File.open('Gemfile', 'r') { |f| f.readlines }.map do |line|
|
262
|
-
line =~ /racc|rexical/ ? "#{line.strip}, :platform => :ruby" : line
|
261
|
+
line =~ /racc|rexical/ ? "#{line.strip}, :platform => [:ruby, :mingw, :x64_mingw]" : line
|
263
262
|
end
|
264
263
|
File.open('Gemfile', 'w') { |f| lines.each { |line| f.puts line } }
|
265
264
|
end
|
@@ -314,23 +313,8 @@ if Hoe.plugins.include?(:debugging)
|
|
314
313
|
end
|
315
314
|
end
|
316
315
|
|
317
|
-
|
318
|
-
|
319
|
-
warn "#{__FILE__}:#{__LINE__}: --- running tests with libxml-ruby loaded ---"
|
320
|
-
Rake::Task[:test].execute
|
321
|
-
ENV['TEST_NOKOGIRI_WITH_LIBXML_RUBY'] = nil
|
322
|
-
end
|
323
|
-
|
324
|
-
Rake::Task["test:libxml-ruby"].prerequisites << :compile
|
325
|
-
|
326
|
-
task "test:valgrind:libxml-ruby" do
|
327
|
-
ENV['TEST_NOKOGIRI_WITH_LIBXML_RUBY'] = "1"
|
328
|
-
warn "#{__FILE__}:#{__LINE__}: --- running tests with libxml-ruby loaded ---"
|
329
|
-
Rake::Task["test:valgrind"].execute
|
330
|
-
ENV['TEST_NOKOGIRI_WITH_LIBXML_RUBY'] = nil
|
331
|
-
end
|
332
|
-
|
333
|
-
Rake::Task["test:valgrind:libxml-ruby"].prerequisites << :compile
|
316
|
+
require 'concourse'
|
317
|
+
Concourse.new("nokogiri").create_tasks!
|
334
318
|
|
335
319
|
# ----------------------------------------
|
336
320
|
|
@@ -352,7 +336,7 @@ end
|
|
352
336
|
task :cross do
|
353
337
|
rake_compiler_config_path = File.expand_path("~/.rake-compiler/config.yml")
|
354
338
|
unless File.exists? rake_compiler_config_path
|
355
|
-
raise "rake-compiler has not installed any cross rubies.
|
339
|
+
raise "rake-compiler has not installed any cross rubies. Use rake-compiler-dock or 'rake gem:windows' for building binary windows gems."
|
356
340
|
end
|
357
341
|
|
358
342
|
CROSS_RUBIES.each do |cross_ruby|
|
data/appveyor.yml
CHANGED
data/dependencies.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
libxml2:
|
2
2
|
version: "2.9.4"
|
3
|
-
|
3
|
+
sha256: "ffb911191e509b966deb55de705387f14156e1a56b21824357cdf0053233633c" # manually confirmed via `gpg --verify`
|
4
4
|
# gpg: Signature made Mon 23 May 2016 04:02:13 AM EDT using DSA key ID DE95BC1F
|
5
5
|
# gpg: Good signature from "Daniel Veillard (Red Hat work email) <veillard@redhat.com>"
|
6
6
|
# gpg: aka "Daniel Veillard <Daniel.Veillard@w3.org>"
|
@@ -10,7 +10,7 @@ libxml2:
|
|
10
10
|
|
11
11
|
libxslt:
|
12
12
|
version: "1.1.29"
|
13
|
-
|
13
|
+
sha256: "b5976e3857837e7617b29f2249ebb5eeac34e249208d31f1fbf7a6ba7a4090ce"
|
14
14
|
# gpg: Signature made Mon 23 May 2016 09:58:52 PM EDT using DSA key ID DE95BC1F
|
15
15
|
# gpg: Good signature from "Daniel Veillard (Red Hat work email) <veillard@redhat.com>"
|
16
16
|
# gpg: aka "Daniel Veillard <Daniel.Veillard@w3.org>"
|
@@ -20,10 +20,15 @@ libxslt:
|
|
20
20
|
|
21
21
|
zlib:
|
22
22
|
version: "1.2.11"
|
23
|
-
|
23
|
+
sha256: "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
|
24
|
+
# SHA-256 hash provided on http://zlib.net/
|
24
25
|
|
25
26
|
libiconv:
|
26
|
-
version: "1.
|
27
|
-
|
28
|
-
# gpg: Signature made
|
29
|
-
# gpg:
|
27
|
+
version: "1.15"
|
28
|
+
sha256: "ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178"
|
29
|
+
# gpg: Signature made Fri Feb 3 00:38:12 2017 CET
|
30
|
+
# gpg: using RSA key 4F494A942E4616C2
|
31
|
+
# gpg: Good signature from "Bruno Haible (Open Source Development) <bruno@clisp.org>" [unknown]
|
32
|
+
# gpg: WARNING: This key is not certified with a trusted signature!
|
33
|
+
# gpg: There is no indication that the signature belongs to the owner.
|
34
|
+
# Primary key fingerprint: 68D9 4D8A AEEA D48A E7DC 5B90 4F49 4A94 2E46 16C2
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -223,8 +223,8 @@ def iconv_configure_flags
|
|
223
223
|
|
224
224
|
return [
|
225
225
|
'--with-iconv=yes',
|
226
|
-
*("CPPFLAGS=#{idirs.map { |dir| '-I'
|
227
|
-
*("LDFLAGS=#{ldirs.map { |dir| '-L'
|
226
|
+
*("CPPFLAGS=#{idirs.map { |dir| '-I' + dir }.join(' ')}" if idirs),
|
227
|
+
*("LDFLAGS=#{ldirs.map { |dir| '-L' + dir }.join(' ')}" if ldirs),
|
228
228
|
]
|
229
229
|
end
|
230
230
|
end
|
@@ -260,11 +260,12 @@ end
|
|
260
260
|
|
261
261
|
def process_recipe(name, version, static_p, cross_p)
|
262
262
|
MiniPortile.new(name, version).tap do |recipe|
|
263
|
-
recipe.target =
|
263
|
+
recipe.target = File.join(ROOT, "ports")
|
264
264
|
# Prefer host_alias over host in order to use i586-mingw32msvc as
|
265
265
|
# correct compiler prefix for cross build, but use host if not set.
|
266
266
|
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
267
267
|
recipe.patch_files = Dir[File.join(ROOT, "patches", name, "*.patch")].sort
|
268
|
+
recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}"
|
268
269
|
|
269
270
|
yield recipe
|
270
271
|
|
@@ -307,7 +308,7 @@ def process_recipe(name, version, static_p, cross_p)
|
|
307
308
|
if RbConfig::CONFIG['target_cpu'] == 'universal'
|
308
309
|
%w[CFLAGS LDFLAGS].each do |key|
|
309
310
|
unless env[key].include?('-arch')
|
310
|
-
env[key]
|
311
|
+
env[key] += ' ' + RbConfig::CONFIG['ARCH_FLAG']
|
311
312
|
end
|
312
313
|
end
|
313
314
|
end
|
@@ -391,7 +392,7 @@ when arg_config('--clean')
|
|
391
392
|
do_clean
|
392
393
|
end
|
393
394
|
|
394
|
-
if openbsd?
|
395
|
+
if openbsd? && !using_system_libraries?
|
395
396
|
ENV['CC'] ||= find_executable('egcc') or
|
396
397
|
abort "Please install gcc 4.9+ from ports using `pkg_add -v gcc`"
|
397
398
|
end
|
@@ -456,7 +457,7 @@ else
|
|
456
457
|
# The gem version constraint in the Rakefile is not respected at install time.
|
457
458
|
# Keep this version in sync with the one in the Rakefile !
|
458
459
|
require 'rubygems'
|
459
|
-
gem 'mini_portile2', '~> 2.
|
460
|
+
gem 'mini_portile2', '~> 2.2.0'
|
460
461
|
require 'mini_portile2'
|
461
462
|
message "Using mini_portile version #{MiniPortile::VERSION}\n"
|
462
463
|
|
@@ -473,8 +474,8 @@ else
|
|
473
474
|
if cross_build_p || windows?
|
474
475
|
zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
|
475
476
|
recipe.files = [{
|
476
|
-
url: "http://zlib.net/#{recipe.name}-#{recipe.version}.tar.gz",
|
477
|
-
|
477
|
+
url: "http://zlib.net/fossils/#{recipe.name}-#{recipe.version}.tar.gz",
|
478
|
+
sha256: dependencies["zlib"]["sha256"]
|
478
479
|
}]
|
479
480
|
class << recipe
|
480
481
|
attr_accessor :cross_build_p
|
@@ -512,7 +513,7 @@ else
|
|
512
513
|
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p, cross_build_p) do |recipe|
|
513
514
|
recipe.files = [{
|
514
515
|
url: "http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
|
515
|
-
|
516
|
+
sha256: dependencies["libiconv"]["sha256"]
|
516
517
|
}]
|
517
518
|
recipe.configure_options += [
|
518
519
|
"CPPFLAGS=-Wall",
|
@@ -547,7 +548,7 @@ EOM
|
|
547
548
|
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
|
548
549
|
recipe.files = [{
|
549
550
|
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
550
|
-
|
551
|
+
sha256: dependencies["libxml2"]["sha256"]
|
551
552
|
}]
|
552
553
|
recipe.configure_options += [
|
553
554
|
"--without-python",
|
@@ -563,7 +564,7 @@ EOM
|
|
563
564
|
libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"]["version"], static_p, cross_build_p) do |recipe|
|
564
565
|
recipe.files = [{
|
565
566
|
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
566
|
-
|
567
|
+
sha256: dependencies["libxslt"]["sha256"]
|
567
568
|
}]
|
568
569
|
recipe.configure_options += [
|
569
570
|
"--without-python",
|
@@ -657,12 +658,6 @@ have_func('xmlRelaxNGSetValidStructuredErrors')
|
|
657
658
|
have_func('xmlSchemaSetValidStructuredErrors')
|
658
659
|
have_func('xmlSchemaSetParserStructuredErrors')
|
659
660
|
|
660
|
-
if ENV['CPUPROFILE']
|
661
|
-
unless find_library('profiler', 'ProfilerEnable', *LIB_DIRS)
|
662
|
-
abort "google performance tools are not installed"
|
663
|
-
end
|
664
|
-
end
|
665
|
-
|
666
661
|
create_makefile('nokogiri/nokogiri')
|
667
662
|
|
668
663
|
if enable_config('clean', true)
|
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -34,16 +34,6 @@ int vasprintf (char **strp, const char *fmt, va_list ap);
|
|
34
34
|
#include <ruby/st.h>
|
35
35
|
#include <ruby/encoding.h>
|
36
36
|
|
37
|
-
#ifndef UNUSED
|
38
|
-
# if defined(__GNUC__)
|
39
|
-
# define MAYBE_UNUSED(name) name __attribute__((unused))
|
40
|
-
# define UNUSED(name) MAYBE_UNUSED(UNUSED_ ## name)
|
41
|
-
# else
|
42
|
-
# define MAYBE_UNUSED(name) name
|
43
|
-
# define UNUSED(name) name
|
44
|
-
# endif
|
45
|
-
#endif
|
46
|
-
|
47
37
|
#ifndef NORETURN
|
48
38
|
# if defined(__GNUC__)
|
49
39
|
# define NORETURN(name) __attribute__((noreturn)) name
|
data/ext/nokogiri/xml_attr.c
CHANGED
@@ -11,11 +11,11 @@ static VALUE set_value(VALUE self, VALUE content)
|
|
11
11
|
xmlAttrPtr attr;
|
12
12
|
Data_Get_Struct(self, xmlAttr, attr);
|
13
13
|
|
14
|
-
if(attr->children) xmlFreeNodeList(attr->children);
|
14
|
+
if (attr->children) { xmlFreeNodeList(attr->children); }
|
15
15
|
|
16
16
|
attr->children = attr->last = NULL;
|
17
17
|
|
18
|
-
if(content) {
|
18
|
+
if (content) {
|
19
19
|
xmlChar *buffer;
|
20
20
|
xmlNode *tmp;
|
21
21
|
|
@@ -30,7 +30,7 @@ static VALUE set_value(VALUE self, VALUE content)
|
|
30
30
|
for(tmp = attr->children; tmp; tmp = tmp->next) {
|
31
31
|
tmp->parent = (xmlNode *)attr;
|
32
32
|
tmp->doc = attr->doc;
|
33
|
-
if(tmp->next == NULL) attr->last = tmp;
|
33
|
+
if (tmp->next == NULL) { attr->last = tmp; }
|
34
34
|
}
|
35
35
|
|
36
36
|
/* Free up memory */
|
@@ -57,20 +57,24 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
57
57
|
|
58
58
|
rb_scan_args(argc, argv, "2*", &document, &name, &rest);
|
59
59
|
|
60
|
+
if (! rb_obj_is_kind_of(document, cNokogiriXmlDocument)) {
|
61
|
+
rb_raise(rb_eArgError, "parameter must be a Nokogiri::XML::Document");
|
62
|
+
}
|
63
|
+
|
60
64
|
Data_Get_Struct(document, xmlDoc, xml_doc);
|
61
65
|
|
62
66
|
node = xmlNewDocProp(
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
xml_doc,
|
68
|
+
(const xmlChar *)StringValueCStr(name),
|
69
|
+
NULL
|
70
|
+
);
|
67
71
|
|
68
72
|
nokogiri_root_node((xmlNodePtr)node);
|
69
73
|
|
70
74
|
rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)node);
|
71
75
|
rb_obj_call_init(rb_node, argc, argv);
|
72
76
|
|
73
|
-
if(rb_block_given_p()) rb_yield(rb_node);
|
77
|
+
if (rb_block_given_p()) { rb_yield(rb_node); }
|
74
78
|
|
75
79
|
return rb_node;
|
76
80
|
}
|
data/ext/nokogiri/xml_node.c
CHANGED
@@ -833,37 +833,40 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
|
|
833
833
|
static VALUE get(VALUE self, VALUE rattribute)
|
834
834
|
{
|
835
835
|
xmlNodePtr node;
|
836
|
-
xmlChar*
|
837
|
-
VALUE rvalue
|
838
|
-
|
839
|
-
|
836
|
+
const xmlChar *value = 0;
|
837
|
+
VALUE rvalue;
|
838
|
+
xmlChar *colon;
|
839
|
+
const xmlChar *attribute, *attr_name, *prefix;
|
840
840
|
xmlNsPtr ns;
|
841
841
|
|
842
842
|
if (NIL_P(rattribute)) return Qnil;
|
843
843
|
|
844
844
|
Data_Get_Struct(self, xmlNode, node);
|
845
|
-
attribute =
|
845
|
+
attribute = xmlCharStrdup(StringValueCStr(rattribute));
|
846
846
|
|
847
|
-
colon =
|
847
|
+
colon = (xmlChar *)xmlStrchr(attribute, (const xmlChar)':');
|
848
848
|
if (colon) {
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
849
|
+
/* split the attribute string into separate prefix and name by
|
850
|
+
* null-terminating the prefix at the colon */
|
851
|
+
prefix = attribute;
|
852
|
+
attr_name = colon + 1;
|
853
|
+
(*colon) = 0;
|
854
|
+
|
855
|
+
ns = xmlSearchNs(node->doc, node, prefix);
|
853
856
|
if (ns) {
|
854
|
-
value = xmlGetNsProp(node,
|
857
|
+
value = xmlGetNsProp(node, attr_name, ns->href);
|
855
858
|
} else {
|
856
859
|
value = xmlGetProp(node, (xmlChar*)StringValueCStr(rattribute));
|
857
860
|
}
|
858
861
|
} else {
|
859
|
-
value = xmlGetNoNsProp(node,
|
862
|
+
value = xmlGetNoNsProp(node, attribute);
|
860
863
|
}
|
861
864
|
|
862
|
-
|
865
|
+
xmlFree((void *)attribute);
|
863
866
|
if (!value) return Qnil;
|
864
867
|
|
865
868
|
rvalue = NOKOGIRI_STR_NEW2(value);
|
866
|
-
xmlFree(value);
|
869
|
+
xmlFree((void *)value);
|
867
870
|
|
868
871
|
return rvalue ;
|
869
872
|
}
|