nokogiri 1.11.3-x86-mingw32 → 1.12.0.rc1-x86-mingw32
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/LICENSE-DEPENDENCIES.md +243 -22
- data/LICENSE.md +1 -1
- data/README.md +6 -5
- data/dependencies.yml +12 -12
- data/ext/nokogiri/depend +35 -34
- data/ext/nokogiri/extconf.rb +181 -103
- data/ext/nokogiri/gumbo.c +611 -0
- data/ext/nokogiri/{html_document.c → html4_document.c} +8 -8
- data/ext/nokogiri/{html_element_description.c → html4_element_description.c} +20 -18
- data/ext/nokogiri/{html_entity_lookup.c → html4_entity_lookup.c} +7 -7
- data/ext/nokogiri/{html_sax_parser_context.c → html4_sax_parser_context.c} +5 -5
- data/ext/nokogiri/{html_sax_push_parser.c → html4_sax_push_parser.c} +4 -4
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +6 -4
- data/ext/nokogiri/include/libxml2/libxml/parser.h +9 -7
- data/ext/nokogiri/include/libxml2/libxml/tree.h +3 -3
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +2 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +39 -115
- data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +1 -1
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +6 -6
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +1 -3
- data/ext/nokogiri/libxml2_backwards_compat.c +30 -30
- data/ext/nokogiri/nokogiri.c +70 -38
- data/ext/nokogiri/nokogiri.h +16 -9
- data/ext/nokogiri/xml_document.c +13 -13
- data/ext/nokogiri/xml_element_content.c +2 -0
- data/ext/nokogiri/xml_encoding_handler.c +11 -6
- data/ext/nokogiri/xml_namespace.c +2 -0
- data/ext/nokogiri/xml_node.c +118 -110
- data/ext/nokogiri/xml_node_set.c +20 -20
- data/ext/nokogiri/xml_reader.c +2 -0
- data/ext/nokogiri/xml_sax_parser.c +6 -6
- data/ext/nokogiri/xml_sax_parser_context.c +2 -0
- data/ext/nokogiri/xml_schema.c +2 -0
- data/ext/nokogiri/xml_xpath_context.c +67 -65
- data/ext/nokogiri/xslt_stylesheet.c +2 -1
- data/gumbo-parser/CHANGES.md +63 -0
- data/gumbo-parser/Makefile +101 -0
- data/gumbo-parser/THANKS +27 -0
- data/lib/nokogiri.rb +31 -29
- data/lib/nokogiri/2.5/nokogiri.so +0 -0
- data/lib/nokogiri/2.6/nokogiri.so +0 -0
- data/lib/nokogiri/2.7/nokogiri.so +0 -0
- data/lib/nokogiri/3.0/nokogiri.so +0 -0
- data/lib/nokogiri/css.rb +14 -14
- data/lib/nokogiri/css/parser.rb +1 -1
- data/lib/nokogiri/css/parser.y +1 -1
- data/lib/nokogiri/css/syntax_error.rb +1 -1
- data/lib/nokogiri/extension.rb +2 -2
- data/lib/nokogiri/gumbo.rb +14 -0
- data/lib/nokogiri/html.rb +31 -27
- data/lib/nokogiri/html4.rb +40 -0
- data/lib/nokogiri/{html → html4}/builder.rb +2 -2
- data/lib/nokogiri/{html → html4}/document.rb +4 -4
- data/lib/nokogiri/{html → html4}/document_fragment.rb +3 -3
- data/lib/nokogiri/{html → html4}/element_description.rb +1 -1
- data/lib/nokogiri/{html → html4}/element_description_defaults.rb +1 -1
- data/lib/nokogiri/{html → html4}/entity_lookup.rb +1 -1
- data/lib/nokogiri/{html → html4}/sax/parser.rb +11 -14
- data/lib/nokogiri/html4/sax/parser_context.rb +19 -0
- data/lib/nokogiri/{html → html4}/sax/push_parser.rb +5 -5
- data/lib/nokogiri/html5.rb +473 -0
- data/lib/nokogiri/html5/document.rb +74 -0
- data/lib/nokogiri/html5/document_fragment.rb +80 -0
- data/lib/nokogiri/html5/node.rb +93 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +12 -2
- data/lib/nokogiri/xml.rb +35 -36
- data/lib/nokogiri/xml/node.rb +6 -5
- data/lib/nokogiri/xml/parse_options.rb +2 -0
- data/lib/nokogiri/xml/pp.rb +2 -2
- data/lib/nokogiri/xml/sax.rb +4 -4
- data/lib/nokogiri/xml/sax/document.rb +24 -30
- data/lib/nokogiri/xml/xpath.rb +2 -2
- data/lib/nokogiri/xslt.rb +16 -16
- data/lib/nokogiri/xslt/stylesheet.rb +1 -1
- metadata +37 -37
- data/lib/nokogiri/html/sax/parser_context.rb +0 -17
data/ext/nokogiri/xml_node.c
CHANGED
@@ -36,6 +36,7 @@ static void
|
|
36
36
|
relink_namespace(xmlNodePtr reparented)
|
37
37
|
{
|
38
38
|
xmlNodePtr child;
|
39
|
+
xmlAttrPtr attr;
|
39
40
|
|
40
41
|
if (reparented->type != XML_ATTRIBUTE_NODE &&
|
41
42
|
reparented->type != XML_ELEMENT_NODE) { return; }
|
@@ -68,11 +69,6 @@ relink_namespace(xmlNodePtr reparented)
|
|
68
69
|
/* Avoid segv when relinking against unlinked nodes. */
|
69
70
|
if (reparented->type != XML_ELEMENT_NODE || !reparented->parent) { return; }
|
70
71
|
|
71
|
-
/* Make sure that our reparented node has the correct namespaces */
|
72
|
-
if (!reparented->ns && reparented->doc != (xmlDocPtr)reparented->parent) {
|
73
|
-
xmlSetNs(reparented, reparented->parent->ns);
|
74
|
-
}
|
75
|
-
|
76
72
|
/* Search our parents for an existing definition */
|
77
73
|
if (reparented->nsDef) {
|
78
74
|
xmlNsPtr curr = reparented->nsDef;
|
@@ -132,10 +128,10 @@ relink_namespace(xmlNodePtr reparented)
|
|
132
128
|
}
|
133
129
|
|
134
130
|
if (reparented->type == XML_ELEMENT_NODE) {
|
135
|
-
|
136
|
-
while (NULL !=
|
137
|
-
relink_namespace(
|
138
|
-
|
131
|
+
attr = reparented->properties;
|
132
|
+
while (NULL != attr) {
|
133
|
+
relink_namespace((xmlNodePtr)attr);
|
134
|
+
attr = attr->next;
|
139
135
|
}
|
140
136
|
}
|
141
137
|
}
|
@@ -170,7 +166,7 @@ static VALUE
|
|
170
166
|
reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_reparentee_func prf)
|
171
167
|
{
|
172
168
|
VALUE reparented_obj ;
|
173
|
-
xmlNodePtr reparentee, pivot, reparented, next_text, new_next_text, parent ;
|
169
|
+
xmlNodePtr reparentee, original_reparentee, pivot, reparented, next_text, new_next_text, parent ;
|
174
170
|
int original_ns_prefix_is_default = 0 ;
|
175
171
|
|
176
172
|
if (!rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlNode)) {
|
@@ -197,66 +193,66 @@ reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_reparentee_func
|
|
197
193
|
|
198
194
|
if (parent) {
|
199
195
|
switch (parent->type) {
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
196
|
+
case XML_DOCUMENT_NODE:
|
197
|
+
case XML_HTML_DOCUMENT_NODE:
|
198
|
+
switch (reparentee->type) {
|
199
|
+
case XML_ELEMENT_NODE:
|
200
|
+
case XML_PI_NODE:
|
201
|
+
case XML_COMMENT_NODE:
|
202
|
+
case XML_DOCUMENT_TYPE_NODE:
|
203
|
+
/*
|
204
|
+
* The DOM specification says no to adding text-like nodes
|
205
|
+
* directly to a document, but we allow it for compatibility.
|
206
|
+
*/
|
207
|
+
case XML_TEXT_NODE:
|
208
|
+
case XML_CDATA_SECTION_NODE:
|
209
|
+
case XML_ENTITY_REF_NODE:
|
210
|
+
goto ok;
|
211
|
+
default:
|
212
|
+
break;
|
213
|
+
}
|
216
214
|
break;
|
217
|
-
|
218
|
-
break;
|
219
|
-
case XML_DOCUMENT_FRAG_NODE:
|
220
|
-
case XML_ENTITY_REF_NODE:
|
221
|
-
case XML_ELEMENT_NODE:
|
222
|
-
switch (reparentee->type) {
|
223
|
-
case XML_ELEMENT_NODE:
|
224
|
-
case XML_PI_NODE:
|
225
|
-
case XML_COMMENT_NODE:
|
226
|
-
case XML_TEXT_NODE:
|
227
|
-
case XML_CDATA_SECTION_NODE:
|
215
|
+
case XML_DOCUMENT_FRAG_NODE:
|
228
216
|
case XML_ENTITY_REF_NODE:
|
229
|
-
|
230
|
-
|
217
|
+
case XML_ELEMENT_NODE:
|
218
|
+
switch (reparentee->type) {
|
219
|
+
case XML_ELEMENT_NODE:
|
220
|
+
case XML_PI_NODE:
|
221
|
+
case XML_COMMENT_NODE:
|
222
|
+
case XML_TEXT_NODE:
|
223
|
+
case XML_CDATA_SECTION_NODE:
|
224
|
+
case XML_ENTITY_REF_NODE:
|
225
|
+
goto ok;
|
226
|
+
default:
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
break;
|
230
|
+
case XML_ATTRIBUTE_NODE:
|
231
|
+
switch (reparentee->type) {
|
232
|
+
case XML_TEXT_NODE:
|
233
|
+
case XML_ENTITY_REF_NODE:
|
234
|
+
goto ok;
|
235
|
+
default:
|
236
|
+
break;
|
237
|
+
}
|
231
238
|
break;
|
232
|
-
}
|
233
|
-
break;
|
234
|
-
case XML_ATTRIBUTE_NODE:
|
235
|
-
switch (reparentee->type) {
|
236
239
|
case XML_TEXT_NODE:
|
237
|
-
|
238
|
-
|
240
|
+
/*
|
241
|
+
* xmlAddChild() breaks the DOM specification in that it allows
|
242
|
+
* adding a text node to another, in which case text nodes are
|
243
|
+
* coalesced, but since our JRuby version does not support such
|
244
|
+
* operation, we should inhibit it.
|
245
|
+
*/
|
246
|
+
break;
|
239
247
|
default:
|
240
248
|
break;
|
241
|
-
}
|
242
|
-
break;
|
243
|
-
case XML_TEXT_NODE:
|
244
|
-
/*
|
245
|
-
* xmlAddChild() breaks the DOM specification in that it allows
|
246
|
-
* adding a text node to another, in which case text nodes are
|
247
|
-
* coalesced, but since our JRuby version does not support such
|
248
|
-
* operation, we should inhibit it.
|
249
|
-
*/
|
250
|
-
break;
|
251
|
-
default:
|
252
|
-
break;
|
253
249
|
}
|
254
250
|
|
255
251
|
rb_raise(rb_eArgError, "cannot reparent %s there", rb_obj_classname(reparentee_obj));
|
256
252
|
}
|
257
253
|
|
258
254
|
ok:
|
259
|
-
|
255
|
+
original_reparentee = reparentee;
|
260
256
|
|
261
257
|
if (reparentee->doc != pivot->doc || reparentee->type == XML_TEXT_NODE) {
|
262
258
|
/*
|
@@ -313,6 +309,8 @@ ok:
|
|
313
309
|
}
|
314
310
|
}
|
315
311
|
|
312
|
+
xmlUnlinkNode(original_reparentee);
|
313
|
+
|
316
314
|
if (prf != xmlAddPrevSibling && prf != xmlAddNextSibling
|
317
315
|
&& reparentee->type == XML_TEXT_NODE && pivot->next && pivot->next->type == XML_TEXT_NODE) {
|
318
316
|
/*
|
@@ -1292,17 +1290,25 @@ get_name(VALUE self)
|
|
1292
1290
|
* Returns the path associated with this Node
|
1293
1291
|
*/
|
1294
1292
|
static VALUE
|
1295
|
-
|
1293
|
+
noko_xml_node_path(VALUE rb_node)
|
1296
1294
|
{
|
1297
|
-
xmlNodePtr
|
1298
|
-
xmlChar *
|
1295
|
+
xmlNodePtr c_node;
|
1296
|
+
xmlChar *c_path ;
|
1299
1297
|
VALUE rval;
|
1300
1298
|
|
1301
|
-
Data_Get_Struct(
|
1299
|
+
Data_Get_Struct(rb_node, xmlNode, c_node);
|
1300
|
+
|
1301
|
+
c_path = xmlGetNodePath(c_node);
|
1302
|
+
if (c_path == NULL) {
|
1303
|
+
// see https://github.com/sparklemotion/nokogiri/issues/2250
|
1304
|
+
// this behavior is clearly undesirable, but is what libxml <= 2.9.10 returned, and so we
|
1305
|
+
// do this for now to preserve the behavior across libxml2 versions.
|
1306
|
+
rval = NOKOGIRI_STR_NEW2("?");
|
1307
|
+
} else {
|
1308
|
+
rval = NOKOGIRI_STR_NEW2(c_path);
|
1309
|
+
xmlFree(c_path);
|
1310
|
+
}
|
1302
1311
|
|
1303
|
-
path = xmlGetNodePath(node);
|
1304
|
-
rval = NOKOGIRI_STR_NEW2(path);
|
1305
|
-
xmlFree(path);
|
1306
1312
|
return rval ;
|
1307
1313
|
}
|
1308
1314
|
|
@@ -1633,12 +1639,12 @@ in_context(VALUE self, VALUE _str, VALUE _options)
|
|
1633
1639
|
|
1634
1640
|
/* FIXME: This probably needs to handle more constants... */
|
1635
1641
|
switch (error) {
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
+
case XML_ERR_INTERNAL_ERROR:
|
1643
|
+
case XML_ERR_NO_MEMORY:
|
1644
|
+
rb_raise(rb_eRuntimeError, "error parsing fragment (%d)", error);
|
1645
|
+
break;
|
1646
|
+
default:
|
1647
|
+
break;
|
1642
1648
|
}
|
1643
1649
|
|
1644
1650
|
set = xmlXPathNodeSetCreate(NULL);
|
@@ -1682,44 +1688,44 @@ noko_xml_node_wrap(VALUE rb_class, xmlNodePtr c_node)
|
|
1682
1688
|
|
1683
1689
|
if (!RTEST(rb_class)) {
|
1684
1690
|
switch (c_node->type) {
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1691
|
+
case XML_ELEMENT_NODE:
|
1692
|
+
rb_class = cNokogiriXmlElement;
|
1693
|
+
break;
|
1694
|
+
case XML_TEXT_NODE:
|
1695
|
+
rb_class = cNokogiriXmlText;
|
1696
|
+
break;
|
1697
|
+
case XML_ATTRIBUTE_NODE:
|
1698
|
+
rb_class = cNokogiriXmlAttr;
|
1699
|
+
break;
|
1700
|
+
case XML_ENTITY_REF_NODE:
|
1701
|
+
rb_class = cNokogiriXmlEntityReference;
|
1702
|
+
break;
|
1703
|
+
case XML_COMMENT_NODE:
|
1704
|
+
rb_class = cNokogiriXmlComment;
|
1705
|
+
break;
|
1706
|
+
case XML_DOCUMENT_FRAG_NODE:
|
1707
|
+
rb_class = cNokogiriXmlDocumentFragment;
|
1708
|
+
break;
|
1709
|
+
case XML_PI_NODE:
|
1710
|
+
rb_class = cNokogiriXmlProcessingInstruction;
|
1711
|
+
break;
|
1712
|
+
case XML_ENTITY_DECL:
|
1713
|
+
rb_class = cNokogiriXmlEntityDecl;
|
1714
|
+
break;
|
1715
|
+
case XML_CDATA_SECTION_NODE:
|
1716
|
+
rb_class = cNokogiriXmlCData;
|
1717
|
+
break;
|
1718
|
+
case XML_DTD_NODE:
|
1719
|
+
rb_class = cNokogiriXmlDtd;
|
1720
|
+
break;
|
1721
|
+
case XML_ATTRIBUTE_DECL:
|
1722
|
+
rb_class = cNokogiriXmlAttributeDecl;
|
1723
|
+
break;
|
1724
|
+
case XML_ELEMENT_DECL:
|
1725
|
+
rb_class = cNokogiriXmlElementDecl;
|
1726
|
+
break;
|
1727
|
+
default:
|
1728
|
+
rb_class = cNokogiriXmlNode;
|
1723
1729
|
}
|
1724
1730
|
}
|
1725
1731
|
|
@@ -1762,6 +1768,8 @@ noko_init_xml_node()
|
|
1762
1768
|
{
|
1763
1769
|
cNokogiriXmlNode = rb_define_class_under(mNokogiriXml, "Node", rb_cObject);
|
1764
1770
|
|
1771
|
+
rb_undef_alloc_func(cNokogiriXmlNode);
|
1772
|
+
|
1765
1773
|
rb_define_singleton_method(cNokogiriXmlNode, "new", rb_xml_node_new, -1);
|
1766
1774
|
|
1767
1775
|
rb_define_method(cNokogiriXmlNode, "add_namespace_definition", add_namespace_definition, 2);
|
@@ -1779,7 +1787,7 @@ noko_init_xml_node()
|
|
1779
1787
|
rb_define_method(cNokogiriXmlNode, "next_element", next_element, 0);
|
1780
1788
|
rb_define_method(cNokogiriXmlNode, "previous_element", previous_element, 0);
|
1781
1789
|
rb_define_method(cNokogiriXmlNode, "node_type", node_type, 0);
|
1782
|
-
rb_define_method(cNokogiriXmlNode, "path",
|
1790
|
+
rb_define_method(cNokogiriXmlNode, "path", noko_xml_node_path, 0);
|
1783
1791
|
rb_define_method(cNokogiriXmlNode, "key?", key_eh, 1);
|
1784
1792
|
rb_define_method(cNokogiriXmlNode, "namespaced_key?", namespaced_key_eh, 2);
|
1785
1793
|
rb_define_method(cNokogiriXmlNode, "blank?", blank_eh, 0);
|
data/ext/nokogiri/xml_node_set.c
CHANGED
@@ -20,20 +20,20 @@ ruby_object_get(xmlNodePtr c_node)
|
|
20
20
|
{
|
21
21
|
/* see xmlElementType in libxml2 tree.h */
|
22
22
|
switch (c_node->type) {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
case XML_NAMESPACE_DECL:
|
24
|
+
/* _private is later in the namespace struct */
|
25
|
+
return (VALUE)(((xmlNsPtr)c_node)->_private);
|
26
|
+
|
27
|
+
case XML_DOCUMENT_NODE:
|
28
|
+
case XML_HTML_DOCUMENT_NODE:
|
29
|
+
/* in documents we use _private to store a tuple */
|
30
|
+
if (DOC_RUBY_OBJECT_TEST(((xmlDocPtr)c_node))) {
|
31
|
+
return DOC_RUBY_OBJECT((xmlDocPtr)c_node);
|
32
|
+
}
|
33
|
+
return (VALUE)NULL;
|
34
|
+
|
35
|
+
default:
|
36
|
+
return (VALUE)(c_node->_private);
|
37
37
|
}
|
38
38
|
}
|
39
39
|
|
@@ -373,12 +373,12 @@ slice(int argc, VALUE *argv, VALUE self)
|
|
373
373
|
|
374
374
|
/* if arg is Range */
|
375
375
|
switch (rb_range_beg_len(arg, &beg, &len, (long)node_set->nodeNr, 0)) {
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
376
|
+
case Qfalse:
|
377
|
+
break;
|
378
|
+
case Qnil:
|
379
|
+
return Qnil;
|
380
|
+
default:
|
381
|
+
return subseq(self, beg, len);
|
382
382
|
}
|
383
383
|
|
384
384
|
return index_at(self, NUM2LONG(arg));
|
data/ext/nokogiri/xml_reader.c
CHANGED
@@ -662,6 +662,8 @@ noko_init_xml_reader()
|
|
662
662
|
*/
|
663
663
|
cNokogiriXmlReader = rb_define_class_under(mNokogiriXml, "Reader", rb_cObject);
|
664
664
|
|
665
|
+
rb_undef_alloc_func(cNokogiriXmlReader);
|
666
|
+
|
665
667
|
rb_define_singleton_method(cNokogiriXmlReader, "from_memory", from_memory, -1);
|
666
668
|
rb_define_singleton_method(cNokogiriXmlReader, "from_io", from_io, -1);
|
667
669
|
|
@@ -30,12 +30,12 @@ start_document(void *ctx)
|
|
30
30
|
version = ctxt->version ? NOKOGIRI_STR_NEW2(ctxt->version) : Qnil;
|
31
31
|
|
32
32
|
switch (ctxt->standalone) {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
case 0:
|
34
|
+
standalone = NOKOGIRI_STR_NEW2("no");
|
35
|
+
break;
|
36
|
+
case 1:
|
37
|
+
standalone = NOKOGIRI_STR_NEW2("yes");
|
38
|
+
break;
|
39
39
|
}
|
40
40
|
|
41
41
|
rb_funcall(doc, id_xmldecl, 3, version, encoding, standalone);
|
@@ -265,6 +265,8 @@ noko_init_xml_sax_parser_context()
|
|
265
265
|
{
|
266
266
|
cNokogiriXmlSaxParserContext = rb_define_class_under(mNokogiriXmlSax, "ParserContext", rb_cObject);
|
267
267
|
|
268
|
+
rb_undef_alloc_func(cNokogiriXmlSaxParserContext);
|
269
|
+
|
268
270
|
rb_define_singleton_method(cNokogiriXmlSaxParserContext, "io", parse_io, 2);
|
269
271
|
rb_define_singleton_method(cNokogiriXmlSaxParserContext, "memory", parse_memory, 1);
|
270
272
|
rb_define_singleton_method(cNokogiriXmlSaxParserContext, "file", parse_file, 1);
|
data/ext/nokogiri/xml_schema.c
CHANGED
@@ -274,6 +274,8 @@ noko_init_xml_schema()
|
|
274
274
|
{
|
275
275
|
cNokogiriXmlSchema = rb_define_class_under(mNokogiriXml, "Schema", rb_cObject);
|
276
276
|
|
277
|
+
rb_undef_alloc_func(cNokogiriXmlSchema);
|
278
|
+
|
277
279
|
rb_define_singleton_method(cNokogiriXmlSchema, "read_memory", read_memory, -1);
|
278
280
|
rb_define_singleton_method(cNokogiriXmlSchema, "from_document", from_document, -1);
|
279
281
|
|
@@ -154,20 +154,20 @@ Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, i
|
|
154
154
|
do {
|
155
155
|
obj = valuePop(ctx);
|
156
156
|
switch (obj->type) {
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
157
|
+
case XPATH_STRING:
|
158
|
+
argv[i] = NOKOGIRI_STR_NEW2(obj->stringval);
|
159
|
+
break;
|
160
|
+
case XPATH_BOOLEAN:
|
161
|
+
argv[i] = obj->boolval == 1 ? Qtrue : Qfalse;
|
162
|
+
break;
|
163
|
+
case XPATH_NUMBER:
|
164
|
+
argv[i] = rb_float_new(obj->floatval);
|
165
|
+
break;
|
166
|
+
case XPATH_NODESET:
|
167
|
+
argv[i] = noko_xml_node_set_wrap(obj->nodesetval, doc);
|
168
|
+
break;
|
169
|
+
default:
|
170
|
+
argv[i] = NOKOGIRI_STR_NEW2(xmlXPathCastToString(obj));
|
171
171
|
}
|
172
172
|
xmlXPathFreeNodeSetList(obj);
|
173
173
|
} while (i-- > 0);
|
@@ -181,43 +181,43 @@ Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, i
|
|
181
181
|
free(argv);
|
182
182
|
|
183
183
|
switch (TYPE(result)) {
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
break;
|
201
|
-
case T_NIL:
|
202
|
-
break;
|
203
|
-
case T_ARRAY: {
|
204
|
-
VALUE args[2];
|
205
|
-
args[0] = doc;
|
206
|
-
args[1] = result;
|
207
|
-
node_set = rb_class_new_instance(2, args, cNokogiriXmlNodeSet);
|
208
|
-
Data_Get_Struct(node_set, xmlNodeSet, xml_node_set);
|
209
|
-
xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
|
210
|
-
}
|
211
|
-
break;
|
212
|
-
case T_DATA:
|
213
|
-
if (rb_obj_is_kind_of(result, cNokogiriXmlNodeSet)) {
|
214
|
-
Data_Get_Struct(result, xmlNodeSet, xml_node_set);
|
215
|
-
/* Copy the node set, otherwise it will get GC'd. */
|
216
|
-
xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
|
184
|
+
case T_FLOAT:
|
185
|
+
case T_BIGNUM:
|
186
|
+
case T_FIXNUM:
|
187
|
+
xmlXPathReturnNumber(ctx, NUM2DBL(result));
|
188
|
+
break;
|
189
|
+
case T_STRING:
|
190
|
+
xmlXPathReturnString(
|
191
|
+
ctx,
|
192
|
+
xmlCharStrdup(StringValueCStr(result))
|
193
|
+
);
|
194
|
+
break;
|
195
|
+
case T_TRUE:
|
196
|
+
xmlXPathReturnTrue(ctx);
|
197
|
+
break;
|
198
|
+
case T_FALSE:
|
199
|
+
xmlXPathReturnFalse(ctx);
|
217
200
|
break;
|
201
|
+
case T_NIL:
|
202
|
+
break;
|
203
|
+
case T_ARRAY: {
|
204
|
+
VALUE args[2];
|
205
|
+
args[0] = doc;
|
206
|
+
args[1] = result;
|
207
|
+
node_set = rb_class_new_instance(2, args, cNokogiriXmlNodeSet);
|
208
|
+
Data_Get_Struct(node_set, xmlNodeSet, xml_node_set);
|
209
|
+
xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
|
218
210
|
}
|
219
|
-
|
220
|
-
|
211
|
+
break;
|
212
|
+
case T_DATA:
|
213
|
+
if (rb_obj_is_kind_of(result, cNokogiriXmlNodeSet)) {
|
214
|
+
Data_Get_Struct(result, xmlNodeSet, xml_node_set);
|
215
|
+
/* Copy the node set, otherwise it will get GC'd. */
|
216
|
+
xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
|
217
|
+
break;
|
218
|
+
}
|
219
|
+
default:
|
220
|
+
rb_raise(rb_eRuntimeError, "Invalid return type");
|
221
221
|
}
|
222
222
|
}
|
223
223
|
|
@@ -314,22 +314,22 @@ evaluate(int argc, VALUE *argv, VALUE self)
|
|
314
314
|
assert(DOC_RUBY_OBJECT_TEST(ctx->doc));
|
315
315
|
|
316
316
|
switch (xpath->type) {
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
317
|
+
case XPATH_STRING:
|
318
|
+
thing = NOKOGIRI_STR_NEW2(xpath->stringval);
|
319
|
+
xmlFree(xpath->stringval);
|
320
|
+
break;
|
321
|
+
case XPATH_NODESET:
|
322
|
+
thing = noko_xml_node_set_wrap(xpath->nodesetval,
|
323
|
+
DOC_RUBY_OBJECT(ctx->doc));
|
324
|
+
break;
|
325
|
+
case XPATH_NUMBER:
|
326
|
+
thing = rb_float_new(xpath->floatval);
|
327
|
+
break;
|
328
|
+
case XPATH_BOOLEAN:
|
329
|
+
thing = xpath->boolval == 1 ? Qtrue : Qfalse;
|
330
|
+
break;
|
331
|
+
default:
|
332
|
+
thing = noko_xml_node_set_wrap(NULL, DOC_RUBY_OBJECT(ctx->doc));
|
333
333
|
}
|
334
334
|
|
335
335
|
xmlXPathFreeNodeSetList(xpath);
|
@@ -373,6 +373,8 @@ noko_init_xml_xpath_context(void)
|
|
373
373
|
*/
|
374
374
|
cNokogiriXmlXpathContext = rb_define_class_under(mNokogiriXml, "XPathContext", rb_cObject);
|
375
375
|
|
376
|
+
rb_undef_alloc_func(cNokogiriXmlXpathContext);
|
377
|
+
|
376
378
|
rb_define_singleton_method(cNokogiriXmlXpathContext, "new", new, 1);
|
377
379
|
|
378
380
|
rb_define_method(cNokogiriXmlXpathContext, "evaluate", evaluate, -1);
|