nokogiri 1.5.5.rc2-java → 1.5.5.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.

@@ -23,7 +23,7 @@ module Nokogiri
23
23
  # Save builder created document
24
24
  AS_BUILDER = 128
25
25
  # the default for XML documents
26
- DEFAULT_XML = AS_XML # https://github.com/tenderlove/nokogiri/issues/#issue/415
26
+ DEFAULT_XML = AS_XML # https://github.com/sparklemotion/nokogiri/issues/#issue/415
27
27
  # the default for HTML document
28
28
  DEFAULT_HTML = NO_DECLARATION | NO_EMPTY_TAGS | AS_HTML
29
29
  else
@@ -89,11 +89,11 @@ module Nokogiri
89
89
  require 'open-uri'
90
90
  begin
91
91
  html = open('http://google.com').read
92
- doc = Nokogiri::HTML html ,"/foo/", nil
93
- refute_empty doc.to_s, "Document should not be empty"
94
92
  rescue
95
93
  skip("This test needs the internet. Skips if no internet available.")
96
94
  end
95
+ doc = Nokogiri::HTML html ,"http:/foobar.foobar/"
96
+ refute_empty doc.to_s, "Document should not be empty"
97
97
  end
98
98
 
99
99
  ###
@@ -268,7 +268,7 @@ module Nokogiri
268
268
  assert_equal 44, @xml.validate.length
269
269
  else
270
270
  xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE) {|cfg| cfg.dtdvalid}
271
- assert_equal 37, xml.validate.length
271
+ assert_equal 40, xml.validate.length
272
272
  end
273
273
  end
274
274
 
@@ -14,12 +14,8 @@ module Nokogiri
14
14
  end
15
15
 
16
16
  def test_external_id
17
- if Nokogiri.uses_libxml?
18
- xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar"><foo />')
19
- else
20
- xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar" ""><foo />')
21
- end
22
- assert dtd = xml.internal_subset
17
+ xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar" ""><foo />')
18
+ assert dtd = xml.internal_subset, 'no internal subset'
23
19
  assert_equal 'bar', dtd.external_id
24
20
  end
25
21
 
@@ -74,7 +70,7 @@ module Nokogiri
74
70
  else
75
71
  xml = Nokogiri::XML(File.open(XML_FILE)) {|cfg| cfg.dtdvalid}
76
72
  list = xml.internal_subset.validate xml
77
- assert_equal 37, list.length
73
+ assert_equal 40, list.length
78
74
  end
79
75
  end
80
76
 
@@ -17,5 +17,219 @@ module Nokogiri
17
17
  100.times { EntityReference.new(@xml, 'foo') }
18
18
  end
19
19
  end
