nokogiri 1.8.5 → 1.9.1
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/README.md +0 -1
- data/ext/nokogiri/extconf.rb +10 -6
- data/ext/nokogiri/xml_attr.c +26 -21
- data/ext/nokogiri/xml_document.c +4 -1
- data/ext/nokogiri/xml_namespace.c +3 -3
- data/ext/nokogiri/xml_namespace.h +1 -2
- data/ext/nokogiri/xml_node.c +55 -15
- data/lib/nokogiri/css/parser.rb +61 -61
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml/document_fragment.rb +11 -0
- data/lib/nokogiri/xml/node.rb +12 -0
- data/lib/nokogiri/xml/node_set.rb +4 -8
- metadata +17 -153
- data/.autotest +0 -22
- data/.cross_rubies +0 -8
- data/.editorconfig +0 -17
- data/.gemtest +0 -0
- data/.travis.yml +0 -63
- data/CHANGELOG.md +0 -1368
- data/CONTRIBUTING.md +0 -42
- data/C_CODING_STYLE.rdoc +0 -33
- data/Gemfile +0 -23
- data/Gemfile-libxml-ruby +0 -3
- data/Manifest.txt +0 -370
- data/ROADMAP.md +0 -111
- data/Rakefile +0 -348
- data/SECURITY.md +0 -19
- data/STANDARD_RESPONSES.md +0 -47
- data/Y_U_NO_GEMSPEC.md +0 -155
- data/appveyor.yml +0 -29
- data/build_all +0 -44
- data/patches/sort-patches-by-date +0 -25
- data/suppressions/README.txt +0 -1
- data/suppressions/nokogiri_ruby-2.supp +0 -10
- data/tasks/test.rb +0 -100
- data/test/css/test_nthiness.rb +0 -226
- data/test/css/test_parser.rb +0 -386
- data/test/css/test_tokenizer.rb +0 -215
- data/test/css/test_xpath_visitor.rb +0 -96
- data/test/decorators/test_slop.rb +0 -23
- data/test/files/2ch.html +0 -108
- data/test/files/GH_1042.html +0 -18
- data/test/files/address_book.rlx +0 -12
- data/test/files/address_book.xml +0 -10
- data/test/files/atom.xml +0 -344
- data/test/files/bar/bar.xsd +0 -4
- data/test/files/bogus.xml +0 -0
- data/test/files/dont_hurt_em_why.xml +0 -422
- data/test/files/encoding.html +0 -82
- data/test/files/encoding.xhtml +0 -84
- data/test/files/exslt.xml +0 -8
- data/test/files/exslt.xslt +0 -35
- data/test/files/foo/foo.xsd +0 -4
- data/test/files/metacharset.html +0 -10
- data/test/files/namespace_pressure_test.xml +0 -1684
- data/test/files/noencoding.html +0 -47
- data/test/files/po.xml +0 -32
- data/test/files/po.xsd +0 -66
- data/test/files/saml/saml20assertion_schema.xsd +0 -283
- data/test/files/saml/saml20protocol_schema.xsd +0 -302
- data/test/files/saml/xenc_schema.xsd +0 -146
- data/test/files/saml/xmldsig_schema.xsd +0 -318
- data/test/files/shift_jis.html +0 -10
- data/test/files/shift_jis.xml +0 -5
- data/test/files/shift_jis_no_charset.html +0 -9
- data/test/files/slow-xpath.xml +0 -25509
- data/test/files/snuggles.xml +0 -3
- data/test/files/staff.dtd +0 -10
- data/test/files/staff.xml +0 -59
- data/test/files/staff.xslt +0 -32
- data/test/files/test_document_url/bar.xml +0 -2
- data/test/files/test_document_url/document.dtd +0 -4
- data/test/files/test_document_url/document.xml +0 -6
- data/test/files/tlm.html +0 -851
- data/test/files/to_be_xincluded.xml +0 -2
- data/test/files/valid_bar.xml +0 -2
- data/test/files/xinclude.xml +0 -4
- data/test/helper.rb +0 -271
- data/test/html/sax/test_parser.rb +0 -168
- data/test/html/sax/test_parser_context.rb +0 -46
- data/test/html/sax/test_parser_text.rb +0 -163
- data/test/html/sax/test_push_parser.rb +0 -87
- data/test/html/test_attributes.rb +0 -85
- data/test/html/test_builder.rb +0 -164
- data/test/html/test_document.rb +0 -712
- data/test/html/test_document_encoding.rb +0 -143
- data/test/html/test_document_fragment.rb +0 -310
- data/test/html/test_element_description.rb +0 -105
- data/test/html/test_named_characters.rb +0 -14
- data/test/html/test_node.rb +0 -212
- data/test/html/test_node_encoding.rb +0 -91
- data/test/namespaces/test_additional_namespaces_in_builder_doc.rb +0 -14
- data/test/namespaces/test_namespaces_aliased_default.rb +0 -24
- data/test/namespaces/test_namespaces_in_builder_doc.rb +0 -75
- data/test/namespaces/test_namespaces_in_cloned_doc.rb +0 -31
- data/test/namespaces/test_namespaces_in_created_doc.rb +0 -75
- data/test/namespaces/test_namespaces_in_parsed_doc.rb +0 -80
- data/test/namespaces/test_namespaces_preservation.rb +0 -31
- data/test/test_convert_xpath.rb +0 -135
- data/test/test_css_cache.rb +0 -47
- data/test/test_encoding_handler.rb +0 -48
- data/test/test_memory_leak.rb +0 -156
- data/test/test_nokogiri.rb +0 -138
- data/test/test_soap4r_sax.rb +0 -52
- data/test/test_xslt_transforms.rb +0 -314
- data/test/xml/node/test_save_options.rb +0 -28
- data/test/xml/node/test_subclass.rb +0 -44
- data/test/xml/sax/test_parser.rb +0 -402
- data/test/xml/sax/test_parser_context.rb +0 -115
- data/test/xml/sax/test_parser_text.rb +0 -202
- data/test/xml/sax/test_push_parser.rb +0 -265
- data/test/xml/test_attr.rb +0 -74
- data/test/xml/test_attribute_decl.rb +0 -86
- data/test/xml/test_builder.rb +0 -341
- data/test/xml/test_c14n.rb +0 -180
- data/test/xml/test_cdata.rb +0 -54
- data/test/xml/test_comment.rb +0 -40
- data/test/xml/test_document.rb +0 -982
- data/test/xml/test_document_encoding.rb +0 -31
- data/test/xml/test_document_fragment.rb +0 -298
- data/test/xml/test_dtd.rb +0 -187
- data/test/xml/test_dtd_encoding.rb +0 -31
- data/test/xml/test_element_content.rb +0 -56
- data/test/xml/test_element_decl.rb +0 -73
- data/test/xml/test_entity_decl.rb +0 -122
- data/test/xml/test_entity_reference.rb +0 -262
- data/test/xml/test_namespace.rb +0 -96
- data/test/xml/test_node.rb +0 -1325
- data/test/xml/test_node_attributes.rb +0 -115
- data/test/xml/test_node_encoding.rb +0 -75
- data/test/xml/test_node_inheritance.rb +0 -32
- data/test/xml/test_node_reparenting.rb +0 -592
- data/test/xml/test_node_set.rb +0 -809
- data/test/xml/test_parse_options.rb +0 -64
- data/test/xml/test_processing_instruction.rb +0 -30
- data/test/xml/test_reader.rb +0 -620
- data/test/xml/test_reader_encoding.rb +0 -134
- data/test/xml/test_relax_ng.rb +0 -60
- data/test/xml/test_schema.rb +0 -142
- data/test/xml/test_syntax_error.rb +0 -36
- data/test/xml/test_text.rb +0 -60
- data/test/xml/test_unparented_node.rb +0 -483
- data/test/xml/test_xinclude.rb +0 -83
- data/test/xml/test_xpath.rb +0 -470
- data/test/xslt/test_custom_functions.rb +0 -133
- data/test/xslt/test_exception_handling.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a790da6f884cfbbebd155a97ab4c3be5fd8ec96a0819a44834996453f9f9b3
|
4
|
+
data.tar.gz: fc972743c712fde37bd6f10594ce6db727de0f78f809fa9bfb94db4e712d8492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de24a0ae431a5f9f19a5f86307f0d5c4ec370849b90da70ff08f01cd017617426b94de3e477e6db0c86f14a78a2b9f70617dce1ffe6310d0942d7e665248594d
|
7
|
+
data.tar.gz: b6b0f502a24638a80f0b9002b9510457980a65f57d46fda704989912c78f40d375b250a6de4019a59f1b0aee81a18dbd57af7c8ba4f985f4a4c4c9aa2740abf0
|
data/README.md
CHANGED
@@ -18,7 +18,6 @@ or CSS3 selectors.
|
|
18
18
|
|
19
19
|
[![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/nokogiri/jobs/ruby-2.4-system/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/nokogiri?groups=master)
|
20
20
|
[![Code Climate](https://codeclimate.com/github/sparklemotion/nokogiri.svg)](https://codeclimate.com/github/sparklemotion/nokogiri)
|
21
|
-
[![Version Eye](https://www.versioneye.com/ruby/nokogiri/badge.png)](https://www.versioneye.com/ruby/nokogiri)
|
22
21
|
[![Join the chat at https://gitter.im/sparklemotion/nokogiri](https://badges.gitter.im/sparklemotion/nokogiri.svg)](https://gitter.im/sparklemotion/nokogiri?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
23
22
|
|
24
23
|
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -400,9 +400,11 @@ if openbsd? && !using_system_libraries?
|
|
400
400
|
ENV['CFLAGS'] = "#{ENV['CFLAGS']} -I /usr/local/include"
|
401
401
|
end
|
402
402
|
|
403
|
-
|
403
|
+
if ENV['CC']
|
404
|
+
RbConfig::CONFIG['CC'] = RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC']
|
405
|
+
end
|
404
406
|
# use same c compiler for libxml and libxslt
|
405
|
-
ENV['CC'] = RbConfig::
|
407
|
+
ENV['CC'] = RbConfig::CONFIG['CC']
|
406
408
|
|
407
409
|
$LIBS << " #{ENV["LIBS"]}"
|
408
410
|
|
@@ -432,7 +434,7 @@ if RUBY_PLATFORM =~ /mingw/i
|
|
432
434
|
$CPPFLAGS << ' "-Idummypath"'
|
433
435
|
end
|
434
436
|
|
435
|
-
if RbConfig::
|
437
|
+
if RbConfig::CONFIG['CC'] =~ /gcc/
|
436
438
|
$CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
|
437
439
|
$CFLAGS << " -Wall -Wcast-qual -Wwrite-strings -Wmissing-noreturn -Winline"
|
438
440
|
end
|
@@ -460,7 +462,7 @@ else
|
|
460
462
|
# The gem version constraint in the Rakefile is not respected at install time.
|
461
463
|
# Keep this version in sync with the one in the Rakefile !
|
462
464
|
require 'rubygems'
|
463
|
-
gem 'mini_portile2', '~> 2.
|
465
|
+
gem 'mini_portile2', '~> 2.4.0'
|
464
466
|
require 'mini_portile2'
|
465
467
|
message "Using mini_portile version #{MiniPortile::VERSION}\n"
|
466
468
|
|
@@ -560,7 +562,8 @@ EOM
|
|
560
562
|
*(libiconv_recipe ? "--with-iconv=#{libiconv_recipe.path}" : iconv_configure_flags),
|
561
563
|
"--with-c14n",
|
562
564
|
"--with-debug",
|
563
|
-
"--with-threads"
|
565
|
+
"--with-threads",
|
566
|
+
*(darwin? ? ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"] : "")
|
564
567
|
]
|
565
568
|
end
|
566
569
|
|
@@ -573,7 +576,8 @@ EOM
|
|
573
576
|
"--without-python",
|
574
577
|
"--without-crypto",
|
575
578
|
"--with-debug",
|
576
|
-
"--with-libxml-prefix=#{sh_export_path(libxml2_recipe.path)}"
|
579
|
+
"--with-libxml-prefix=#{sh_export_path(libxml2_recipe.path)}",
|
580
|
+
*(darwin? ? ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"] : "")
|
577
581
|
]
|
578
582
|
end
|
579
583
|
|
data/ext/nokogiri/xml_attr.c
CHANGED
@@ -4,37 +4,40 @@
|
|
4
4
|
* call-seq:
|
5
5
|
* value=(content)
|
6
6
|
*
|
7
|
-
* Set the value for this Attr to +content
|
7
|
+
* Set the value for this Attr to +content+. Use `nil` to remove the value
|
8
|
+
* (e.g., a HTML boolean attribute).
|
8
9
|
*/
|
9
10
|
static VALUE set_value(VALUE self, VALUE content)
|
10
11
|
{
|
11
12
|
xmlAttrPtr attr;
|
12
|
-
|
13
|
+
xmlChar *value;
|
14
|
+
xmlNode *cur;
|
13
15
|
|
14
|
-
|
16
|
+
Data_Get_Struct(self, xmlAttr, attr);
|
15
17
|
|
18
|
+
if (attr->children) {
|
19
|
+
xmlFreeNodeList(attr->children);
|
20
|
+
}
|
16
21
|
attr->children = attr->last = NULL;
|
17
22
|
|
18
|
-
if (content) {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
/* Encode our content */
|
23
|
-
buffer = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValueCStr(content));
|
23
|
+
if (content == Qnil) {
|
24
|
+
return content;
|
25
|
+
}
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
value = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValueCStr(content));
|
28
|
+
if (xmlStrlen(value) == 0) {
|
29
|
+
attr->children = xmlNewDocText(attr->doc, value);
|
30
|
+
} else {
|
31
|
+
attr->children = xmlStringGetNodeList(attr->doc, value);
|
32
|
+
}
|
33
|
+
xmlFree(value);
|
28
34
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
for (cur = attr->children; cur; cur = cur->next) {
|
36
|
+
cur->parent = (xmlNode *)attr;
|
37
|
+
cur->doc = attr->doc;
|
38
|
+
if (cur->next == NULL) {
|
39
|
+
attr->last = cur;
|
34
40
|
}
|
35
|
-
|
36
|
-
/* Free up memory */
|
37
|
-
xmlFree(buffer);
|
38
41
|
}
|
39
42
|
|
40
43
|
return content;
|
@@ -74,7 +77,9 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
74
77
|
rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)node);
|
75
78
|
rb_obj_call_init(rb_node, argc, argv);
|
76
79
|
|
77
|
-
if (rb_block_given_p()) {
|
80
|
+
if (rb_block_given_p()) {
|
81
|
+
rb_yield(rb_node);
|
82
|
+
}
|
78
83
|
|
79
84
|
return rb_node;
|
80
85
|
}
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -7,7 +7,10 @@ static int dealloc_node_i(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc)
|
|
7
7
|
xmlFreePropList((xmlAttrPtr)node);
|
8
8
|
break;
|
9
9
|
case XML_NAMESPACE_DECL:
|
10
|
-
|
10
|
+
xmlFreeNs((xmlNsPtr)node);
|
11
|
+
break;
|
12
|
+
case XML_DTD_NODE:
|
13
|
+
xmlFreeDtd((xmlDtdPtr)node);
|
11
14
|
break;
|
12
15
|
default:
|
13
16
|
if(node->parent == NULL) {
|
@@ -63,7 +63,7 @@ static int part_of_an_xpath_node_set_eh(xmlNsPtr node)
|
|
63
63
|
|
64
64
|
VALUE Nokogiri_wrap_xml_namespace(xmlDocPtr doc, xmlNsPtr node)
|
65
65
|
{
|
66
|
-
VALUE ns, document, node_cache;
|
66
|
+
VALUE ns = 0, document, node_cache;
|
67
67
|
|
68
68
|
assert(doc->type == XML_DOCUMENT_NODE || doc->type == XML_HTML_DOCUMENT_NODE);
|
69
69
|
|
@@ -71,8 +71,6 @@ VALUE Nokogiri_wrap_xml_namespace(xmlDocPtr doc, xmlNsPtr node)
|
|
71
71
|
|
72
72
|
if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
|
73
73
|
|
74
|
-
ns = Data_Wrap_Struct(cNokogiriXmlNamespace, 0, 0, node);
|
75
|
-
|
76
74
|
if (DOC_RUBY_OBJECT_TEST(doc)) {
|
77
75
|
document = DOC_RUBY_OBJECT(doc);
|
78
76
|
|
@@ -91,6 +89,8 @@ VALUE Nokogiri_wrap_xml_namespace(xmlDocPtr doc, xmlNsPtr node)
|
|
91
89
|
}
|
92
90
|
|
93
91
|
rb_iv_set(ns, "@document", document);
|
92
|
+
} else {
|
93
|
+
ns = Data_Wrap_Struct(cNokogiriXmlNamespace, 0, 0, node);
|
94
94
|
}
|
95
95
|
|
96
96
|
node->_private = (void *)ns;
|
@@ -7,8 +7,7 @@ void init_xml_namespace();
|
|
7
7
|
|
8
8
|
extern VALUE cNokogiriXmlNamespace ;
|
9
9
|
|
10
|
-
VALUE Nokogiri_wrap_xml_namespace(xmlDocPtr doc, xmlNsPtr node)
|
11
|
-
VALUE Nokogiri_wrap_xml_namespace2(VALUE document, xmlNsPtr node) ;
|
10
|
+
VALUE Nokogiri_wrap_xml_namespace(xmlDocPtr doc, xmlNsPtr node);
|
12
11
|
|
13
12
|
#define NOKOGIRI_NAMESPACE_EH(node) ((node)->type == XML_NAMESPACE_DECL)
|
14
13
|
|
data/ext/nokogiri/xml_node.c
CHANGED
@@ -31,13 +31,13 @@ typedef xmlNodePtr (*pivot_reparentee_func)(xmlNodePtr, xmlNodePtr);
|
|
31
31
|
static void relink_namespace(xmlNodePtr reparented)
|
32
32
|
{
|
33
33
|
xmlNodePtr child;
|
34
|
-
xmlNsPtr ns;
|
35
34
|
|
36
35
|
if (reparented->type != XML_ATTRIBUTE_NODE &&
|
37
36
|
reparented->type != XML_ELEMENT_NODE) { return; }
|
38
37
|
|
39
38
|
if (reparented->ns == NULL || reparented->ns->prefix == NULL) {
|
40
|
-
|
39
|
+
xmlNsPtr ns = NULL;
|
40
|
+
xmlChar *name = NULL, *prefix = NULL;
|
41
41
|
|
42
42
|
name = xmlSplitQName2(reparented->name, &prefix);
|
43
43
|
|
@@ -99,6 +99,25 @@ static void relink_namespace(xmlNodePtr reparented)
|
|
99
99
|
}
|
100
100
|
}
|
101
101
|
|
102
|
+
/*
|
103
|
+
* Search our parents for an existing definition of current namespace,
|
104
|
+
* because the definition it's pointing to may have just been removed nsDef.
|
105
|
+
*
|
106
|
+
* And although that would technically probably be OK, I'd feel better if we
|
107
|
+
* referred to a namespace that's still present in a node's nsDef somewhere
|
108
|
+
* in the doc.
|
109
|
+
*/
|
110
|
+
if (reparented->ns) {
|
111
|
+
xmlNsPtr ns = xmlSearchNs(reparented->doc, reparented, reparented->ns->prefix);
|
112
|
+
if (ns
|
113
|
+
&& ns != reparented->ns
|
114
|
+
&& xmlStrEqual(ns->prefix, reparented->ns->prefix)
|
115
|
+
&& xmlStrEqual(ns->href, reparented->ns->href)
|
116
|
+
) {
|
117
|
+
xmlSetNs(reparented, ns);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
102
121
|
/* Only walk all children if there actually is a namespace we need to */
|
103
122
|
/* reparent. */
|
104
123
|
if (NULL == reparented->ns) { return; }
|
@@ -282,7 +301,11 @@ ok:
|
|
282
301
|
}
|
283
302
|
|
284
303
|
if (original_ns_prefix_is_default && reparentee->ns != NULL && reparentee->ns->prefix != NULL) {
|
285
|
-
/*
|
304
|
+
/*
|
305
|
+
* issue #391, where new node's prefix may become the string "default"
|
306
|
+
* see libxml2 tree.c xmlNewReconciliedNs which implements this behavior.
|
307
|
+
*/
|
308
|
+
xmlFree(reparentee->ns->prefix);
|
286
309
|
reparentee->ns->prefix = NULL;
|
287
310
|
}
|
288
311
|
}
|
@@ -509,22 +532,39 @@ static VALUE internal_subset(VALUE self)
|
|
509
532
|
/*
|
510
533
|
* call-seq:
|
511
534
|
* dup
|
535
|
+
* dup(depth)
|
536
|
+
* dup(depth, new_parent_doc)
|
512
537
|
*
|
513
|
-
* Copy this node.
|
514
|
-
*
|
538
|
+
* Copy this node.
|
539
|
+
* An optional depth may be passed in. 0 is a shallow copy, 1 (the default) is a deep copy.
|
540
|
+
* An optional new_parent_doc may also be passed in, which will be the new
|
541
|
+
* node's parent document. Defaults to the current node's document.
|
542
|
+
* current document.
|
515
543
|
*/
|
516
544
|
static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
|
517
545
|
{
|
518
|
-
VALUE
|
546
|
+
VALUE r_level, r_new_parent_doc;
|
547
|
+
int level;
|
548
|
+
int n_args;
|
549
|
+
xmlDocPtr new_parent_doc;
|
519
550
|
xmlNodePtr node, dup;
|
520
551
|
|
521
|
-
|
522
|
-
|
552
|
+
Data_Get_Struct(self, xmlNode, node);
|
553
|
+
|
554
|
+
n_args = rb_scan_args(argc, argv, "02", &r_level, &r_new_parent_doc);
|
555
|
+
|
556
|
+
if (n_args < 1) {
|
557
|
+
r_level = INT2NUM((long)1);
|
523
558
|
}
|
559
|
+
level = (int)NUM2INT(r_level);
|
524
560
|
|
525
|
-
|
561
|
+
if (n_args < 2) {
|
562
|
+
new_parent_doc = node->doc;
|
563
|
+
} else {
|
564
|
+
Data_Get_Struct(r_new_parent_doc, xmlDoc, new_parent_doc);
|
565
|
+
}
|
526
566
|
|
527
|
-
dup = xmlDocCopyNode(node,
|
567
|
+
dup = xmlDocCopyNode(node, new_parent_doc, level);
|
528
568
|
if(dup == NULL) { return Qnil; }
|
529
569
|
|
530
570
|
nokogiri_root_node(dup);
|
@@ -1308,11 +1348,11 @@ static VALUE line(VALUE self)
|
|
1308
1348
|
*/
|
1309
1349
|
static VALUE add_namespace_definition(VALUE self, VALUE prefix, VALUE href)
|
1310
1350
|
{
|
1311
|
-
xmlNodePtr node,
|
1351
|
+
xmlNodePtr node, namespace;
|
1312
1352
|
xmlNsPtr ns;
|
1313
1353
|
|
1314
1354
|
Data_Get_Struct(self, xmlNode, node);
|
1315
|
-
|
1355
|
+
namespace = node ;
|
1316
1356
|
|
1317
1357
|
ns = xmlSearchNs(
|
1318
1358
|
node->doc,
|
@@ -1322,10 +1362,10 @@ static VALUE add_namespace_definition(VALUE self, VALUE prefix, VALUE href)
|
|
1322
1362
|
|
1323
1363
|
if(!ns) {
|
1324
1364
|
if (node->type != XML_ELEMENT_NODE) {
|
1325
|
-
|
1365
|
+
namespace = node->parent;
|
1326
1366
|
}
|
1327
1367
|
ns = xmlNewNs(
|
1328
|
-
|
1368
|
+
namespace,
|
1329
1369
|
(const xmlChar *)StringValueCStr(href),
|
1330
1370
|
(const xmlChar *)(NIL_P(prefix) ? NULL : StringValueCStr(prefix))
|
1331
1371
|
);
|
@@ -1333,7 +1373,7 @@ static VALUE add_namespace_definition(VALUE self, VALUE prefix, VALUE href)
|
|
1333
1373
|
|
1334
1374
|
if (!ns) { return Qnil ; }
|
1335
1375
|
|
1336
|
-
if(NIL_P(prefix) || node !=
|
1376
|
+
if(NIL_P(prefix) || node != namespace) { xmlSetNs(node, ns); }
|
1337
1377
|
|
1338
1378
|
return Nokogiri_wrap_xml_namespace(node->doc, ns);
|
1339
1379
|
}
|
data/lib/nokogiri/css/parser.rb
CHANGED
@@ -31,64 +31,64 @@ end
|
|
31
31
|
|
32
32
|
racc_action_table = [
|
33
33
|
24, 93, 56, 57, 33, 55, 94, 23, 24, 22,
|
34
|
-
12, 93, 33, 27,
|
35
|
-
|
34
|
+
12, 93, 33, 27, 35, 52, 44, 22, -23, 25,
|
35
|
+
45, 98, 23, 33, 26, 18, 20, 25, 27, -23,
|
36
36
|
23, 24, 26, 18, 20, 33, 27, 11, 39, 24,
|
37
|
-
22, 23,
|
38
|
-
25,
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
27,
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
18,
|
49
|
-
|
50
|
-
81, nil, nil, nil, 77, 78, 79, 80, nil,
|
51
|
-
4, 5,
|
52
|
-
6, 60, 8, 7, 6, nil, 8, 7, 4,
|
53
|
-
10,
|
54
|
-
8, 7 ]
|
37
|
+
22, 23, 74, 33, 18, 91, 90, 27, 22, 12,
|
38
|
+
25, 24, -23, 23, 85, 26, 18, 20, 25, 27,
|
39
|
+
66, 23, 24, 26, 18, 20, 33, 27, 86, 88,
|
40
|
+
51, 22, 89, 92, 24, 26, 56, 87, 95, 60,
|
41
|
+
90, 25, 96, 46, 23, 49, 26, 18, 20, 99,
|
42
|
+
27, 33, 33, 51, 103, 104, 56, 58, 26, 60,
|
43
|
+
93, 106, 33, 33, 33, 109, 39, 39, 110, 23,
|
44
|
+
23, nil, 18, 18, 20, 27, 27, 39, 39, 39,
|
45
|
+
23, 23, 23, 18, 18, 18, 27, 27, 27, 33,
|
46
|
+
33, 101, 100, nil, 102, 22, 56, 87, nil, 60,
|
47
|
+
33, nil, nil, nil, 39, 39, nil, 23, 23, nil,
|
48
|
+
18, 18, 20, 27, 27, 39, 82, 83, 23, 56,
|
49
|
+
87, 18, 60, nil, 27, 82, 83, 78, 79, 80,
|
50
|
+
nil, 81, nil, nil, nil, 77, 78, 79, 80, nil,
|
51
|
+
81, 4, 5, 10, 77, 4, 5, 43, nil, 56,
|
52
|
+
87, 6, 60, 8, 7, 6, nil, 8, 7, 4,
|
53
|
+
5, 10, nil, nil, nil, nil, nil, nil, nil, 6,
|
54
|
+
nil, 8, 7 ]
|
55
55
|
|
56
56
|
racc_action_check = [
|
57
|
-
3, 58, 24, 24, 3, 24, 57, 15,
|
58
|
-
64, 57,
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
32, 39,
|
73
|
-
|
74
|
-
47, nil, nil, nil, 47, 48, 48, 48, nil,
|
75
|
-
|
76
|
-
|
77
|
-
26,
|
78
|
-
26, 26 ]
|
57
|
+
3, 58, 24, 24, 3, 24, 57, 15, 9, 3,
|
58
|
+
64, 57, 9, 15, 11, 24, 18, 9, 58, 3,
|
59
|
+
21, 64, 3, 14, 3, 3, 3, 9, 3, 22,
|
60
|
+
9, 12, 9, 9, 9, 12, 9, 1, 14, 42,
|
61
|
+
12, 14, 45, 42, 14, 55, 55, 14, 42, 1,
|
62
|
+
12, 27, 46, 12, 49, 12, 12, 12, 42, 12,
|
63
|
+
27, 42, 43, 42, 42, 42, 43, 42, 50, 53,
|
64
|
+
27, 43, 54, 56, 23, 27, 51, 51, 59, 51,
|
65
|
+
60, 43, 61, 23, 43, 23, 43, 43, 43, 75,
|
66
|
+
43, 28, 25, 23, 84, 86, 25, 25, 23, 25,
|
67
|
+
87, 91, 29, 30, 31, 94, 28, 25, 106, 28,
|
68
|
+
25, nil, 28, 25, 25, 28, 25, 29, 30, 31,
|
69
|
+
29, 30, 31, 29, 30, 31, 29, 30, 31, 32,
|
70
|
+
39, 76, 76, nil, 76, 39, 90, 90, nil, 90,
|
71
|
+
62, nil, nil, nil, 32, 39, nil, 32, 39, nil,
|
72
|
+
32, 39, 39, 32, 39, 62, 47, 47, 62, 92,
|
73
|
+
92, 62, 92, nil, 62, 48, 48, 47, 47, 47,
|
74
|
+
nil, 47, nil, nil, nil, 47, 48, 48, 48, nil,
|
75
|
+
48, 0, 0, 0, 48, 17, 17, 17, nil, 93,
|
76
|
+
93, 0, 93, 0, 0, 17, nil, 17, 17, 26,
|
77
|
+
26, 26, nil, nil, nil, nil, nil, nil, nil, 26,
|
78
|
+
nil, 26, 26 ]
|
79
79
|
|
80
80
|
racc_action_pointer = [
|
81
|
-
|
82
|
-
nil,
|
83
|
-
nil,
|
84
|
-
|
85
|
-
nil, nil,
|
86
|
-
|
87
|
-
|
88
|
-
nil, nil, nil, nil, nil,
|
89
|
-
nil, nil, nil, nil,
|
90
|
-
|
91
|
-
nil, nil, nil, nil, nil, nil,
|
81
|
+
174, 37, nil, -2, nil, nil, nil, nil, nil, 6,
|
82
|
+
nil, 14, 29, nil, 17, -17, nil, 178, 5, nil,
|
83
|
+
nil, -9, 0, 72, -8, 86, 192, 49, 85, 96,
|
84
|
+
97, 98, 123, nil, nil, nil, nil, nil, nil, 124,
|
85
|
+
nil, nil, 37, 60, nil, 31, 23, 153, 162, 29,
|
86
|
+
39, 66, nil, 46, 49, 34, 61, -1, -11, 55,
|
87
|
+
68, 59, 134, nil, -2, nil, nil, nil, nil, nil,
|
88
|
+
nil, nil, nil, nil, nil, 64, 121, nil, nil, nil,
|
89
|
+
nil, nil, nil, nil, 69, nil, 84, 88, nil, nil,
|
90
|
+
126, 94, 149, 179, 92, nil, nil, nil, nil, nil,
|
91
|
+
nil, nil, nil, nil, nil, nil, 95, nil, nil, nil,
|
92
92
|
nil ]
|
93
93
|
|
94
94
|
racc_action_default = [
|
@@ -106,26 +106,26 @@ racc_action_default = [
|
|
106
106
|
-41 ]
|
107
107
|
|
108
108
|
racc_goto_table = [
|
109
|
-
53, 38, 13, 1,
|
110
|
-
|
111
|
-
62,
|
109
|
+
53, 38, 13, 1, 42, 48, 62, 37, 34, 65,
|
110
|
+
40, 36, 63, 75, 84, 67, 68, 69, 70, 71,
|
111
|
+
62, 41, 50, 47, 54, nil, 63, nil, nil, 64,
|
112
112
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
113
113
|
nil, 72, 73, nil, nil, nil, nil, nil, nil, 97,
|
114
114
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
115
115
|
nil, nil, nil, nil, nil, nil, 105, nil, 107, 108 ]
|
116
116
|
|
117
117
|
racc_goto_check = [
|
118
|
-
18, 12, 2, 1,
|
119
|
-
|
120
|
-
7,
|
118
|
+
18, 12, 2, 1, 5, 9, 7, 8, 2, 9,
|
119
|
+
10, 2, 12, 17, 17, 12, 12, 12, 12, 12,
|
120
|
+
7, 11, 15, 16, 19, nil, 12, nil, nil, 1,
|
121
121
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
122
122
|
nil, 2, 2, nil, nil, nil, nil, nil, nil, 12,
|
123
123
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
124
124
|
nil, nil, nil, nil, nil, nil, 18, nil, 18, 18 ]
|
125
125
|
|
126
126
|
racc_goto_pointer = [
|
127
|
-
nil, 3, -1, nil, nil, -
|
128
|
-
6,
|
127
|
+
nil, 3, -1, nil, nil, -13, nil, -19, -7, -18,
|
128
|
+
-5, 6, -13, nil, nil, -1, 0, -34, -24, 0,
|
129
129
|
nil, nil, nil, nil ]
|
130
130
|
|
131
131
|
racc_goto_default = [
|
data/lib/nokogiri/version.rb
CHANGED
@@ -25,6 +25,17 @@ module Nokogiri
|
|
25
25
|
children.each { |child| child.parent = self }
|
26
26
|
end
|
27
27
|
|
28
|
+
if Nokogiri.uses_libxml?
|
29
|
+
def dup
|
30
|
+
new_document = document.dup
|
31
|
+
new_fragment = self.class.new(new_document)
|
32
|
+
children.each do |child|
|
33
|
+
child.dup(1, new_document).parent = new_fragment
|
34
|
+
end
|
35
|
+
new_fragment
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
28
39
|
###
|
29
40
|
# return the name for DocumentFragment
|
30
41
|
def name
|
data/lib/nokogiri/xml/node.rb
CHANGED
@@ -161,6 +161,18 @@ module Nokogiri
|
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
+
|
165
|
+
###
|
166
|
+
# Add html around this node
|
167
|
+
#
|
168
|
+
# Returns self
|
169
|
+
def wrap(html)
|
170
|
+
new_parent = document.parse(html).first
|
171
|
+
add_next_sibling(new_parent)
|
172
|
+
new_parent.add_child(self)
|
173
|
+
self
|
174
|
+
end
|
175
|
+
|
164
176
|
###
|
165
177
|
# Add +node_or_tags+ as a child of this Node.
|
166
178
|
# +node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
|
@@ -203,6 +203,7 @@ module Nokogiri
|
|
203
203
|
0.upto(length - 1) do |x|
|
204
204
|
yield self[x]
|
205
205
|
end
|
206
|
+
self
|
206
207
|
end
|
207
208
|
|
208
209
|
###
|
@@ -230,14 +231,9 @@ module Nokogiri
|
|
230
231
|
end
|
231
232
|
|
232
233
|
###
|
233
|
-
# Wrap this NodeSet with +html+
|
234
|
-
def wrap
|
235
|
-
|
236
|
-
new_parent = document.parse(html).first
|
237
|
-
j.add_next_sibling(new_parent)
|
238
|
-
new_parent.add_child(j)
|
239
|
-
end
|
240
|
-
self
|
234
|
+
# Wrap this NodeSet with +html+
|
235
|
+
def wrap html
|
236
|
+
map { |node| node.wrap html }
|
241
237
|
end
|
242
238
|
|
243
239
|
###
|