nokogiri 1.4.1-x86-mingw32 → 1.4.2.1-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.
- data/CHANGELOG.ja.rdoc +45 -0
- data/CHANGELOG.rdoc +53 -1
- data/Manifest.txt +3 -3
- data/README.ja.rdoc +1 -1
- data/README.rdoc +11 -5
- data/Rakefile +13 -79
- data/ext/nokogiri/extconf.rb +25 -74
- data/ext/nokogiri/html_document.c +17 -8
- data/ext/nokogiri/html_element_description.c +20 -16
- data/ext/nokogiri/html_entity_lookup.c +2 -2
- data/ext/nokogiri/html_sax_parser_context.c +10 -8
- data/ext/nokogiri/nokogiri.c +0 -1
- data/ext/nokogiri/nokogiri.h +33 -28
- data/ext/nokogiri/xml_attr.c +7 -5
- data/ext/nokogiri/xml_attribute_decl.c +5 -2
- data/ext/nokogiri/xml_cdata.c +4 -2
- data/ext/nokogiri/xml_comment.c +4 -2
- data/ext/nokogiri/xml_document.c +93 -15
- data/ext/nokogiri/xml_document.h +0 -1
- data/ext/nokogiri/xml_document_fragment.c +4 -2
- data/ext/nokogiri/xml_dtd.c +18 -8
- data/ext/nokogiri/xml_element_content.c +2 -2
- data/ext/nokogiri/xml_entity_decl.c +15 -2
- data/ext/nokogiri/xml_entity_reference.c +4 -2
- data/ext/nokogiri/xml_io.c +1 -1
- data/ext/nokogiri/xml_namespace.c +5 -3
- data/ext/nokogiri/xml_node.c +353 -114
- data/ext/nokogiri/xml_node_set.c +35 -22
- data/ext/nokogiri/xml_node_set.h +1 -1
- data/ext/nokogiri/xml_processing_instruction.c +4 -2
- data/ext/nokogiri/xml_reader.c +119 -47
- data/ext/nokogiri/xml_relax_ng.c +21 -12
- data/ext/nokogiri/xml_sax_parser.c +6 -3
- data/ext/nokogiri/xml_sax_parser.h +13 -17
- data/ext/nokogiri/xml_sax_parser_context.c +8 -6
- data/ext/nokogiri/xml_sax_push_parser.c +7 -6
- data/ext/nokogiri/xml_schema.c +62 -13
- data/ext/nokogiri/xml_syntax_error.c +18 -12
- data/ext/nokogiri/xml_syntax_error.h +1 -1
- data/ext/nokogiri/xml_text.c +4 -2
- data/ext/nokogiri/xml_xpath_context.c +60 -23
- data/ext/nokogiri/xslt_stylesheet.c +14 -3
- data/lib/nokogiri.rb +17 -0
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/css/generated_parser.rb +72 -62
- data/lib/nokogiri/css/generated_tokenizer.rb +23 -23
- data/lib/nokogiri/css/parser.y +3 -1
- data/lib/nokogiri/css/tokenizer.rex +3 -3
- data/lib/nokogiri/css/xpath_visitor.rb +8 -3
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +3 -3
- data/lib/nokogiri/ffi/libxml.rb +16 -2
- data/lib/nokogiri/ffi/structs/common_node.rb +15 -3
- data/lib/nokogiri/ffi/structs/xml_document.rb +13 -4
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +3 -2
- data/lib/nokogiri/ffi/weak_bucket.rb +40 -0
- data/lib/nokogiri/ffi/xml/document.rb +27 -0
- data/lib/nokogiri/ffi/xml/entity_decl.rb +9 -0
- data/lib/nokogiri/ffi/xml/node.rb +142 -61
- data/lib/nokogiri/ffi/xml/node_set.rb +15 -12
- data/lib/nokogiri/ffi/xml/reader.rb +5 -0
- data/lib/nokogiri/ffi/xml/schema.rb +17 -0
- data/lib/nokogiri/ffi/xml/syntax_error.rb +4 -4
- data/lib/nokogiri/ffi/xml/xpath.rb +0 -10
- data/lib/nokogiri/ffi/xml/xpath_context.rb +22 -9
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +3 -0
- data/lib/nokogiri/html/document.rb +5 -3
- data/lib/nokogiri/html/document_fragment.rb +28 -7
- data/lib/nokogiri/version.rb +6 -2
- data/lib/nokogiri/version_warning.rb +6 -3
- data/lib/nokogiri/xml.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +35 -22
- data/lib/nokogiri/xml/document.rb +44 -12
- data/lib/nokogiri/xml/document_fragment.rb +16 -12
- data/lib/nokogiri/xml/entity_decl.rb +4 -0
- data/lib/nokogiri/xml/node.rb +152 -95
- data/lib/nokogiri/xml/node_set.rb +2 -1
- data/lib/nokogiri/xml/sax/push_parser.rb +1 -1
- data/lib/nokogiri/xml/schema.rb +1 -5
- data/lib/nokogiri/xml/syntax_error.rb +4 -0
- data/lib/nokogiri/xml/text.rb +9 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +3 -0
- data/tasks/cross_compile.rb +158 -0
- data/tasks/test.rb +0 -6
- data/test/css/test_xpath_visitor.rb +9 -0
- data/test/helper.rb +49 -11
- data/test/html/sax/test_parser.rb +11 -1
- data/test/html/test_document.rb +8 -0
- data/test/html/test_document_fragment.rb +14 -2
- data/test/html/test_element_description.rb +5 -1
- data/test/html/test_node.rb +5 -66
- data/test/test_reader.rb +28 -0
- data/test/test_xslt_transforms.rb +14 -0
- data/test/xml/test_builder.rb +43 -0
- data/test/xml/test_cdata.rb +12 -0
- data/test/xml/test_document.rb +74 -39
- data/test/xml/test_document_fragment.rb +36 -0
- data/test/xml/test_entity_decl.rb +37 -0
- data/test/xml/test_node.rb +192 -65
- data/test/xml/test_node_reparenting.rb +253 -236
- data/test/xml/test_node_set.rb +67 -0
- data/test/xml/test_text.rb +8 -0
- data/test/xml/test_xpath.rb +32 -0
- metadata +151 -79
- data/ext/nokogiri/iconv.dll +0 -0
- data/ext/nokogiri/libexslt.dll +0 -0
- data/ext/nokogiri/libxml2.dll +0 -0
- data/ext/nokogiri/libxslt.dll +0 -0
- data/ext/nokogiri/xml_xpath.c +0 -53
- data/ext/nokogiri/xml_xpath.h +0 -11
- data/ext/nokogiri/zlib1.dll +0 -0
- data/lib/nokogiri/xml/fragment_handler.rb +0 -79
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'rake/extensioncompiler'
|
2
|
+
HOST = Rake::ExtensionCompiler.mingw_host
|
3
|
+
TARGET = 'i386-pc-mingw32'
|
4
|
+
|
5
|
+
ZLIB = 'zlib-1.2.5'
|
6
|
+
ICONV = 'libiconv-1.13.1'
|
7
|
+
LIBXML = 'libxml2-2.7.7'
|
8
|
+
LIBXSLT = 'libxslt-1.1.26'
|
9
|
+
|
10
|
+
### Build zlib ###
|
11
|
+
file "tmp/cross/download/#{ZLIB}" do |t|
|
12
|
+
FileUtils.mkdir_p('tmp/cross/download')
|
13
|
+
|
14
|
+
file = ZLIB
|
15
|
+
url = "http://zlib.net/#{file}.tar.gz"
|
16
|
+
|
17
|
+
Dir.chdir('tmp/cross/download') do
|
18
|
+
sh "wget #{url} || curl -O #{url}"
|
19
|
+
sh "tar zxvf #{file}.tar.gz"
|
20
|
+
end
|
21
|
+
|
22
|
+
Dir.chdir t.name do
|
23
|
+
mk = File.read('win32/Makefile.gcc')
|
24
|
+
File.open('win32/Makefile.gcc', 'wb') do |f|
|
25
|
+
f.puts "BINARY_PATH = #{CROSS_DIR}/bin"
|
26
|
+
f.puts "LIBRARY_PATH = #{CROSS_DIR}/lib"
|
27
|
+
f.puts "INCLUDE_PATH = #{CROSS_DIR}/include"
|
28
|
+
|
29
|
+
# FIXME: need to make the cross compiler dynamic
|
30
|
+
f.puts mk.sub(/^PREFIX\s*=\s*$/, "PREFIX = #{HOST}-") #.
|
31
|
+
#sub(/^SHARED_MODE=0$/, 'SHARED_MODE=1').
|
32
|
+
#sub(/^IMPLIB\s*=.*$/, 'IMPLIB=libz.dll.a')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
file 'tmp/cross/lib/libz.a' => "tmp/cross/download/#{ZLIB}" do |t|
|
38
|
+
Dir.chdir t.prerequisites.first do
|
39
|
+
sh 'make -f win32/Makefile.gcc'
|
40
|
+
sh 'make -f win32/Makefile.gcc install'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
### End build zlib ###
|
44
|
+
|
45
|
+
### Build iconv ###
|
46
|
+
file "tmp/cross/download/#{ICONV}" do |t|
|
47
|
+
FileUtils.mkdir_p('tmp/cross/download')
|
48
|
+
|
49
|
+
file = ICONV
|
50
|
+
url = "http://ftp.gnu.org/pub/gnu/libiconv/#{file}.tar.gz"
|
51
|
+
|
52
|
+
Dir.chdir('tmp/cross/download') do
|
53
|
+
sh "wget #{url} || curl -O #{url}"
|
54
|
+
sh "tar zxvf #{file}.tar.gz"
|
55
|
+
end
|
56
|
+
|
57
|
+
Dir.chdir t.name do
|
58
|
+
# FIXME: need to make the host dynamic
|
59
|
+
sh "./configure --disable-shared --enable-static --host=#{HOST} --target=#{TARGET} --prefix=#{CROSS_DIR} CPPFLAGS='-mno-cygwin -Wall' CFLAGS='-mno-cygwin -O2 -g' CXXFLAGS='-mno-cygwin -O2 -g' LDFLAGS=-mno-cygwin"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
file 'tmp/cross/bin/iconv.exe' => "tmp/cross/download/#{ICONV}" do |t|
|
64
|
+
Dir.chdir t.prerequisites.first do
|
65
|
+
sh 'make'
|
66
|
+
sh 'make install'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
### End build iconv ###
|
70
|
+
|
71
|
+
### Build libxml2 ###
|
72
|
+
file "tmp/cross/download/#{LIBXML}" do |t|
|
73
|
+
FileUtils.mkdir_p('tmp/cross/download')
|
74
|
+
|
75
|
+
file = LIBXML
|
76
|
+
url = "ftp://ftp.xmlsoft.org/libxml2/#{file}.tar.gz"
|
77
|
+
|
78
|
+
Dir.chdir('tmp/cross/download') do
|
79
|
+
sh "wget #{url} || curl -O #{url}"
|
80
|
+
sh "tar zxvf #{file}.tar.gz"
|
81
|
+
end
|
82
|
+
|
83
|
+
Dir.chdir t.name do
|
84
|
+
# FIXME: need to make the host dynamic
|
85
|
+
sh "CFLAGS='-DIN_LIBXML' ./configure --host=#{HOST} --target=#{TARGET} --enable-static --disable-shared --prefix=#{CROSS_DIR} --with-zlib=#{CROSS_DIR} --with-iconv=#{CROSS_DIR} --without-python --without-readline"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
file 'tmp/cross/bin/xml2-config' => "tmp/cross/download/#{LIBXML}" do |t|
|
90
|
+
Dir.chdir t.prerequisites.first do
|
91
|
+
sh 'make LDFLAGS="-avoid-version"'
|
92
|
+
sh 'make install'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
### End build libxml2 ###
|
96
|
+
|
97
|
+
### Build libxslt ###
|
98
|
+
file "tmp/cross/download/#{LIBXSLT}" do |t|
|
99
|
+
FileUtils.mkdir_p('tmp/cross/download')
|
100
|
+
|
101
|
+
file = LIBXSLT
|
102
|
+
url = "ftp://ftp.xmlsoft.org/libxml2/#{file}.tar.gz"
|
103
|
+
|
104
|
+
Dir.chdir('tmp/cross/download') do
|
105
|
+
sh "wget #{url} || curl -O #{url}"
|
106
|
+
sh "tar zxvf #{file}.tar.gz"
|
107
|
+
end
|
108
|
+
|
109
|
+
Dir.chdir t.name do
|
110
|
+
# FIXME: need to make the host dynamic
|
111
|
+
sh "CFLAGS='-DIN_LIBXML' ./configure --host=#{HOST} --target=#{TARGET} --enable-static --disable-shared --prefix=#{CROSS_DIR} --with-libxml-prefix=#{CROSS_DIR} --without-python"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
file 'tmp/cross/bin/xslt-config' => "tmp/cross/download/#{LIBXSLT}" do |t|
|
116
|
+
Dir.chdir t.prerequisites.first do
|
117
|
+
sh 'make LDFLAGS="-avoid-version"'
|
118
|
+
sh 'make install'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
### End build libxslt ###
|
122
|
+
|
123
|
+
file 'lib/nokogiri/nokogiri.rb' => 'cross:libxslt' do
|
124
|
+
File.open("lib/#{HOE.name}/#{HOE.name}.rb", 'wb') do |f|
|
125
|
+
f.write <<-eoruby
|
126
|
+
require "#{HOE.name}/\#{RUBY_VERSION.sub(/\\.\\d+$/, '')}/#{HOE.name}"
|
127
|
+
eoruby
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
namespace :cross do
|
132
|
+
task :iconv => 'tmp/cross/bin/iconv.exe'
|
133
|
+
task :zlib => 'tmp/cross/lib/libz.a'
|
134
|
+
task :libxml2 => ['cross:zlib', 'cross:iconv', 'tmp/cross/bin/xml2-config']
|
135
|
+
task :libxslt => ['cross:libxml2', 'tmp/cross/bin/xslt-config']
|
136
|
+
|
137
|
+
task :copy_dlls do
|
138
|
+
Dir['tmp/cross/bin/*.dll'].each do |file|
|
139
|
+
cp file, "ext/nokogiri"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
task :file_list => 'cross:copy_dlls' do
|
144
|
+
HOE.spec.extensions = []
|
145
|
+
HOE.spec.files += Dir["lib/#{HOE.name}/#{HOE.name}.rb"]
|
146
|
+
HOE.spec.files += Dir["lib/#{HOE.name}/1.{8,9}/#{HOE.name}.so"]
|
147
|
+
HOE.spec.files += Dir["ext/nokogiri/*.dll"]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
CLOBBER.include("lib/nokogiri/nokogiri.{so,dylib,rb,bundle}")
|
152
|
+
CLOBBER.include("lib/nokogiri/1.{8,9}")
|
153
|
+
CLOBBER.include("ext/nokogiri/*.dll")
|
154
|
+
|
155
|
+
if Rake::Task.task_defined?(:cross)
|
156
|
+
Rake::Task[:cross].prerequisites << "lib/nokogiri/nokogiri.rb"
|
157
|
+
Rake::Task[:cross].prerequisites << "cross:file_list"
|
158
|
+
end
|
data/tasks/test.rb
CHANGED
@@ -8,6 +8,15 @@ module Nokogiri
|
|
8
8
|
@parser = Nokogiri::CSS::Parser.new
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_not_simple_selector
|
12
|
+
assert_xpath('//ol/*[not(self::li)]', @parser.parse('ol > *:not(li)'))
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_not_last_child
|
16
|
+
assert_xpath('//ol/*[not(position() = last())]',
|
17
|
+
@parser.parse('ol > *:not(:last-child)'))
|
18
|
+
end
|
19
|
+
|
11
20
|
def test_function_calls_allow_at_params
|
12
21
|
assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
|
13
22
|
assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
|
data/test/helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#Process.setrlimit(Process::RLIMIT_CORE, Process::RLIM_INFINITY) unless RUBY_PLATFORM =~ /(java|mswin|mingw)/i
|
2
2
|
$VERBOSE = true
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'tempfile'
|
6
6
|
require 'pp'
|
@@ -10,7 +10,7 @@ require 'nokogiri'
|
|
10
10
|
warn "#{__FILE__}:#{__LINE__}: libxml version info: #{Nokogiri::VERSION_INFO.inspect}"
|
11
11
|
|
12
12
|
module Nokogiri
|
13
|
-
class TestCase <
|
13
|
+
class TestCase < MiniTest::Spec
|
14
14
|
ASSETS_DIR = File.expand_path File.join(File.dirname(__FILE__), 'files')
|
15
15
|
XML_FILE = File.join(ASSETS_DIR, 'staff.xml')
|
16
16
|
XSLT_FILE = File.join(ASSETS_DIR, 'staff.xslt')
|
@@ -26,18 +26,15 @@ module Nokogiri
|
|
26
26
|
ADDRESS_XML_FILE = File.join(ASSETS_DIR, 'address_book.xml')
|
27
27
|
SNUGGLES_FILE = File.join(ASSETS_DIR, 'snuggles.xml')
|
28
28
|
|
29
|
-
unless RUBY_VERSION >= '1.9'
|
30
|
-
undef :default_test
|
31
|
-
end
|
32
|
-
|
33
|
-
def setup
|
34
|
-
warn "#{name}" if ENV['TESTOPTS'] == '-v'
|
35
|
-
end
|
36
|
-
|
37
29
|
def teardown
|
38
30
|
if ENV['NOKOGIRI_GC']
|
39
31
|
STDOUT.putc '!'
|
40
|
-
|
32
|
+
if RUBY_PLATFORM =~ /java/
|
33
|
+
require 'java'
|
34
|
+
java.lang.System.gc
|
35
|
+
else
|
36
|
+
GC.start
|
37
|
+
end
|
41
38
|
end
|
42
39
|
end
|
43
40
|
|
@@ -52,6 +49,47 @@ module Nokogiri
|
|
52
49
|
assert_equal(0, len % amount, message)
|
53
50
|
end
|
54
51
|
end
|
52
|
+
|
53
|
+
def util_decorate(document, decorator_module)
|
54
|
+
document.decorators(XML::Node) << decorator_module
|
55
|
+
document.decorators(XML::NodeSet) << decorator_module
|
56
|
+
document.decorate!
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Test::Unit backwards compatibility section
|
61
|
+
#
|
62
|
+
alias :assert_no_match :refute_match
|
63
|
+
alias :assert_not_nil :refute_nil
|
64
|
+
alias :assert_raise :assert_raises
|
65
|
+
alias :assert_not_equal :refute_equal
|
66
|
+
|
67
|
+
def assert_nothing_raised(*args)
|
68
|
+
self._assertions += 1
|
69
|
+
if Module === args.last
|
70
|
+
msg = nil
|
71
|
+
else
|
72
|
+
msg = args.pop
|
73
|
+
end
|
74
|
+
begin
|
75
|
+
line = __LINE__; yield
|
76
|
+
rescue Exception => e
|
77
|
+
bt = e.backtrace
|
78
|
+
as = e.instance_of?(MiniTest::Assertion)
|
79
|
+
if as
|
80
|
+
ans = /\A#{Regexp.quote(__FILE__)}:#{line}:in /o
|
81
|
+
bt.reject! {|ln| ans =~ ln}
|
82
|
+
end
|
83
|
+
if ((args.empty? && !as) ||
|
84
|
+
args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
|
85
|
+
msg = message(msg) { "Exception raised:\n<#{mu_pp(e)}>" }
|
86
|
+
raise MiniTest::Assertion, msg.call, bt
|
87
|
+
else
|
88
|
+
raise
|
89
|
+
end
|
90
|
+
end
|
91
|
+
nil
|
92
|
+
end
|
55
93
|
end
|
56
94
|
|
57
95
|
module SAX
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require "helper"
|
2
3
|
|
3
4
|
module Nokogiri
|
@@ -34,7 +35,7 @@ module Nokogiri
|
|
34
35
|
|
35
36
|
def test_parse_file_non_existant
|
36
37
|
assert_raise Errno::ENOENT do
|
37
|
-
@parser.parse_file('
|
38
|
+
@parser.parse_file('there_is_no_reasonable_way_this_file_exists')
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
@@ -50,6 +51,15 @@ module Nokogiri
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
def test_parse_force_encoding
|
55
|
+
@parser.parse_memory(<<-HTML, 'UTF-8')
|
56
|
+
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
|
57
|
+
Информация
|
58
|
+
HTML
|
59
|
+
assert_equal("Информация",
|
60
|
+
@parser.document.data.join.strip)
|
61
|
+
end
|
62
|
+
|
53
63
|
def test_parse_document
|
54
64
|
@parser.parse_memory(<<-eoxml)
|
55
65
|
<p>Paragraph 1</p>
|
data/test/html/test_document.rb
CHANGED
@@ -8,6 +8,14 @@ module Nokogiri
|
|
8
8
|
@html = Nokogiri::HTML.parse(File.read(HTML_FILE))
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_exceptions_remove_newlines
|
12
|
+
errors = @html.errors
|
13
|
+
assert errors.length > 0, 'has errors'
|
14
|
+
errors.each do |error|
|
15
|
+
assert_equal(error.to_s.chomp, error.to_s)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
def test_fragment
|
12
20
|
fragment = @html.fragment
|
13
21
|
assert_equal 0, fragment.children.length
|
@@ -9,6 +9,18 @@ module Nokogiri
|
|
9
9
|
@html = Nokogiri::HTML.parse(File.read(HTML_FILE), HTML_FILE)
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_no_contextual_parsing_on_unlinked_nodes
|
13
|
+
node = @html.css('body').first
|
14
|
+
node.unlink
|
15
|
+
assert_raises(RuntimeError) do
|
16
|
+
node.parse('<br />')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_parse_in_context
|
21
|
+
assert_equal('<br>', @html.root.parse('<br />').to_s)
|
22
|
+
end
|
23
|
+
|
12
24
|
def test_ancestors_search
|
13
25
|
html = %q{
|
14
26
|
<div>
|
@@ -91,9 +103,9 @@ module Nokogiri
|
|
91
103
|
end
|
92
104
|
|
93
105
|
def test_html_fragment_case_insensitivity
|
94
|
-
doc = "<
|
106
|
+
doc = "<Div>b</Div>"
|
95
107
|
fragment = Nokogiri::HTML::Document.new.fragment(doc)
|
96
|
-
assert_equal "<
|
108
|
+
assert_equal "<div>b</div>", fragment.to_s
|
97
109
|
end
|
98
110
|
|
99
111
|
def test_html_fragment_with_leading_whitespace
|
@@ -56,7 +56,11 @@ module Nokogiri
|
|
56
56
|
|
57
57
|
def test_subelements
|
58
58
|
sub_elements = ElementDescription['body'].sub_elements
|
59
|
-
|
59
|
+
if Nokogiri::LIBXML_VERSION == '2.7.7'
|
60
|
+
assert_equal 65, sub_elements.length
|
61
|
+
else
|
62
|
+
assert_equal 61, sub_elements.length
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
66
|
def test_default_sub_element
|
data/test/html/test_node.rb
CHANGED
@@ -17,6 +17,10 @@ module Nokogiri
|
|
17
17
|
eohtml
|
18
18
|
end
|
19
19
|
|
20
|
+
def test_to_a
|
21
|
+
assert_equal [['class', 'bar'], ['href', 'foo']],@html.at('a').to_a.sort
|
22
|
+
end
|
23
|
+
|
20
24
|
def test_attr
|
21
25
|
node = @html.at('div.baz')
|
22
26
|
assert_equal node['class'], node.attr('class')
|
@@ -64,18 +68,6 @@ module Nokogiri
|
|
64
68
|
assert_equal 'a', desc.name
|
65
69
|
end
|
66
70
|
|
67
|
-
def test_add_next_sibling_with_empty_nodeset
|
68
|
-
assert_raises(ArgumentError) {
|
69
|
-
@html.at('a').add_next_sibling(@html.at('head').children)
|
70
|
-
}
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_add_next_sibling_with_non_empty_nodeset
|
74
|
-
assert_raises(ArgumentError) {
|
75
|
-
@html.at('head').add_next_sibling(@html.at('div').children)
|
76
|
-
}
|
77
|
-
end
|
78
|
-
|
79
71
|
def test_ancestors_with_selector
|
80
72
|
assert node = @html.at('a.bar').child
|
81
73
|
assert list = node.ancestors('.baz')
|
@@ -135,35 +127,9 @@ module Nokogiri
|
|
135
127
|
assert_equal 'foo&bar&baz', node['href']
|
136
128
|
end
|
137
129
|
|
138
|
-
|
139
|
-
def test_before_will_prepend_text_nodes
|
140
|
-
assert node = @html.at('//body').children.first
|
141
|
-
node.before "some text"
|
142
|
-
assert_equal 'some text', @html.at('//body').children[0].content.strip
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_before
|
146
|
-
@html.at('//div').before('<a href="awesome">town</a>')
|
147
|
-
assert_equal 'awesome', @html.at('//div').previous['href']
|
148
|
-
end
|
149
|
-
|
150
130
|
def test_fragment_handler_does_not_regurge_on_invalid_attributes
|
151
131
|
iframe = %Q{<iframe style="width: 0%; height: 0px" src="http://someurl" allowtransparency></iframe>}
|
152
|
-
assert_nothing_raised { @html.at('div').
|
153
|
-
assert_nothing_raised { @html.at('div').after(iframe) }
|
154
|
-
assert_nothing_raised { @html.at('div').inner_html=(iframe) }
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_inner_html=
|
158
|
-
assert div = @html.at('//div')
|
159
|
-
div.inner_html = '1<span>2</span>3'
|
160
|
-
assert_equal '1', div.children[0].to_s
|
161
|
-
assert_equal 'span', div.children[1].name
|
162
|
-
assert_equal '2', div.children[1].inner_text
|
163
|
-
assert_equal '3', div.children[2].to_s
|
164
|
-
|
165
|
-
div.inner_html = 'testing'
|
166
|
-
assert_equal 'testing', div.content
|
132
|
+
assert_nothing_raised { @html.at('div').fragment(iframe) }
|
167
133
|
end
|
168
134
|
|
169
135
|
def test_fragment
|
@@ -190,33 +156,6 @@ module Nokogiri
|
|
190
156
|
assert_equal "<div>foo</div>", fragment.to_s
|
191
157
|
end
|
192
158
|
|
193
|
-
def test_after_will_append_text_nodes
|
194
|
-
assert node = @html.at('//body/div')
|
195
|
-
node.after "some text"
|
196
|
-
assert_equal 'some text', node.next.text.strip
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_after
|
200
|
-
@html.at('//div').after('<a href="awesome">town</a>')
|
201
|
-
assert_equal 'awesome', @html.at('//div').next['href']
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_replace
|
205
|
-
doc = Nokogiri::HTML(<<-eohtml)
|
206
|
-
<html>
|
207
|
-
<head></head>
|
208
|
-
<body>
|
209
|
-
<center><img src='logo.gif' /></center>
|
210
|
-
</body>
|
211
|
-
</html>
|
212
|
-
eohtml
|
213
|
-
center = doc.at("//center")
|
214
|
-
img = center.search("//img")
|
215
|
-
assert_raises ArgumentError do
|
216
|
-
center.replace img
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
159
|
def test_to_html_does_not_contain_entities
|
221
160
|
return unless defined?(NKF) # NKF is not implemented on Rubinius as of 2009-11-23
|
222
161
|
html = NKF.nkf("-e --msdos", <<-EOH)
|