nokogiri 1.5.3-x86-mswin32-60 → 1.5.4.rc1-x86-mswin32-60
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 +14 -0
- data/CHANGELOG.rdoc +14 -0
- data/C_CODING_STYLE.rdoc +9 -3
- data/bin/nokogiri +3 -1
- data/ext/nokogiri/extconf.rb +3 -1
- data/ext/nokogiri/nokogiri.c +20 -0
- data/ext/nokogiri/nokogiri.h +2 -5
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_cdata.c +1 -1
- data/ext/nokogiri/xml_comment.c +1 -1
- data/ext/nokogiri/xml_document.c +2 -2
- data/ext/nokogiri/xml_document_fragment.c +1 -1
- data/ext/nokogiri/xml_entity_reference.c +1 -1
- data/ext/nokogiri/xml_node.c +15 -12
- data/ext/nokogiri/xml_processing_instruction.c +1 -1
- data/ext/nokogiri/xml_text.c +1 -1
- data/ext/nokogiri/xml_xpath_context.c +1 -1
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml/document.rb +26 -8
- data/lib/nokogiri/xml/node.rb +1 -1
- data/lib/nokogiri/xml/node_set.rb +1 -1
- data/lib/nokogiri/xml/parse_options.rb +1 -1
- data/test/xml/test_document_fragment.rb +5 -0
- data/test/xml/test_node.rb +10 -0
- data/test/xml/test_node_set.rb +5 -0
- metadata +13 -9
data/CHANGELOG.ja.rdoc
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
== 1.5.4 / unreleased
|
2
|
+
|
3
|
+
* Features
|
4
|
+
|
5
|
+
* The "nokogiri" script now has more verbose output when passed the `--rng` option. (Thanks, Dan Radez!)
|
6
|
+
* Build support on hardened Debian systems that use `-Werror=format-security`. #680.
|
7
|
+
* Better build support for systems with pkg-config. #584
|
8
|
+
|
9
|
+
* Bugfixes
|
10
|
+
|
11
|
+
* Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
|
12
|
+
* Treat '.' as xpath in at() and search(). #690
|
13
|
+
|
14
|
+
|
1
15
|
== 1.5.3 / 2012-06-01
|
2
16
|
|
3
17
|
* Features
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
== 1.5.4 / unreleased
|
2
|
+
|
3
|
+
* Features
|
4
|
+
|
5
|
+
* The "nokogiri" script now has more verbose output when passed the `--rng` option. (Thanks, Dan Radez!)
|
6
|
+
* Build support on hardened Debian systems that use `-Werror=format-security`. #680.
|
7
|
+
* Better build support for systems with pkg-config. #584
|
8
|
+
|
9
|
+
* Bugfixes
|
10
|
+
|
11
|
+
* Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
|
12
|
+
* Treat '.' as xpath in at() and search(). #690
|
13
|
+
|
14
|
+
|
1
15
|
== 1.5.3 / 2012-06-01
|
2
16
|
|
3
17
|
* Features
|
data/C_CODING_STYLE.rdoc
CHANGED
@@ -4,11 +4,17 @@ Please don't propose commits that only change whitespace. However, if your
|
|
4
4
|
commit touches a function or section that is not using MRI Ruby conventions,
|
5
5
|
feel free to update whitespace in the surrounding code.
|
6
6
|
|
7
|
+
|
7
8
|
= WHITESPACE:
|
8
9
|
|
9
|
-
indent level: 2
|
10
|
-
indent type: Always spaces
|
11
|
-
|
10
|
+
* indent level: 2
|
11
|
+
* indent type: Always spaces
|
12
|
+
* line Breaks: LF
|
13
|
+
|
14
|
+
This style can be automatically applied by running:
|
15
|
+
|
16
|
+
astyle --indent=spaces=2 --style=1tbs --keep-one-line-blocks $(ack -f --type=cpp --type=cc ext/nokogiri)
|
17
|
+
|
12
18
|
|
13
19
|
= FUNCTION DECLARATION:
|
14
20
|
|
data/bin/nokogiri
CHANGED
data/ext/nokogiri/extconf.rb
CHANGED
@@ -99,7 +99,9 @@ def asplode(lib)
|
|
99
99
|
abort "-----\n#{lib} is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.\n-----"
|
100
100
|
end
|
101
101
|
|
102
|
-
pkg_config('libxslt')
|
102
|
+
pkg_config('libxslt')
|
103
|
+
pkg_config('libxml-2.0')
|
104
|
+
pkg_config('libiconv')
|
103
105
|
|
104
106
|
asplode "libxml2" unless find_header('libxml/parser.h')
|
105
107
|
asplode "libxslt" unless find_header('libxslt/xslt.h')
|
data/ext/nokogiri/nokogiri.c
CHANGED
@@ -43,6 +43,26 @@ void vasprintf_free (void *p)
|
|
43
43
|
#endif
|
44
44
|
#endif
|
45
45
|
|
46
|
+
void nokogiri_root_node(xmlNodePtr node)
|
47
|
+
{
|
48
|
+
xmlDocPtr doc;
|
49
|
+
nokogiriTuplePtr tuple;
|
50
|
+
|
51
|
+
doc = node->doc;
|
52
|
+
if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
|
53
|
+
tuple = (nokogiriTuplePtr)doc->_private;
|
54
|
+
st_insert(tuple->unlinkedNodes, (st_data_t)node, (st_data_t)node);
|
55
|
+
}
|
56
|
+
|
57
|
+
void nokogiri_root_nsdef(xmlNsPtr ns, xmlDocPtr doc)
|
58
|
+
{
|
59
|
+
nokogiriTuplePtr tuple;
|
60
|
+
|
61
|
+
if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
|
62
|
+
tuple = (nokogiriTuplePtr)doc->_private;
|
63
|
+
st_insert(tuple->unlinkedNodes, (st_data_t)ns, (st_data_t)ns);
|
64
|
+
}
|
65
|
+
|
46
66
|
void Init_nokogiri()
|
47
67
|
{
|
48
68
|
#ifndef __MACRUBY__
|
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -120,11 +120,8 @@ extern VALUE mNokogiriHtml ;
|
|
120
120
|
extern VALUE mNokogiriHtmlSax ;
|
121
121
|
extern VALUE mNokogiriXslt ;
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
#define NOKOGIRI_ROOT_NSDEF(_nsDef, _doc) \
|
127
|
-
st_insert(((nokogiriTuplePtr)(_doc)->_private)->unlinkedNodes, (st_data_t)(_nsDef), (st_data_t)(_nsDef))
|
123
|
+
void nokogiri_root_node(xmlNodePtr);
|
124
|
+
void nokogiri_root_nsdef(xmlNsPtr, xmlDocPtr);
|
128
125
|
|
129
126
|
#ifdef DEBUG
|
130
127
|
|
data/ext/nokogiri/xml_attr.c
CHANGED
data/ext/nokogiri/xml_cdata.c
CHANGED
@@ -25,7 +25,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
25
25
|
NIL_P(content) ? 0 : (int)RSTRING_LEN(content)
|
26
26
|
);
|
27
27
|
|
28
|
-
|
28
|
+
nokogiri_root_node(node);
|
29
29
|
|
30
30
|
rb_node = Nokogiri_wrap_xml_node(klass, node);
|
31
31
|
rb_obj_call_init(rb_node, argc, argv);
|
data/ext/nokogiri/xml_comment.c
CHANGED
data/ext/nokogiri/xml_document.c
CHANGED
@@ -102,7 +102,7 @@ static VALUE set_root(VALUE self, VALUE root)
|
|
102
102
|
|
103
103
|
if(old_root) {
|
104
104
|
xmlUnlinkNode(old_root);
|
105
|
-
|
105
|
+
nokogiri_root_node(old_root);
|
106
106
|
}
|
107
107
|
|
108
108
|
return root;
|
@@ -121,7 +121,7 @@ static VALUE set_root(VALUE self, VALUE root)
|
|
121
121
|
}
|
122
122
|
|
123
123
|
xmlDocSetRootElement(doc, new_root);
|
124
|
-
if(old_root)
|
124
|
+
if(old_root) nokogiri_root_node(old_root);
|
125
125
|
return root;
|
126
126
|
}
|
127
127
|
|
data/ext/nokogiri/xml_node.c
CHANGED
@@ -51,7 +51,7 @@ static void relink_namespace(xmlNodePtr reparented)
|
|
51
51
|
} else {
|
52
52
|
reparented->nsDef = curr->next;
|
53
53
|
}
|
54
|
-
|
54
|
+
nokogiri_root_nsdef(curr, reparented->doc);
|
55
55
|
} else {
|
56
56
|
prev = curr;
|
57
57
|
}
|
@@ -132,7 +132,7 @@ static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_rep
|
|
132
132
|
* uninteresting libxml2 implementation detail). as a result, we cannot
|
133
133
|
* reparent the actual reparentee, so we reparent a duplicate.
|
134
134
|
*/
|
135
|
-
|
135
|
+
nokogiri_root_node(reparentee);
|
136
136
|
if (!(reparentee = xmlDocCopyNode(reparentee, pivot->doc, 1))) {
|
137
137
|
rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
|
138
138
|
}
|
@@ -162,7 +162,7 @@ static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_rep
|
|
162
162
|
new_next_text = xmlDocCopyNode(next_text, pivot->doc, 1) ;
|
163
163
|
|
164
164
|
xmlUnlinkNode(next_text);
|
165
|
-
|
165
|
+
nokogiri_root_node(next_text);
|
166
166
|
|
167
167
|
xmlAddNextSibling(pivot, new_next_text);
|
168
168
|
}
|
@@ -375,7 +375,7 @@ static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
|
|
375
375
|
dup = xmlDocCopyNode(node, node->doc, (int)NUM2INT(level));
|
376
376
|
if(dup == NULL) return Qnil;
|
377
377
|
|
378
|
-
|
378
|
+
nokogiri_root_node(dup);
|
379
379
|
|
380
380
|
return Nokogiri_wrap_xml_node(rb_obj_class(self), dup);
|
381
381
|
}
|
@@ -391,7 +391,7 @@ static VALUE unlink_node(VALUE self)
|
|
391
391
|
xmlNodePtr node;
|
392
392
|
Data_Get_Struct(self, xmlNode, node);
|
393
393
|
xmlUnlinkNode(node);
|
394
|
-
|
394
|
+
nokogiri_root_node(node);
|
395
395
|
return self;
|
396
396
|
}
|
397
397
|
|
@@ -489,7 +489,7 @@ static VALUE replace(VALUE self, VALUE new_node)
|
|
489
489
|
|
490
490
|
xmlNodePtr pivot;
|
491
491
|
Data_Get_Struct(self, xmlNode, pivot);
|
492
|
-
|
492
|
+
nokogiri_root_node(pivot);
|
493
493
|
|
494
494
|
return reparent;
|
495
495
|
}
|
@@ -681,7 +681,7 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
|
|
681
681
|
if (prop && prop->children) {
|
682
682
|
for (cur = prop->children; cur; cur = cur->next) {
|
683
683
|
if (cur->_private) {
|
684
|
-
|
684
|
+
nokogiri_root_node(cur);
|
685
685
|
xmlUnlinkNode(cur);
|
686
686
|
}
|
687
687
|
}
|
@@ -901,7 +901,7 @@ static VALUE set_content(VALUE self, VALUE content)
|
|
901
901
|
while (NULL != child) {
|
902
902
|
next = child->next ;
|
903
903
|
xmlUnlinkNode(child) ;
|
904
|
-
|
904
|
+
nokogiri_root_node(child);
|
905
905
|
child = next ;
|
906
906
|
}
|
907
907
|
|
@@ -1133,7 +1133,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
1133
1133
|
|
1134
1134
|
node = xmlNewNode(NULL, (xmlChar *)StringValuePtr(name));
|
1135
1135
|
node->doc = doc->doc;
|
1136
|
-
|
1136
|
+
nokogiri_root_node(node);
|
1137
1137
|
|
1138
1138
|
rb_node = Nokogiri_wrap_xml_node(
|
1139
1139
|
klass == cNokogiriXmlNode ? (VALUE)NULL : klass,
|
@@ -1320,6 +1320,7 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
|
|
1320
1320
|
VALUE node_cache = Qnil ;
|
1321
1321
|
VALUE rb_node = Qnil ;
|
1322
1322
|
nokogiriTuplePtr node_has_a_document;
|
1323
|
+
xmlDocPtr doc;
|
1323
1324
|
void (*mark_method)(xmlNodePtr) = NULL ;
|
1324
1325
|
|
1325
1326
|
assert(node);
|
@@ -1330,7 +1331,9 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
|
|
1330
1331
|
/* It's OK if the node doesn't have a fully-realized document (as in XML::Reader). */
|
1331
1332
|
/* see https://github.com/tenderlove/nokogiri/issues/95 */
|
1332
1333
|
/* and https://github.com/tenderlove/nokogiri/issues/439 */
|
1333
|
-
|
1334
|
+
doc = node->doc;
|
1335
|
+
if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
|
1336
|
+
node_has_a_document = DOC_RUBY_OBJECT_TEST(doc);
|
1334
1337
|
|
1335
1338
|
if(node->_private && node_has_a_document)
|
1336
1339
|
return (VALUE)node->_private;
|
@@ -1385,8 +1388,8 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
|
|
1385
1388
|
node->_private = (void *)rb_node;
|
1386
1389
|
|
1387
1390
|
if (node_has_a_document) {
|
1388
|
-
document = DOC_RUBY_OBJECT(
|
1389
|
-
node_cache = DOC_NODE_CACHE(
|
1391
|
+
document = DOC_RUBY_OBJECT(doc);
|
1392
|
+
node_cache = DOC_NODE_CACHE(doc);
|
1390
1393
|
rb_ary_push(node_cache, rb_node);
|
1391
1394
|
rb_funcall(document, decorate, 1, rb_node);
|
1392
1395
|
}
|
data/ext/nokogiri/xml_text.c
CHANGED
@@ -22,7 +22,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
22
22
|
node = xmlNewText((xmlChar *)StringValuePtr(string));
|
23
23
|
node->doc = doc->doc;
|
24
24
|
|
25
|
-
|
25
|
+
nokogiri_root_node(node);
|
26
26
|
|
27
27
|
rb_node = Nokogiri_wrap_xml_node(klass, node) ;
|
28
28
|
rb_obj_call_init(rb_node, argc, argv);
|
Binary file
|
Binary file
|
data/lib/nokogiri/version.rb
CHANGED
@@ -3,10 +3,11 @@ module Nokogiri
|
|
3
3
|
##
|
4
4
|
# Nokogiri::XML::Document is the main entry point for dealing with
|
5
5
|
# XML documents. The Document is created by parsing an XML document.
|
6
|
-
# See Nokogiri.
|
6
|
+
# See Nokogiri::XML::Document.parse() for more information on parsing.
|
7
7
|
#
|
8
8
|
# For searching a Document, see Nokogiri::XML::Node#css and
|
9
9
|
# Nokogiri::XML::Node#xpath
|
10
|
+
#
|
10
11
|
class Document < Nokogiri::XML::Node
|
11
12
|
# I'm ignoring unicode characters here.
|
12
13
|
# See http://www.w3.org/TR/REC-xml-names/#ns-decl for more details.
|
@@ -15,13 +16,30 @@ module Nokogiri
|
|
15
16
|
NCNAME_RE = /^xmlns(:[#{NCNAME_START_CHAR}][#{NCNAME_CHAR}]*)?$/
|
16
17
|
|
17
18
|
##
|
18
|
-
# Parse an XML file.
|
19
|
-
#
|
20
|
-
# +
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
19
|
+
# Parse an XML file.
|
20
|
+
#
|
21
|
+
# +string_or_io+ may be a String, or any object that responds to
|
22
|
+
# _read_ and _close_ such as an IO, or StringIO.
|
23
|
+
#
|
24
|
+
# +url+ (optional) is the URI where this document is located.
|
25
|
+
#
|
26
|
+
# +encoding+ (optional) is the encoding that should be used when processing
|
27
|
+
# the document.
|
28
|
+
#
|
29
|
+
# +options+ (optional) is a configuration object that sets options during
|
30
|
+
# parsing, such as Nokogiri::XML::ParseOptions::RECOVER. See the
|
31
|
+
# Nokogiri::XML::ParseOptions for more information.
|
32
|
+
#
|
33
|
+
# +block+ (optional) is passed a configuration object on which
|
34
|
+
# parse options may be set.
|
35
|
+
#
|
36
|
+
# When parsing untrusted documents, it's recommended that the
|
37
|
+
# +nonet+ option be used, as shown in this example code:
|
38
|
+
#
|
39
|
+
# Nokogiri::XML::Document.parse(xml_string) { |config| config.nonet }
|
40
|
+
#
|
41
|
+
# Nokogiri.XML() is a convenience method which will call this method.
|
42
|
+
#
|
25
43
|
def self.parse string_or_io, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML, &block
|
26
44
|
options = Nokogiri::XML::ParseOptions.new(options) if Fixnum === options
|
27
45
|
# Give the options to the user
|
data/lib/nokogiri/xml/node.rb
CHANGED
@@ -27,7 +27,7 @@ module Nokogiri
|
|
27
27
|
SAX1 = 1 << 9
|
28
28
|
# Implement XInclude substitution
|
29
29
|
XINCLUDE = 1 << 10
|
30
|
-
# Forbid network access
|
30
|
+
# Forbid network access. Recommended for dealing with untrusted documents.
|
31
31
|
NONET = 1 << 11
|
32
32
|
# Do not reuse the context dictionary
|
33
33
|
NODICT = 1 << 12
|
@@ -176,6 +176,11 @@ module Nokogiri
|
|
176
176
|
assert fragment.children.respond_to?(:awesome!), fragment.children.class
|
177
177
|
end
|
178
178
|
|
179
|
+
def test_add_node_to_doc_fragment_segfault
|
180
|
+
frag = Nokogiri::XML::DocumentFragment.new(@xml, '<p>hello world</p>')
|
181
|
+
Nokogiri::XML::Comment.new(frag,'moo')
|
182
|
+
end
|
183
|
+
|
179
184
|
if Nokogiri.uses_libxml?
|
180
185
|
def test_for_libxml_in_context_fragment_parsing_bug_workaround
|
181
186
|
10.times do
|
data/test/xml/test_node.rb
CHANGED
@@ -454,6 +454,11 @@ module Nokogiri
|
|
454
454
|
assert_equal node, @xml.xpath('//address').first
|
455
455
|
end
|
456
456
|
|
457
|
+
def test_at_self
|
458
|
+
node = @xml.at('address')
|
459
|
+
assert_equal node, node.at('.')
|
460
|
+
end
|
461
|
+
|
457
462
|
def test_at_xpath
|
458
463
|
node = @xml.at_xpath('//address')
|
459
464
|
nodes = @xml.xpath('//address')
|
@@ -740,6 +745,11 @@ module Nokogiri
|
|
740
745
|
assert_equal node.parent, parent_node
|
741
746
|
end
|
742
747
|
|
748
|
+
def test_search_self
|
749
|
+
node = @xml.at('//employee')
|
750
|
+
assert_equal node.search('.').to_a, [node]
|
751
|
+
end
|
752
|
+
|
743
753
|
def test_search_by_symbol
|
744
754
|
assert set = @xml.search(:employee)
|
745
755
|
assert 5, set.length
|
data/test/xml/test_node_set.rb
CHANGED
@@ -146,6 +146,11 @@ module Nokogiri
|
|
146
146
|
assert_equal @xml.xpath('//employee'), custom_employees
|
147
147
|
end
|
148
148
|
|
149
|
+
def test_search_self
|
150
|
+
set = @xml.xpath('//staff')
|
151
|
+
assert_equal set.to_a, set.search('.').to_a
|
152
|
+
end
|
153
|
+
|
149
154
|
def test_search_with_custom_object
|
150
155
|
set = @xml.xpath('//staff')
|
151
156
|
custom_employees = set.search('//*[awesome(.)]', Class.new {
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokogiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 1939456333
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
|
9
|
+
- 4
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 1.5.4.rc1
|
11
13
|
platform: x86-mswin32-60
|
12
14
|
authors:
|
13
15
|
- Aaron Patterson
|
@@ -17,7 +19,7 @@ autorequire:
|
|
17
19
|
bindir: bin
|
18
20
|
cert_chain: []
|
19
21
|
|
20
|
-
date: 2012-06-
|
22
|
+
date: 2012-06-07 00:00:00 Z
|
21
23
|
dependencies:
|
22
24
|
- !ruby/object:Gem::Dependency
|
23
25
|
name: hoe-bundler
|
@@ -506,12 +508,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
506
508
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
507
509
|
none: false
|
508
510
|
requirements:
|
509
|
-
- - "
|
511
|
+
- - ">"
|
510
512
|
- !ruby/object:Gem::Version
|
511
|
-
hash:
|
513
|
+
hash: 25
|
512
514
|
segments:
|
513
|
-
-
|
514
|
-
|
515
|
+
- 1
|
516
|
+
- 3
|
517
|
+
- 1
|
518
|
+
version: 1.3.1
|
515
519
|
requirements: []
|
516
520
|
|
517
521
|
rubyforge_project: nokogiri
|