nokogiri 1.6.4.1-java → 1.6.5-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8353cac07237f5e65173ea5c626e1a18caf5a6a2
4
- data.tar.gz: 1cf345611b8685978c8c0f8b7090d1e79d046a50
3
+ metadata.gz: 1148b14986575ffdf88e32369713e071b058ed5b
4
+ data.tar.gz: aff3cd8473522f0eece98be2bcde6bc1fdbc35d2
5
5
  SHA512:
6
- metadata.gz: b48fcad3ebed969d2117353f7e0fa474c67f6de83877fc77ffd56722798f11d66d75fe92cb8c269472f9a0ab2b14a88ef514cecc60607fd09be484a63f3ab5c8
7
- data.tar.gz: cde24f8b555391062500989f99a0e4186a175dc17e6d866f27470d29f15a6d6c3dc6e4a9b39de090b25eb4de2d92f3202a45ab5afd3a580248aa7c7c22ffe04b
6
+ metadata.gz: 60e01772a9bb88140f6fec66ea489ea19d24d515c209ddb98250183c8a7afee3fcdbd17c767ee52dc1eb81b53afc5002f8c7b36cd01329a8ad863b119a139753
7
+ data.tar.gz: b8e5157309140b6c767a34adf1f2d700fad690dd373638cb108cc6969873dc1e8b600c5f37a59b1080c3d835d1484b218c2169f2f4c952d0c1e0bc2d9ebeb61c
@@ -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
- ==== Bug fixes
17
+ ==== バグ修正
4
18
 
5
19
  * (MRI) 渡したCFLAGSが反映されないバグを修正 (#1188)
6
20
  * CSSセレクタの :nth(n) が動かなかったのを修正 (#1187)
@@ -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
@@ -586,7 +586,10 @@ public class XmlDocument extends XmlNode {
586
586
  throw context.getRuntime().newTypeError("Expected array");
587
587
  }
588
588
  if (!args[1].isNil()) {
589
- inclusive_namespace = (String)((RubyArray)args[1]).get(0);
589
+ inclusive_namespace = (String)((RubyArray)args[1])
590
+ .join(context, context.getRuntime().newString(" "))
591
+ .asString()
592
+ .asJavaString(); // OMG I wish I knew JRuby better, this is ugly
590
593
  }
591
594
  }
592
595
  if (args.length > 2) {
@@ -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 duplicate_node(int argc, VALUE *argv, VALUE self)
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
- return Nokogiri_wrap_xml_document(rb_obj_class(self), dup);
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", duplicate_node, -1);
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 (b == 0)
187
- return "(#{position} mod #{a}) = 0"
186
+ if b.zero?
187
+ "(#{position} mod #{a}) = 0"
188
188
  else
189
- compare = (a < 0) ? "<=" : ">="
190
- return "(#{position} #{compare} #{b}) and (((#{position}-#{b}) mod #{a.abs}) = 0)"
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
Binary file
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.6.4.1'
3
+ VERSION = '1.6.5'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -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[(position() <= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(-1n+3)')
197
- assert_xpath '//a[(position() <= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(-n+3)')
198
- assert_xpath '//a[(position() >= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(1n+3)')
199
- assert_xpath '//a[(position() >= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(n+3)')
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[((last()-position()+1) <= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(-1n+3)')
207
- assert_xpath '//a[((last()-position()+1) <= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(-n+3)')
208
- assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(1n+3)')
209
- assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(n+3)')
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
- assert doc.item._description, 'should have description'
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
@@ -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|
@@ -452,8 +452,7 @@ eohtml
452
452
  end
453
453
 
454
454
  def test_content_size
455
- html = Nokogiri::HTML('<div>
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(<<-eohtml)
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
- eohtml
534
- node = html.xpath('//div').first
535
- assert_equal('<p>Helloworld!</p>', node.inner_html.gsub(/\s/, ''))
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
@@ -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 <<-eoxml
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
- eoxml
114
- doc2 = Nokogiri.XML <<-eoxml
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
- eoxml
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
- c14n = doc2.at_xpath('//n1:elem2', {'n1' => 'http://example.net'}).canonicalize
130
- assert_equal '<n1:elem2 xmlns:n1="http://example.net" xmlns:n2="http://foo.example" xml:lang="en" xml:space="retain">
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
- </n1:elem2>', c14n
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
- excl_c14n = '<n1:elem2 xmlns:n1="http://example.net" xml:lang="en">
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 excl_c14n, c14n
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 excl_c14n, c14n
151
+ assert_equal expected, c14n
141
152
 
142
- c14n = doc2.at_xpath('//n1:elem2', {'n1' => 'http://example.net'}).canonicalize(XML::XML_C14N_EXCLUSIVE_1_0, ['n2'])
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
- </n1:elem2>', c14n
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
- begin
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
- old_stress = GC.stress
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.1
4
+ version: 1.6.5
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: 2014-11-07 00:00:00.000000000 Z
15
+ date: 2014-11-26 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rdoc