nokogiri 1.6.4.1 → 1.6.5
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/CHANGELOG.ja.rdoc +15 -1
- data/CHANGELOG.rdoc +14 -0
- data/ext/nokogiri/xml_document.c +11 -3
- data/lib/nokogiri/css/xpath_visitor.rb +8 -4
- data/lib/nokogiri/decorators/slop.rb +8 -0
- data/lib/nokogiri/version.rb +1 -1
- data/test/css/test_parser.rb +8 -8
- data/test/decorators/test_slop.rb +6 -2
- data/test/helper.rb +13 -0
- data/test/html/test_document.rb +14 -6
- data/test/xml/test_c14n.rb +32 -13
- data/test/xml/test_node_attributes.rb +1 -5
- data/test/xml/test_reader_encoding.rb +1 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62d17ed461d1dbd833eef8540c2f0f64ef8b3e78
|
4
|
+
data.tar.gz: f2ca86d3bf9d3e1b94973a0d861f5b314e33193a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ef0d64f6241d6e43e9ed990a134bfb6d9dfcf2fcc37e89c084975a47535773227568370163b678f1d0b0b8fff33736c141eac8f2a6d8de9e20cb522b9134662
|
7
|
+
data.tar.gz: 380870a8946e03a97508a044daa9c7d71b5fc364c19200af463fb3a71b97c29804b3a9dd3850c1dd5756f518a0157e82fcc06c5fef998918f6d89ba3173f4214
|
data/CHANGELOG.ja.rdoc
CHANGED
@@ -1,6 +1,20 @@
|
|
1
|
+
=== 1.6.5 / 未リリース
|
2
|
+
|
3
|
+
==== 機能
|
4
|
+
|
5
|
+
* Slop#respond_to_missing? を実装 (#1176)
|
6
|
+
* Optimized the XPath query generated by an `an+b` CSS query.
|
7
|
+
|
8
|
+
|
9
|
+
==== バグ修正
|
10
|
+
|
11
|
+
* Capture non-parse errors from Document#dup in Document#errors. (#1196)
|
12
|
+
* (JRuby) Document#canonicalize parameters are now consistent with MRI. (#1189)
|
13
|
+
|
14
|
+
|
1
15
|
=== 1.6.4.1 / 2014年11月5日
|
2
16
|
|
3
|
-
====
|
17
|
+
==== バグ修正
|
4
18
|
|
5
19
|
* (MRI) 渡したCFLAGSが反映されないバグを修正 (#1188)
|
6
20
|
* CSSセレクタの :nth(n) が動かなかったのを修正 (#1187)
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 1.6.5 / unreleased
|
2
|
+
|
3
|
+
==== Features
|
4
|
+
|
5
|
+
* Implement Slop#respond_to_missing?. (#1176)
|
6
|
+
* Optimized the XPath query generated by an `an+b` CSS query.
|
7
|
+
|
8
|
+
|
9
|
+
==== Bug fixes
|
10
|
+
|
11
|
+
* Capture non-parse errors from Document#dup in Document#errors. (#1196)
|
12
|
+
* (JRuby) Document#canonicalize parameters are now consistent with MRI. (#1189)
|
13
|
+
|
14
|
+
|
1
15
|
=== 1.6.4.1 / 2014-11-05
|
2
16
|
|
3
17
|
==== Bug fixes
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -317,21 +317,29 @@ static VALUE read_memory( VALUE klass,
|
|
317
317
|
* Copy this Document. An optional depth may be passed in, but it defaults
|
318
318
|
* to a deep copy. 0 is a shallow copy, 1 is a deep copy.
|
319
319
|
*/
|
320
|
-
static VALUE
|
320
|
+
static VALUE duplicate_document(int argc, VALUE *argv, VALUE self)
|
321
321
|
{
|
322
322
|
xmlDocPtr doc, dup;
|
323
|
+
VALUE copy;
|
323
324
|
VALUE level;
|
325
|
+
VALUE error_list = rb_ary_new();
|
324
326
|
|
325
327
|
if(rb_scan_args(argc, argv, "01", &level) == 0)
|
326
328
|
level = INT2NUM((long)1);
|
327
329
|
|
328
330
|
Data_Get_Struct(self, xmlDoc, doc);
|
329
331
|
|
332
|
+
xmlResetLastError();
|
333
|
+
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
|
330
334
|
dup = xmlCopyDoc(doc, (int)NUM2INT(level));
|
335
|
+
xmlSetStructuredErrorFunc(NULL, NULL);
|
336
|
+
|
331
337
|
if(dup == NULL) return Qnil;
|
332
338
|
|
333
339
|
dup->type = doc->type;
|
334
|
-
|
340
|
+
copy = Nokogiri_wrap_xml_document(rb_obj_class(self), dup);
|
341
|
+
rb_iv_set(copy, "@errors", error_list);
|
342
|
+
return copy ;
|
335
343
|
}
|
336
344
|
|
337
345
|
/*
|
@@ -566,7 +574,7 @@ void init_xml_document()
|
|
566
574
|
rb_define_method(klass, "encoding=", set_encoding, 1);
|
567
575
|
rb_define_method(klass, "version", version, 0);
|
568
576
|
rb_define_method(klass, "canonicalize", canonicalize, -1);
|
569
|
-
rb_define_method(klass, "dup",
|
577
|
+
rb_define_method(klass, "dup", duplicate_document, -1);
|
570
578
|
rb_define_method(klass, "url", url, 0);
|
571
579
|
rb_define_method(klass, "create_entity", create_entity, -1);
|
572
580
|
rb_define_method(klass, "remove_namespaces!", remove_namespaces_bang, 0);
|
@@ -183,11 +183,15 @@ module Nokogiri
|
|
183
183
|
options[:last] ? "(last()-position()+1)" : "position()"
|
184
184
|
end
|
185
185
|
|
186
|
-
if
|
187
|
-
|
186
|
+
if b.zero?
|
187
|
+
"(#{position} mod #{a}) = 0"
|
188
188
|
else
|
189
|
-
compare =
|
190
|
-
|
189
|
+
compare = a < 0 ? "<=" : ">="
|
190
|
+
if a.abs == 1
|
191
|
+
"#{position} #{compare} #{b}"
|
192
|
+
else
|
193
|
+
"(#{position} #{compare} #{b}) and (((#{position}-#{b}) mod #{a.abs}) = 0)"
|
194
|
+
end
|
191
195
|
end
|
192
196
|
end
|
193
197
|
|
@@ -30,6 +30,14 @@ module Nokogiri
|
|
30
30
|
super if list.empty?
|
31
31
|
list.length == 1 ? list.first : list
|
32
32
|
end
|
33
|
+
|
34
|
+
def respond_to_missing? name, include_private = false
|
35
|
+
prefix = implied_xpath_context
|
36
|
+
|
37
|
+
list = xpath("#{prefix}#{name.to_s.sub(/^_/, '')}")
|
38
|
+
|
39
|
+
!list.empty?
|
40
|
+
end
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
data/lib/nokogiri/version.rb
CHANGED
data/test/css/test_parser.rb
CHANGED
@@ -193,20 +193,20 @@ module Nokogiri
|
|
193
193
|
assert_xpath '//a[(position() mod 2) = 0]', @parser.parse('a:nth-of-type(even)')
|
194
194
|
assert_xpath '//a[(position() >= 1) and (((position()-1) mod 2) = 0)]', @parser.parse('a:nth-of-type(odd)')
|
195
195
|
assert_xpath '//a[(position() >= 3) and (((position()-3) mod 4) = 0)]', @parser.parse('a:nth-of-type(4n+3)')
|
196
|
-
assert_xpath '//a[
|
197
|
-
assert_xpath '//a[
|
198
|
-
assert_xpath '//a[
|
199
|
-
assert_xpath '//a[
|
196
|
+
assert_xpath '//a[position() <= 3]', @parser.parse('a:nth-of-type(-1n+3)')
|
197
|
+
assert_xpath '//a[position() <= 3]', @parser.parse('a:nth-of-type(-n+3)')
|
198
|
+
assert_xpath '//a[position() >= 3]', @parser.parse('a:nth-of-type(1n+3)')
|
199
|
+
assert_xpath '//a[position() >= 3]', @parser.parse('a:nth-of-type(n+3)')
|
200
200
|
|
201
201
|
assert_xpath '//a[((last()-position()+1) mod 2) = 0]', @parser.parse('a:nth-last-of-type(2n)')
|
202
202
|
assert_xpath '//a[((last()-position()+1) >= 1) and ((((last()-position()+1)-1) mod 2) = 0)]', @parser.parse('a:nth-last-of-type(2n+1)')
|
203
203
|
assert_xpath '//a[((last()-position()+1) mod 2) = 0]', @parser.parse('a:nth-last-of-type(even)')
|
204
204
|
assert_xpath '//a[((last()-position()+1) >= 1) and ((((last()-position()+1)-1) mod 2) = 0)]', @parser.parse('a:nth-last-of-type(odd)')
|
205
205
|
assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 4) = 0)]', @parser.parse('a:nth-last-of-type(4n+3)')
|
206
|
-
assert_xpath '//a[(
|
207
|
-
assert_xpath '//a[(
|
208
|
-
assert_xpath '//a[(
|
209
|
-
assert_xpath '//a[(
|
206
|
+
assert_xpath '//a[(last()-position()+1) <= 3]', @parser.parse('a:nth-last-of-type(-1n+3)')
|
207
|
+
assert_xpath '//a[(last()-position()+1) <= 3]', @parser.parse('a:nth-last-of-type(-n+3)')
|
208
|
+
assert_xpath '//a[(last()-position()+1) >= 3]', @parser.parse('a:nth-last-of-type(1n+3)')
|
209
|
+
assert_xpath '//a[(last()-position()+1) >= 3]', @parser.parse('a:nth-last-of-type(n+3)')
|
210
210
|
end
|
211
211
|
|
212
212
|
def test_preceding_selector
|
@@ -9,8 +9,12 @@ module Nokogiri
|
|
9
9
|
<description>this is the foo thing</description>
|
10
10
|
</item>
|
11
11
|
eoxml
|
12
|
-
assert doc.item.title
|
13
|
-
|
12
|
+
assert doc.item.respond_to?(:title)
|
13
|
+
assert_equal 'foo', doc.item.title.text
|
14
|
+
assert doc.item.respond_to?(:_description), 'should have description'
|
15
|
+
assert 'this is the foo thing', doc.item._description.text
|
16
|
+
assert !doc.item.respond_to?(:foo)
|
17
|
+
assert_raise(NoMethodError) { doc.item.foo }
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
data/test/helper.rb
CHANGED
@@ -47,6 +47,19 @@ module Nokogiri
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
def stress_memory_while &block
|
51
|
+
# force the test to explicitly declare a skip
|
52
|
+
raise "JRuby doesn't do GC" if Nokogiri.jruby?
|
53
|
+
|
54
|
+
old_stress = GC.stress
|
55
|
+
begin
|
56
|
+
GC.stress = true
|
57
|
+
yield
|
58
|
+
ensure
|
59
|
+
GC.stress = old_stress
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
50
63
|
def assert_indent amount, doc, message = nil
|
51
64
|
nodes = []
|
52
65
|
doc.traverse do |node|
|
data/test/html/test_document.rb
CHANGED
@@ -452,8 +452,7 @@ eohtml
|
|
452
452
|
end
|
453
453
|
|
454
454
|
def test_content_size
|
455
|
-
html = Nokogiri::HTML(
|
456
|
-
</div>')
|
455
|
+
html = Nokogiri::HTML("<div>\n</div>")
|
457
456
|
assert_equal 1, html.content.size
|
458
457
|
assert_equal 1, html.content.split("").size
|
459
458
|
assert_equal "\n", html.content
|
@@ -520,7 +519,7 @@ eohtml
|
|
520
519
|
end
|
521
520
|
|
522
521
|
def test_inner_html
|
523
|
-
html = Nokogiri::HTML
|
522
|
+
html = Nokogiri::HTML <<-EOHTML
|
524
523
|
<html>
|
525
524
|
<body>
|
526
525
|
<div>
|
@@ -530,9 +529,9 @@ eohtml
|
|
530
529
|
</div>
|
531
530
|
</body>
|
532
531
|
</html>
|
533
|
-
|
534
|
-
node = html.xpath(
|
535
|
-
assert_equal(
|
532
|
+
EOHTML
|
533
|
+
node = html.xpath("//div").first
|
534
|
+
assert_equal("<p>Helloworld!</p>", node.inner_html.gsub(%r{\s}, ""))
|
536
535
|
end
|
537
536
|
|
538
537
|
def test_round_trip
|
@@ -613,6 +612,15 @@ eohtml
|
|
613
612
|
assert_equal "", Nokogiri::HTML.parse(nil).text
|
614
613
|
assert_equal "", Nokogiri::HTML.parse("").text
|
615
614
|
end
|
615
|
+
|
616
|
+
def test_capturing_nonparse_errors_during_clone
|
617
|
+
# see https://github.com/sparklemotion/nokogiri/issues/1196 for background
|
618
|
+
original = Nokogiri::HTML.parse("<div id='unique'></div><div id='unique'></div>")
|
619
|
+
original_errors = original.errors
|
620
|
+
|
621
|
+
copy = original.dup
|
622
|
+
assert_equal original_errors, copy.errors
|
623
|
+
end
|
616
624
|
end
|
617
625
|
end
|
618
626
|
end
|
data/test/xml/test_c14n.rb
CHANGED
@@ -104,46 +104,65 @@ module Nokogiri
|
|
104
104
|
def test_c14n_modes
|
105
105
|
# http://www.w3.org/TR/xml-exc-c14n/#sec-Enveloping
|
106
106
|
|
107
|
-
doc1 = Nokogiri.XML <<-
|
107
|
+
doc1 = Nokogiri.XML <<-EOXML
|
108
108
|
<n0:local xmlns:n0="http://foobar.org" xmlns:n3="ftp://example.org">
|
109
109
|
<n1:elem2 xmlns:n1="http://example.net" xml:lang="en">
|
110
110
|
<n3:stuff xmlns:n3="ftp://example.org"/>
|
111
111
|
</n1:elem2>
|
112
112
|
</n0:local>
|
113
|
-
|
114
|
-
|
113
|
+
EOXML
|
114
|
+
|
115
|
+
doc2 = Nokogiri.XML <<-EOXML
|
115
116
|
<n2:pdu xmlns:n1="http://example.com"
|
116
117
|
xmlns:n2="http://foo.example"
|
118
|
+
xmlns:n4="http://foo.example"
|
117
119
|
xml:lang="fr"
|
118
120
|
xml:space="retain">
|
119
121
|
<n1:elem2 xmlns:n1="http://example.net" xml:lang="en">
|
120
122
|
<n3:stuff xmlns:n3="ftp://example.org"/>
|
123
|
+
<n4:stuff />
|
121
124
|
</n1:elem2>
|
122
125
|
</n2:pdu>
|
123
|
-
|
126
|
+
EOXML
|
124
127
|
|
125
128
|
c14n = doc1.at_xpath('//n1:elem2', {'n1' => 'http://example.net'}).canonicalize
|
126
129
|
assert_equal '<n1:elem2 xmlns:n0="http://foobar.org" xmlns:n1="http://example.net" xmlns:n3="ftp://example.org" xml:lang="en">
|
127
130
|
<n3:stuff></n3:stuff>
|
128
131
|
</n1:elem2>', c14n
|
129
|
-
|
130
|
-
|
132
|
+
|
133
|
+
expected = '<n1:elem2 xmlns:n1="http://example.net" xmlns:n2="http://foo.example" xmlns:n4="http://foo.example" xml:lang="en" xml:space="retain">
|
131
134
|
<n3:stuff xmlns:n3="ftp://example.org"></n3:stuff>
|
132
|
-
|
135
|
+
<n4:stuff></n4:stuff>
|
136
|
+
</n1:elem2>'
|
137
|
+
c14n = doc2.at_xpath('//n1:elem2', {'n1' => 'http://example.net'}).canonicalize
|
138
|
+
assert_equal expected, c14n
|
133
139
|
|
134
|
-
|
140
|
+
expected = '<n1:elem2 xmlns:n1="http://example.net" xml:lang="en">
|
135
141
|
<n3:stuff xmlns:n3="ftp://example.org"></n3:stuff>
|
136
142
|
</n1:elem2>'
|
137
143
|
c14n = doc1.at_xpath('//n1:elem2', {'n1' => 'http://example.net'}).canonicalize(XML::XML_C14N_EXCLUSIVE_1_0)
|
138
|
-
assert_equal
|
144
|
+
assert_equal expected, c14n
|
145
|
+
|
146
|
+
expected = '<n1:elem2 xmlns:n1="http://example.net" xml:lang="en">
|
147
|
+
<n3:stuff xmlns:n3="ftp://example.org"></n3:stuff>
|
148
|
+
<n4:stuff xmlns:n4="http://foo.example"></n4:stuff>
|
149
|
+
</n1:elem2>'
|
139
150
|
c14n = doc2.at_xpath('//n1:elem2', {'n1' => 'http://example.net'}).canonicalize(XML::XML_C14N_EXCLUSIVE_1_0)
|
140
|
-
assert_equal
|
151
|
+
assert_equal expected, c14n
|
141
152
|
|
142
|
-
|
143
|
-
assert_equal '<n1:elem2 xmlns:n1="http://example.net" xmlns:n2="http://foo.example" xml:lang="en">
|
153
|
+
expected = '<n1:elem2 xmlns:n1="http://example.net" xmlns:n2="http://foo.example" xml:lang="en">
|
144
154
|
<n3:stuff xmlns:n3="ftp://example.org"></n3:stuff>
|
145
|
-
|
155
|
+
<n4:stuff xmlns:n4="http://foo.example"></n4:stuff>
|
156
|
+
</n1:elem2>'
|
157
|
+
c14n = doc2.at_xpath('//n1:elem2', {'n1' => 'http://example.net'}).canonicalize(XML::XML_C14N_EXCLUSIVE_1_0, ['n2'])
|
158
|
+
assert_equal expected, c14n
|
146
159
|
|
160
|
+
expected = '<n1:elem2 xmlns:n1="http://example.net" xmlns:n2="http://foo.example" xmlns:n4="http://foo.example" xml:lang="en">
|
161
|
+
<n3:stuff xmlns:n3="ftp://example.org"></n3:stuff>
|
162
|
+
<n4:stuff></n4:stuff>
|
163
|
+
</n1:elem2>'
|
164
|
+
c14n = doc2.at_xpath('//n1:elem2', {'n1' => 'http://example.net'}).canonicalize(XML::XML_C14N_EXCLUSIVE_1_0, ['n2', 'n4'])
|
165
|
+
assert_equal expected, c14n
|
147
166
|
end
|
148
167
|
|
149
168
|
def test_wrong_params
|
@@ -100,12 +100,8 @@ module Nokogiri
|
|
100
100
|
text = Nokogiri::XML::Text.new 'bar', document
|
101
101
|
attribute.add_child(text)
|
102
102
|
|
103
|
-
|
104
|
-
gc_previous = GC.stress
|
105
|
-
GC.stress = true
|
103
|
+
stress_memory_while do
|
106
104
|
node['visible'] = 'attr'
|
107
|
-
ensure
|
108
|
-
GC.stress = gc_previous
|
109
105
|
end
|
110
106
|
end
|
111
107
|
end
|
@@ -123,17 +123,11 @@ module Nokogiri
|
|
123
123
|
|
124
124
|
def test_value_lookup_segfault
|
125
125
|
skip("JRuby doesn't do GC.") if Nokogiri.jruby?
|
126
|
-
|
127
|
-
|
128
|
-
begin
|
129
|
-
GC.stress = true
|
130
|
-
|
126
|
+
stress_memory_while do
|
131
127
|
while node = @reader.read
|
132
128
|
nodes = node.send(:attr_nodes)
|
133
129
|
nodes.first.name if nodes.first
|
134
130
|
end
|
135
|
-
ensure
|
136
|
-
GC.stress = old_stress
|
137
131
|
end
|
138
132
|
end
|
139
133
|
end
|
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.
|
4
|
+
version: 1.6.5
|
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: 2014-11-
|
15
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: mini_portile
|