nokogiri 1.6.2.1-java → 1.6.3-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 +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.ja.rdoc +16 -0
- data/CHANGELOG.rdoc +16 -0
- data/build_all +0 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +5 -3
- data/ext/nokogiri/extconf.rb +4 -0
- data/ext/nokogiri/xml_document.c +27 -4
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml/node.rb +14 -4
- data/lib/nokogiri/xml/sax/document.rb +1 -1
- data/test/xml/test_document.rb +6 -0
- data/test/xml/test_node.rb +44 -2
- data/test/xml/test_unparented_node.rb +6 -1
- 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: 56b670c9b1574c610cb83034fee9f044ab7f2b29
|
4
|
+
data.tar.gz: b6d4586a68f531110b29f96f75317b464e53e033
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c642cad9650139cbea702fc74635d21d9c634216c7b0e09eff22fda426d5a5dd685256c5fd187fcd028253cd9a633d46d3883730c723b5fb379473b98eda390
|
7
|
+
data.tar.gz: abdf35dcd629550cf9930520b29cbb965bad38ad8abd715482f47127610fee4c8b807b70f8478da979ac65f77b95beb3cfbc4e78c551fd19d648e624ad9ec443
|
data/.travis.yml
CHANGED
@@ -2,6 +2,7 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- 1.9.3
|
4
4
|
- 2.0.0
|
5
|
+
- 2.1.2
|
5
6
|
- ruby-head
|
6
7
|
- jruby-19mode
|
7
8
|
- jruby-20mode
|
@@ -21,6 +22,8 @@ matrix:
|
|
21
22
|
jdk: openjdk7
|
22
23
|
- rvm: 2.0.0
|
23
24
|
jdk: openjdk7
|
25
|
+
- rvm: 2.1.2
|
26
|
+
jdk: openjdk7
|
24
27
|
- rvm: ruby-head
|
25
28
|
jdk: openjdk7
|
26
29
|
- rvm: rbx-19mode
|
data/CHANGELOG.ja.rdoc
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
=== 1.6.3 / 2014年7月20日
|
2
|
+
|
3
|
+
==== 機能
|
4
|
+
|
5
|
+
* Added Node#document? and Node#processing_instruction?
|
6
|
+
|
7
|
+
|
8
|
+
==== バグ修正
|
9
|
+
|
10
|
+
* [JRuby] Fix Ruby memory exhaustion vulnerability. #1087 (Thanks, @ocher)
|
11
|
+
* [MRI] Fix segfault during GC when using `libxml-ruby` and `nokogiri` together in multi-threaded environment. #895 (Thanks, @ender672!)
|
12
|
+
* Building on OSX 10.9 stock ruby 2.0.0 now works. #1101 (Thanks, @zenspider!)
|
13
|
+
* Node#parse now works again for HTML document nodes (broken in 1.6.2+).
|
14
|
+
* Processing instructions can now be added via Node#add_next_sibling.
|
15
|
+
|
16
|
+
|
1
17
|
=== 1.6.2.1 / 2014年5月13日
|
2
18
|
|
3
19
|
==== バグ修正
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
=== 1.6.3 / 2014-07-20
|
2
|
+
|
3
|
+
==== Features
|
4
|
+
|
5
|
+
* Added Node#document? and Node#processing_instruction?
|
6
|
+
|
7
|
+
|
8
|
+
==== Bug fixes
|
9
|
+
|
10
|
+
* [JRuby] Fix Ruby memory exhaustion vulnerability. #1087 (Thanks, @ocher)
|
11
|
+
* [MRI] Fix segfault during GC when using `libxml-ruby` and `nokogiri` together in multi-threaded environment. #895 (Thanks, @ender672!)
|
12
|
+
* Building on OSX 10.9 stock ruby 2.0.0 now works. #1101 (Thanks, @zenspider!)
|
13
|
+
* Node#parse now works again for HTML document nodes (broken in 1.6.2+).
|
14
|
+
* Processing instructions can now be added via Node#add_next_sibling.
|
15
|
+
|
16
|
+
|
1
17
|
=== 1.6.2.1 / 2014-05-13
|
2
18
|
|
3
19
|
==== Bug fixes
|
data/build_all
CHANGED
Binary file
|
@@ -90,9 +90,11 @@ public class NokogiriNonStrictErrorHandler extends NokogiriErrorHandler{
|
|
90
90
|
* the parsing to stop, or an error that can be ignored.
|
91
91
|
*/
|
92
92
|
private static boolean isFatal(String msg) {
|
93
|
+
String msgLowerCase = msg.toLowerCase();
|
93
94
|
return
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
msgLowerCase.contains("in prolog") ||
|
96
|
+
msgLowerCase.contains("limit") ||
|
97
|
+
msgLowerCase.contains("preceding the root element must be well-formed") ||
|
98
|
+
msgLowerCase.contains("following the root element must be well-formed");
|
97
99
|
}
|
98
100
|
}
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -311,6 +311,9 @@ when 'mingw32', /mswin/
|
|
311
311
|
$CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
|
312
312
|
when /solaris/
|
313
313
|
$CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
|
314
|
+
when /darwin/
|
315
|
+
# TODO: maybe make it stricter to only work on stock ruby? How to tell?
|
316
|
+
$CFLAGS << " -Wno-error=unused-command-line-argument-hard-error-in-future"
|
314
317
|
else
|
315
318
|
$CFLAGS << " -g -DXP_UNIX"
|
316
319
|
end
|
@@ -469,6 +472,7 @@ else
|
|
469
472
|
}
|
470
473
|
}
|
471
474
|
|
475
|
+
# Defining a macro that expands to a C string; double quotes are significant.
|
472
476
|
$CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATH=\"#{recipe.path}\"".shellescape
|
473
477
|
|
474
478
|
case libname
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -17,13 +17,29 @@ static int dealloc_node_i(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc)
|
|
17
17
|
return ST_CONTINUE;
|
18
18
|
}
|
19
19
|
|
20
|
+
static void remove_private(xmlNodePtr node)
|
21
|
+
{
|
22
|
+
xmlNodePtr child;
|
23
|
+
|
24
|
+
for (child = node->children; child; child = child->next)
|
25
|
+
remove_private(child);
|
26
|
+
|
27
|
+
if ((node->type == XML_ELEMENT_NODE ||
|
28
|
+
node->type == XML_XINCLUDE_START ||
|
29
|
+
node->type == XML_XINCLUDE_END) &&
|
30
|
+
node->properties) {
|
31
|
+
for (child = (xmlNodePtr)node->properties; child; child = child->next)
|
32
|
+
remove_private(child);
|
33
|
+
}
|
34
|
+
|
35
|
+
node->_private = NULL;
|
36
|
+
}
|
37
|
+
|
20
38
|
static void dealloc(xmlDocPtr doc)
|
21
39
|
{
|
22
|
-
xmlDeregisterNodeFunc func;
|
23
40
|
st_table *node_hash;
|
24
41
|
|
25
42
|
NOKOGIRI_DEBUG_START(doc);
|
26
|
-
func = xmlDeregisterNodeDefault(NULL);
|
27
43
|
|
28
44
|
node_hash = DOC_UNLINKED_NODE_HASH(doc);
|
29
45
|
|
@@ -31,10 +47,17 @@ static void dealloc(xmlDocPtr doc)
|
|
31
47
|
st_free_table(node_hash);
|
32
48
|
|
33
49
|
free(doc->_private);
|
34
|
-
|
50
|
+
|
51
|
+
/* When both Nokogiri and libxml-ruby are loaded, make sure that all nodes
|
52
|
+
* have their _private pointers cleared. This is to avoid libxml-ruby's
|
53
|
+
* xmlDeregisterNode callback from accessing VALUE pointers from ruby's GC
|
54
|
+
* free context, which can result in segfaults.
|
55
|
+
*/
|
56
|
+
if (xmlDeregisterNodeDefaultValue)
|
57
|
+
remove_private((xmlNodePtr)doc);
|
58
|
+
|
35
59
|
xmlFreeDoc(doc);
|
36
60
|
|
37
|
-
xmlDeregisterNodeDefault(func);
|
38
61
|
NOKOGIRI_DEBUG_END(doc);
|
39
62
|
}
|
40
63
|
|
data/lib/nokogiri/nokogiri.jar
CHANGED
Binary file
|
data/lib/nokogiri/version.rb
CHANGED
data/lib/nokogiri/xml/node.rb
CHANGED
@@ -287,7 +287,7 @@ module Nokogiri
|
|
287
287
|
def prepend_child node_or_tags
|
288
288
|
if first = children.first
|
289
289
|
# Mimic the error add_child would raise.
|
290
|
-
raise RuntimeError, "Document already has a root node" if
|
290
|
+
raise RuntimeError, "Document already has a root node" if document? && !node_or_tags.processing_instruction?
|
291
291
|
first.__send__(:add_sibling, :previous, node_or_tags)
|
292
292
|
else
|
293
293
|
add_child(node_or_tags)
|
@@ -313,7 +313,7 @@ module Nokogiri
|
|
313
313
|
#
|
314
314
|
# Also see related method +before+.
|
315
315
|
def add_previous_sibling node_or_tags
|
316
|
-
raise ArgumentError.new("A document may not have multiple root nodes.") if parent.
|
316
|
+
raise ArgumentError.new("A document may not have multiple root nodes.") if (parent && parent.document?) && !node_or_tags.processing_instruction?
|
317
317
|
|
318
318
|
add_sibling :previous, node_or_tags
|
319
319
|
end
|
@@ -326,7 +326,7 @@ module Nokogiri
|
|
326
326
|
#
|
327
327
|
# Also see related method +after+.
|
328
328
|
def add_next_sibling node_or_tags
|
329
|
-
raise ArgumentError.new("A document may not have multiple root nodes.") if parent.
|
329
|
+
raise ArgumentError.new("A document may not have multiple root nodes.") if (parent && parent.document?) && !node_or_tags.processing_instruction?
|
330
330
|
|
331
331
|
add_sibling :next, node_or_tags
|
332
332
|
end
|
@@ -513,7 +513,7 @@ module Nokogiri
|
|
513
513
|
# document as the parsing context instead. Otherwise, the in-context
|
514
514
|
# parser cannot find an element or a document node.
|
515
515
|
# Document Fragments are also not usable by the in-context parser.
|
516
|
-
if !element? && !
|
516
|
+
if !element? && !document? && (!parent || parent.fragment?)
|
517
517
|
return document.parse(string_or_io, options)
|
518
518
|
end
|
519
519
|
|
@@ -601,6 +601,16 @@ module Nokogiri
|
|
601
601
|
type == HTML_DOCUMENT_NODE
|
602
602
|
end
|
603
603
|
|
604
|
+
# Returns true if this is a Document
|
605
|
+
def document?
|
606
|
+
is_a? XML::Document
|
607
|
+
end
|
608
|
+
|
609
|
+
# Returns true if this is a ProcessingInstruction node
|
610
|
+
def processing_instruction?
|
611
|
+
type == PI_NODE
|
612
|
+
end
|
613
|
+
|
604
614
|
# Returns true if this is a Text node
|
605
615
|
def text?
|
606
616
|
type == TEXT_NODE
|
@@ -8,7 +8,7 @@ module Nokogiri
|
|
8
8
|
# The basic way a SAX style parser works is by creating a parser,
|
9
9
|
# telling the parser about the events we're interested in, then giving
|
10
10
|
# the parser some XML to process. The parser will notify you when
|
11
|
-
# it encounters events
|
11
|
+
# it encounters events you said you would like to know about.
|
12
12
|
#
|
13
13
|
# To register for events, you simply subclass Nokogiri::XML::SAX::Document,
|
14
14
|
# and implement the methods for which you would like notification.
|
data/test/xml/test_document.rb
CHANGED
@@ -625,6 +625,12 @@ module Nokogiri
|
|
625
625
|
refute_empty doc.errors
|
626
626
|
end
|
627
627
|
|
628
|
+
def test_memory_explosion_on_wrong_formatted_element_following_the_root_element
|
629
|
+
doc = Nokogiri::XML("<a/><\n")
|
630
|
+
refute_nil doc
|
631
|
+
refute_empty doc.errors
|
632
|
+
end
|
633
|
+
|
628
634
|
def test_document_has_errors
|
629
635
|
doc = Nokogiri::XML(<<-eoxml)
|
630
636
|
<foo><bar></foo>
|
data/test/xml/test_node.rb
CHANGED
@@ -136,7 +136,29 @@ module Nokogiri
|
|
136
136
|
def test_parse_with_unparented_text_context_node
|
137
137
|
doc = XML::Document.new
|
138
138
|
elem = XML::Text.new("foo", doc)
|
139
|
-
elem.parse("<bar/>")
|
139
|
+
x = elem.parse("<bar/>") # should not raise an exception
|
140
|
+
assert_equal x.first.name, "bar"
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_parse_with_unparented_html_text_context_node
|
144
|
+
doc = HTML::Document.new
|
145
|
+
elem = XML::Text.new("div", doc)
|
146
|
+
x = elem.parse("<div/>") # should not raise an exception
|
147
|
+
assert_equal x.first.name, "div"
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_parse_with_unparented_fragment_text_context_node
|
151
|
+
doc = XML::DocumentFragment.parse "<div><span>foo</span></div>"
|
152
|
+
elem = doc.at_css "span"
|
153
|
+
x = elem.parse("<span/>") # should not raise an exception
|
154
|
+
assert_equal x.first.name, "span"
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_parse_with_unparented_html_fragment_text_context_node
|
158
|
+
doc = HTML::DocumentFragment.parse "<div><span>foo</span></div>"
|
159
|
+
elem = doc.at_css "span"
|
160
|
+
x = elem.parse("<span/>") # should not raise an exception
|
161
|
+
assert_equal x.first.name, "span"
|
140
162
|
end
|
141
163
|
|
142
164
|
def test_subclass_dup
|
@@ -836,7 +858,7 @@ b"></div>
|
|
836
858
|
ne = d1.root.xpath('//a').first.dup(1)
|
837
859
|
ne.content += "& < & > \" &"
|
838
860
|
d2.root << ne
|
839
|
-
assert_match /<a>&& < & > " &<\/a>/, d2.to_s
|
861
|
+
assert_match /<a>&& < & > \" &<\/a>/, d2.to_s
|
840
862
|
end
|
841
863
|
|
842
864
|
def test_content_after_appending_text
|
@@ -1150,6 +1172,26 @@ eoxml
|
|
1150
1172
|
root << "<a>hello:with_colon</a>"
|
1151
1173
|
assert_match(/hello:with_colon/, document.to_xml)
|
1152
1174
|
end
|
1175
|
+
|
1176
|
+
def test_document_eh
|
1177
|
+
html_doc = Nokogiri::HTML "<div>foo</div>"
|
1178
|
+
xml_doc = Nokogiri::XML "<div>foo</div>"
|
1179
|
+
html_node = html_doc.at_css "div"
|
1180
|
+
xml_node = xml_doc.at_css "div"
|
1181
|
+
|
1182
|
+
assert html_doc.document?
|
1183
|
+
assert xml_doc.document?
|
1184
|
+
assert ! html_node.document?
|
1185
|
+
assert ! xml_node.document?
|
1186
|
+
end
|
1187
|
+
|
1188
|
+
def test_processing_instruction_eh
|
1189
|
+
xml_doc = Nokogiri::XML %Q{<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="foo.xsl"?>\n<?xml-stylesheet type="text/xsl" href="foo2.xsl"?>\n<root><div>foo</div></root>}
|
1190
|
+
pi_node = xml_doc.children.first
|
1191
|
+
div_node = xml_doc.at_css "div"
|
1192
|
+
assert pi_node.processing_instruction?
|
1193
|
+
assert ! div_node.processing_instruction?
|
1194
|
+
end
|
1153
1195
|
end
|
1154
1196
|
end
|
1155
1197
|
end
|
@@ -248,12 +248,17 @@ module Nokogiri
|
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
251
|
-
def
|
251
|
+
def test_add_pi_as_previous_and_next_sibling_to_root_is_ok
|
252
252
|
doc = Nokogiri::XML "<root>foo</root>"
|
253
253
|
pi = Nokogiri::XML::ProcessingInstruction.new(doc, "xml-stylesheet", %q{type="text/xsl" href="foo.xsl"})
|
254
254
|
doc.root.add_previous_sibling pi
|
255
255
|
expected_doc = %Q{<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="foo.xsl"?>\n<root>foo</root>}
|
256
256
|
assert_includes doc.to_xml, expected_doc
|
257
|
+
|
258
|
+
pi2 = Nokogiri::XML::ProcessingInstruction.new(doc, "xml-stylesheet", %q{type="text/xsl" href="foo2.xsl"})
|
259
|
+
pi.add_next_sibling pi2
|
260
|
+
expected_doc = %Q{<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="foo.xsl"?>\n<?xml-stylesheet type="text/xsl" href="foo2.xsl"?>\n<root>foo</root>}
|
261
|
+
assert_includes doc.to_xml, expected_doc
|
257
262
|
end
|
258
263
|
|
259
264
|
def test_find_by_css_with_tilde_eql
|
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.3
|
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-
|
15
|
+
date: 2014-07-20 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rdoc
|