20
+
21
+ module Common
22
+ PATH = 'test/files/test_document_url/'
23
+
24
+ attr_accessor :path, :parser
25
+
26
+ def xml_document
27
+ File.join path, 'document.xml'
28
+ end
29
+
30
+ def self.included base
31
+ def base.test_relative_and_absolute_path method_name, &block
32
+ test_relative_path method_name, &block
33
+ test_absolute_path method_name, &block
34
+ end
35
+
36
+ def base.test_absolute_path method_name, &block
37
+ define_method "#{method_name}_with_absolute_path" do
38
+ self.path = "#{File.expand_path PATH}/"
39
+ instance_eval(&block)
40
+ end
41
+ end
42
+
43
+ def base.test_relative_path method_name, &block
44
+ define_method method_name do
45
+ self.path = PATH
46
+ instance_eval(&block)
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ class TestDOMEntityReference < Nokogiri::TestCase
53
+ include Common
54
+
55
+ def setup
56
+ super
57
+ @parser = Nokogiri::XML::Document
58
+ end
59
+
60
+ test_relative_and_absolute_path :test_dom_entity_reference_with_dtdloda do
61
+ # Make sure that we can parse entity references and include them in the document
62
+ html = File.read xml_document
63
+ doc = @parser.parse html, path do |cfg|
64
+ cfg.default_xml
65
+ cfg.dtdload
66
+ cfg.noent
67
+ end
68
+ assert_equal [], doc.errors
69
+ assert_equal "foobar", doc.xpath('//blah').text
70
+ end
71
+
72
+ test_relative_and_absolute_path :test_dom_entity_reference_with_dtdvalid do
73
+ # Make sure that we can parse entity references and include them in the document
74
+ html = File.read xml_document
75
+ doc = @parser.parse html, path do |cfg|
76
+ cfg.default_xml
77
+ cfg.dtdvalid
78
+ cfg.noent
79
+ end
80
+ assert_equal [], doc.errors
81
+ assert_equal "foobar", doc.xpath('//blah').text
82
+ end
83
+
84
+ test_absolute_path :test_dom_dtd_loading_with_absolute_path do
85
+ # Make sure that we can parse entity references and include them in the document
86
+ html = %Q[<?xml version="1.0" encoding="UTF-8" ?>
87
+ <!DOCTYPE document SYSTEM "#{path}/document.dtd">
88
+ <document>
89
+ <body>&bar;</body>
90
+ </document>
91
+ ]
92
+ doc = @parser.parse html, xml_document do |cfg|
93
+ cfg.default_xml
94
+ cfg.dtdvalid
95
+ cfg.noent
96
+ end
97
+ assert_equal [], doc.errors
98
+ assert_equal "foobar", doc.xpath('//blah').text
99
+ end
100
+
101
+ test_relative_and_absolute_path :test_dom_entity_reference_with_io do
102
+ # Make sure that we can parse entity references and include them in the document
103
+ html = File.open xml_document
104
+ doc = @parser.parse html, nil do |cfg|
105
+ cfg.default_xml
106
+ cfg.dtdload
107
+ cfg.noent
108
+ end
109
+ assert_equal [], doc.errors
110
+ assert_equal "foobar", doc.xpath('//blah').text
111
+ end
112
+
113
+ test_relative_and_absolute_path :test_dom_entity_reference_without_noent do
114
+ # Make sure that we don't include entity references unless NOENT is set to true
115
+ html = File.read xml_document
116
+ doc = @parser.parse html, path do |cfg|
117
+ cfg.default_xml
118
+ cfg.dtdload
119
+ end
120
+ assert_equal [], doc.errors
121
+ assert_kind_of Nokogiri::XML::EntityReference, doc.xpath('//body').first.children.first
122
+ end
123
+
124
+ test_relative_and_absolute_path :test_dom_entity_reference_without_dtdload do
125
+ # Make sure that we don't include entity references unless NOENT is set to true
126
+ html = File.read xml_document
127
+ doc = @parser.parse html, path do |cfg|
128
+ cfg.default_xml
129
+ end
130
+ assert_kind_of Nokogiri::XML::EntityReference, doc.xpath('//body').first.children.first
131
+ if Nokogiri.uses_libxml?
132
+ assert_equal ["Entity 'bar' not defined"], doc.errors.map(&:to_s)
133
+ end
134
+ end
135
+
136
+ test_relative_and_absolute_path :test_document_dtd_loading_with_nonet do
137
+ # Make sure that we don't include remote entities unless NOENT is set to true
138
+ html = %Q[<?xml version="1.0" encoding="UTF-8" ?>
139
+ <!DOCTYPE document SYSTEM "http://foo.bar.com/">
140
+ <document>
141
+ <body>&bar;</body>
142
+ </document>
143
+ ]
144
+ doc = @parser.parse html, path do |cfg|
145
+ cfg.default_xml
146
+ cfg.dtdload
147
+ end
148
+ assert_kind_of Nokogiri::XML::EntityReference, doc.xpath('//body').first.children.first
149
+ if Nokogiri.uses_libxml?
150
+ assert_equal ["Attempt to load network entity http://foo.bar.com/", "Entity 'bar' not defined"], doc.errors.map(&:to_s)
151
+ else
152
+ assert_equal ["Attempt to load network entity http://foo.bar.com/"], doc.errors.map(&:to_s)
153
+ end
154
+ end
155
+ # TODO: can we retreive a resource pointing to localhost when NONET is set to true ?
156
+ end
157
+
158
+ class TestSaxEntityReference < Nokogiri::SAX::TestCase
159
+ include Common
160
+
161
+ def setup
162
+ super
163
+ @parser = XML::SAX::Parser.new(Doc.new) do |ctx|
164
+ ctx.replace_entities = true
165
+ end
166
+ end
167
+
168
+ test_relative_and_absolute_path :test_sax_entity_reference do
169
+ # Make sure that we can parse entity references and include them in the document
170
+ html = File.read xml_document
171
+ @parser.parse html
172
+ refute_nil @parser.document.errors
173
+ assert_equal ["Entity 'bar' not defined"], @parser.document.errors.map(&:to_s).map(&:strip)
174
+ end
175
+
176
+ test_relative_and_absolute_path :test_more_sax_entity_reference do
177
+ # Make sure that we don't include entity references unless NOENT is set to true
178
+ html = %Q[<?xml version="1.0" encoding="UTF-8" ?>
179
+ <!DOCTYPE document SYSTEM "http://foo.bar.com/">
180
+ <document>
181
+ <body>&bar;</body>
182
+ </document>
183
+ ]
184
+ @parser.parse html
185
+ refute_nil @parser.document.errors
186
+ assert_equal ["Entity 'bar' not defined"], @parser.document.errors.map(&:to_s).map(&:strip)
187
+ end
188
+ end
189
+
190
+ class TestReaderEntityReference < Nokogiri::TestCase
191
+ include Common
192
+
193
+ def setup
194
+ super
195
+ end
196
+
197
+ test_relative_and_absolute_path :test_reader_entity_reference do
198
+ # Make sure that we can parse entity references and include them in the document
199
+ html = File.read xml_document
200
+ reader = Nokogiri::XML::Reader html, path do |cfg|
201
+ cfg.default_xml
202
+ cfg.dtdload
203
+ cfg.noent
204
+ end
205
+ nodes = []
206
+ reader.each { |n| nodes << n.value }
207
+ assert_equal ['foobar'], nodes.compact.map(&:strip).reject(&:empty?)
208
+ end
209
+
210
+ test_relative_and_absolute_path :test_reader_entity_reference_without_noent do
211
+ # Make sure that we can parse entity references and include them in the document
212
+ html = File.read xml_document
213
+ reader = Nokogiri::XML::Reader html, path do |cfg|
214
+ cfg.default_xml
215
+ cfg.dtdload
216
+ end
217
+ nodes = []
218
+ reader.each { |n| nodes << n.value }
219
+ assert_equal [], nodes.compact.map(&:strip).reject(&:empty?)
220
+ end
221
+
222
+ test_relative_and_absolute_path :test_reader_entity_reference_without_dtdload do
223
+ # Make sure that we can parse entity references and include them in the document
224
+ html = File.read xml_document
225
+ assert_raises(Nokogiri::XML::SyntaxError) do
226
+ reader = Nokogiri::XML::Reader html, path do |cfg|
227
+ cfg.default_xml
228
+ end
229
+ nodes = []
230
+ reader.each { |n| nodes << n.value }
231
+ end
232
+ end
233
+ end
20
234
  end
21
235
  end
@@ -329,7 +329,7 @@ module Nokogiri
329
329
 
330
330
  describe "unlinking a node and then reparenting it" do
331
331
  it "not blow up" do
332
- # see http://github.com/tenderlove/nokogiri/issues#issue/22
332
+ # see http://github.com/sparklemotion/nokogiri/issues#issue/22
333
333
  10.times do
334
334
  begin
335
335
  doc = Nokogiri::XML <<-EOHTML
@@ -217,7 +217,7 @@ module Nokogiri
217
217
  end
218
218
 
219
219
  def test_custom_xpath_handler_with_args_under_gc_pressure
220
- # see http://github.com/tenderlove/nokogiri/issues/#issue/345
220
+ # see http://github.com/sparklemotion/nokogiri/issues/#issue/345
221
221
  tool_inspector = Class.new do
222
222
  def name_equals(nodeset, name, *args)
223
223
  nodeset.all? do |node|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.5.5.rc2
5
+ version: 1.5.5.rc3
6
6
  platform: java
7
7
  authors:
8
8
  - Aaron Patterson
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2012-06-14 00:00:00 Z
16
+ date: 2012-06-22 00:00:00 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: hoe-bundler