nokogiri 1.13.10 → 1.14.3
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/Gemfile +39 -0
- data/LICENSE-DEPENDENCIES.md +830 -509
- data/LICENSE.md +1 -1
- data/README.md +18 -11
- data/dependencies.yml +28 -10
- data/ext/nokogiri/extconf.rb +82 -21
- data/ext/nokogiri/gumbo.c +20 -10
- data/ext/nokogiri/html4_document.c +2 -2
- data/ext/nokogiri/html4_element_description.c +1 -1
- data/ext/nokogiri/html4_entity_lookup.c +2 -2
- data/ext/nokogiri/html4_sax_parser_context.c +1 -6
- data/ext/nokogiri/html4_sax_push_parser.c +1 -1
- data/ext/nokogiri/nokogiri.c +38 -51
- data/ext/nokogiri/nokogiri.h +17 -14
- data/ext/nokogiri/test_global_handlers.c +1 -1
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_attribute_decl.c +2 -2
- data/ext/nokogiri/xml_cdata.c +2 -2
- data/ext/nokogiri/xml_comment.c +1 -1
- data/ext/nokogiri/xml_document.c +17 -12
- data/ext/nokogiri/xml_document_fragment.c +1 -1
- data/ext/nokogiri/xml_dtd.c +1 -1
- data/ext/nokogiri/xml_element_content.c +3 -3
- data/ext/nokogiri/xml_element_decl.c +2 -2
- data/ext/nokogiri/xml_encoding_handler.c +3 -3
- data/ext/nokogiri/xml_entity_decl.c +1 -1
- data/ext/nokogiri/xml_entity_reference.c +1 -1
- data/ext/nokogiri/xml_namespace.c +39 -9
- data/ext/nokogiri/xml_node.c +287 -27
- data/ext/nokogiri/xml_node_set.c +0 -2
- data/ext/nokogiri/xml_processing_instruction.c +1 -1
- data/ext/nokogiri/xml_reader.c +41 -21
- data/ext/nokogiri/xml_relax_ng.c +1 -3
- data/ext/nokogiri/xml_sax_parser.c +23 -17
- data/ext/nokogiri/xml_sax_parser_context.c +1 -6
- data/ext/nokogiri/xml_sax_push_parser.c +1 -3
- data/ext/nokogiri/xml_schema.c +1 -3
- data/ext/nokogiri/xml_syntax_error.c +1 -1
- data/ext/nokogiri/xml_text.c +1 -1
- data/ext/nokogiri/xml_xpath_context.c +87 -83
- data/ext/nokogiri/xslt_stylesheet.c +15 -14
- data/gumbo-parser/Makefile +10 -0
- data/gumbo-parser/src/attribute.h +1 -1
- data/gumbo-parser/src/error.c +2 -2
- data/gumbo-parser/src/error.h +1 -1
- data/gumbo-parser/src/foreign_attrs.c +2 -2
- data/gumbo-parser/src/{gumbo.h → nokogiri_gumbo.h} +1 -0
- data/gumbo-parser/src/parser.c +8 -5
- data/gumbo-parser/src/replacement.h +1 -1
- data/gumbo-parser/src/string_buffer.h +1 -1
- data/gumbo-parser/src/string_piece.c +1 -1
- data/gumbo-parser/src/svg_attrs.c +2 -2
- data/gumbo-parser/src/svg_tags.c +2 -2
- data/gumbo-parser/src/tag.c +2 -1
- data/gumbo-parser/src/tag_lookup.c +7 -7
- data/gumbo-parser/src/tag_lookup.gperf +1 -0
- data/gumbo-parser/src/tag_lookup.h +1 -1
- data/gumbo-parser/src/token_buffer.h +1 -1
- data/gumbo-parser/src/tokenizer.c +1 -1
- data/gumbo-parser/src/tokenizer.h +1 -1
- data/gumbo-parser/src/utf8.c +1 -1
- data/gumbo-parser/src/utf8.h +1 -1
- data/gumbo-parser/src/util.c +1 -3
- data/gumbo-parser/src/util.h +4 -0
- data/gumbo-parser/src/vector.h +1 -1
- data/lib/nokogiri/css/node.rb +2 -2
- data/lib/nokogiri/css/xpath_visitor.rb +5 -3
- data/lib/nokogiri/css.rb +6 -0
- data/lib/nokogiri/decorators/slop.rb +1 -1
- data/lib/nokogiri/encoding_handler.rb +57 -0
- data/lib/nokogiri/extension.rb +3 -2
- data/lib/nokogiri/html4/document.rb +2 -121
- data/lib/nokogiri/html4/element_description_defaults.rb +6 -12
- data/lib/nokogiri/html4/encoding_reader.rb +121 -0
- data/lib/nokogiri/html4.rb +1 -0
- data/lib/nokogiri/html5/document.rb +113 -36
- data/lib/nokogiri/html5/document_fragment.rb +9 -2
- data/lib/nokogiri/html5/node.rb +3 -5
- data/lib/nokogiri/html5.rb +127 -216
- data/lib/nokogiri/jruby/dependencies.rb +1 -19
- data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +11 -10
- data/lib/nokogiri/xml/attr.rb +49 -0
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +103 -55
- data/lib/nokogiri/xml/document_fragment.rb +49 -6
- data/lib/nokogiri/xml/namespace.rb +42 -0
- data/lib/nokogiri/xml/node/save_options.rb +6 -4
- data/lib/nokogiri/xml/node.rb +190 -35
- data/lib/nokogiri/xml/node_set.rb +88 -9
- data/lib/nokogiri/xml/parse_options.rb +129 -50
- data/lib/nokogiri/xml/pp/node.rb +6 -4
- data/lib/nokogiri/xml/processing_instruction.rb +2 -1
- data/lib/nokogiri/xml/sax/parser.rb +2 -3
- data/lib/nokogiri/xslt.rb +1 -1
- data/lib/nokogiri.rb +3 -11
- data/lib/xsd/xmlparser/nokogiri.rb +3 -1
- data/ports/archives/libxml2-2.10.4.tar.xz +0 -0
- metadata +12 -246
- data/patches/libxml2/0005-avoid-isnan-isinf.patch +0 -81
- data/ports/archives/libxml2-2.10.3.tar.xz +0 -0
data/ext/nokogiri/nokogiri.c
CHANGED
@@ -49,34 +49,11 @@ void noko_init_html_sax_push_parser(void);
|
|
49
49
|
void noko_init_gumbo(void);
|
50
50
|
void noko_init_test_global_handlers(void);
|
51
51
|
|
52
|
-
static ID id_read, id_write;
|
53
|
-
|
54
|
-
|
55
|
-
#ifndef HAVE_VASPRINTF
|
56
|
-
/*
|
57
|
-
* Thank you Geoffroy Couprie for this implementation of vasprintf!
|
58
|
-
*/
|
59
|
-
int
|
60
|
-
vasprintf(char **strp, const char *fmt, va_list ap)
|
61
|
-
{
|
62
|
-
/* Mingw32/64 have a broken vsnprintf implementation that fails when
|
63
|
-
* using a zero-byte limit in order to retrieve the required size for malloc.
|
64
|
-
* So we use a one byte buffer instead.
|
65
|
-
*/
|
66
|
-
char tmp[1];
|
67
|
-
int len = vsnprintf(tmp, 1, fmt, ap) + 1;
|
68
|
-
char *res = (char *)malloc((unsigned int)len);
|
69
|
-
if (res == NULL) {
|
70
|
-
return -1;
|
71
|
-
}
|
72
|
-
*strp = res;
|
73
|
-
return vsnprintf(res, (unsigned int)len, fmt, ap);
|
74
|
-
}
|
75
|
-
#endif
|
52
|
+
static ID id_read, id_write, id_external_encoding;
|
76
53
|
|
77
54
|
|
78
55
|
static VALUE
|
79
|
-
|
56
|
+
noko_io_read_check(VALUE val)
|
80
57
|
{
|
81
58
|
VALUE *args = (VALUE *)val;
|
82
59
|
return rb_funcall(args[0], id_read, 1, args[1]);
|
@@ -84,75 +61,84 @@ read_check(VALUE val)
|
|
84
61
|
|
85
62
|
|
86
63
|
static VALUE
|
87
|
-
|
64
|
+
noko_io_read_failed(VALUE arg, VALUE exc)
|
88
65
|
{
|
89
66
|
return Qundef;
|
90
67
|
}
|
91
68
|
|
92
69
|
|
93
70
|
int
|
94
|
-
noko_io_read(void *
|
71
|
+
noko_io_read(void *io, char *c_buffer, int c_buffer_len)
|
95
72
|
{
|
96
|
-
VALUE
|
97
|
-
|
73
|
+
VALUE rb_io = (VALUE)io;
|
74
|
+
VALUE rb_read_string, rb_args[2];
|
75
|
+
size_t n_bytes_read, safe_len;
|
98
76
|
|
99
|
-
|
100
|
-
|
77
|
+
rb_args[0] = rb_io;
|
78
|
+
rb_args[1] = INT2NUM(c_buffer_len);
|
101
79
|
|
102
|
-
|
80
|
+
rb_read_string = rb_rescue(noko_io_read_check, (VALUE)rb_args, noko_io_read_failed, 0);
|
103
81
|
|
104
|
-
if (NIL_P(
|
105
|
-
if (
|
106
|
-
if (TYPE(
|
82
|
+
if (NIL_P(rb_read_string)) { return 0; }
|
83
|
+
if (rb_read_string == Qundef) { return -1; }
|
84
|
+
if (TYPE(rb_read_string) != T_STRING) { return -1; }
|
107
85
|
|
108
|
-
|
109
|
-
safe_len =
|
110
|
-
memcpy(
|
86
|
+
n_bytes_read = (size_t)RSTRING_LEN(rb_read_string);
|
87
|
+
safe_len = (n_bytes_read > (size_t)c_buffer_len) ? (size_t)c_buffer_len : n_bytes_read;
|
88
|
+
memcpy(c_buffer, StringValuePtr(rb_read_string), safe_len);
|
111
89
|
|
112
90
|
return (int)safe_len;
|
113
91
|
}
|
114
92
|
|
115
93
|
|
116
94
|
static VALUE
|
117
|
-
|
95
|
+
noko_io_write_check(VALUE rb_args)
|
118
96
|
{
|
119
|
-
VALUE
|
120
|
-
|
97
|
+
VALUE rb_io = ((VALUE *)rb_args)[0];
|
98
|
+
VALUE rb_output = ((VALUE *)rb_args)[1];
|
99
|
+
return rb_funcall(rb_io, id_write, 1, rb_output);
|
121
100
|
}
|
122
101
|
|
123
102
|
|
124
103
|
static VALUE
|
125
|
-
|
104
|
+
noko_io_write_failed(VALUE arg, VALUE exc)
|
126
105
|
{
|
127
106
|
return Qundef;
|
128
107
|
}
|
129
108
|
|
130
109
|
|
131
110
|
int
|
132
|
-
noko_io_write(void *
|
111
|
+
noko_io_write(void *io, char *c_buffer, int c_buffer_len)
|
133
112
|
{
|
134
|
-
VALUE
|
113
|
+
VALUE rb_args[2], rb_n_bytes_written;
|
114
|
+
VALUE rb_io = (VALUE)io;
|
115
|
+
VALUE rb_enc = Qnil;
|
116
|
+
rb_encoding *io_encoding;
|
135
117
|
|
136
|
-
|
137
|
-
|
118
|
+
if (rb_respond_to(rb_io, id_external_encoding)) {
|
119
|
+
rb_enc = rb_funcall(rb_io, id_external_encoding, 0);
|
120
|
+
}
|
121
|
+
io_encoding = RB_NIL_P(rb_enc) ? rb_ascii8bit_encoding() : rb_to_encoding(rb_enc);
|
138
122
|
|
139
|
-
|
123
|
+
rb_args[0] = rb_io;
|
124
|
+
rb_args[1] = rb_enc_str_new(c_buffer, (long)c_buffer_len, io_encoding);
|
140
125
|
|
141
|
-
|
126
|
+
rb_n_bytes_written = rb_rescue(noko_io_write_check, (VALUE)rb_args, noko_io_write_failed, 0);
|
127
|
+
if (rb_n_bytes_written == Qundef) { return -1; }
|
142
128
|
|
143
|
-
return NUM2INT(
|
129
|
+
return NUM2INT(rb_n_bytes_written);
|
144
130
|
}
|
145
131
|
|
146
132
|
|
147
133
|
int
|
148
|
-
noko_io_close(void *
|
134
|
+
noko_io_close(void *io)
|
149
135
|
{
|
150
136
|
return 0;
|
151
137
|
}
|
152
138
|
|
153
139
|
|
154
140
|
void
|
155
|
-
Init_nokogiri()
|
141
|
+
Init_nokogiri(void)
|
156
142
|
{
|
157
143
|
mNokogiri = rb_define_module("Nokogiri");
|
158
144
|
mNokogiriGumbo = rb_define_module_under(mNokogiri, "Gumbo");
|
@@ -275,4 +261,5 @@ Init_nokogiri()
|
|
275
261
|
|
276
262
|
id_read = rb_intern("read");
|
277
263
|
id_write = rb_intern("write");
|
264
|
+
id_external_encoding = rb_intern("external_encoding");
|
278
265
|
}
|
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#ifndef NOKOGIRI_NATIVE
|
2
2
|
#define NOKOGIRI_NATIVE
|
3
3
|
|
4
|
+
#include <ruby/defines.h> // https://github.com/sparklemotion/nokogiri/issues/2696
|
5
|
+
|
4
6
|
#ifdef _MSC_VER
|
5
7
|
# ifndef WIN32_LEAN_AND_MEAN
|
6
8
|
# define WIN32_LEAN_AND_MEAN
|
@@ -23,7 +25,6 @@
|
|
23
25
|
# define NOKOPUBVAR extern
|
24
26
|
#endif
|
25
27
|
|
26
|
-
|
27
28
|
#include <stdlib.h>
|
28
29
|
#include <string.h>
|
29
30
|
#include <assert.h>
|
@@ -75,22 +76,25 @@ xmlNodePtr xmlLastElementChild(xmlNodePtr parent);
|
|
75
76
|
#define NOKOGIRI_STR_NEW(str, len) rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding())
|
76
77
|
#define RBSTR_OR_QNIL(_str) (_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
|
77
78
|
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#else
|
82
|
-
#
|
83
|
-
#
|
79
|
+
#ifndef NORETURN_DECL
|
80
|
+
# if defined(__GNUC__)
|
81
|
+
# define NORETURN_DECL __attribute__ ((noreturn))
|
82
|
+
# else
|
83
|
+
# define NORETURN_DECL
|
84
|
+
# endif
|
84
85
|
#endif
|
85
86
|
|
86
|
-
#ifndef
|
87
|
+
#ifndef PRINTFLIKE_DECL
|
87
88
|
# if defined(__GNUC__)
|
88
|
-
# define
|
89
|
+
# define PRINTFLIKE_DECL(stringidx, argidx) __attribute__ ((format(printf,stringidx,argidx)))
|
89
90
|
# else
|
90
|
-
# define
|
91
|
+
# define PRINTFLIKE_DECL(stringidx, argidx)
|
91
92
|
# endif
|
92
93
|
#endif
|
93
94
|
|
95
|
+
#if defined(TRUFFLERUBY) && !defined(NOKOGIRI_PACKAGED_LIBRARIES)
|
96
|
+
# define TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
|
97
|
+
#endif
|
94
98
|
|
95
99
|
NOKOPUBVAR VALUE mNokogiri ;
|
96
100
|
NOKOPUBVAR VALUE mNokogiriGumbo ;
|
@@ -162,7 +166,6 @@ typedef struct _nokogiriXsltStylesheetTuple {
|
|
162
166
|
VALUE func_instances;
|
163
167
|
} nokogiriXsltStylesheetTuple;
|
164
168
|
|
165
|
-
int vasprintf(char **strp, const char *fmt, va_list ap);
|
166
169
|
void noko_xml_document_pin_node(xmlNodePtr);
|
167
170
|
void noko_xml_document_pin_namespace(xmlNsPtr, xmlDocPtr);
|
168
171
|
|
@@ -198,7 +201,7 @@ NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass,
|
|
198
201
|
#define NOKOGIRI_SAX_SELF(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->self
|
199
202
|
#define NOKOGIRI_SAX_CTXT(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->ctxt
|
200
203
|
#define NOKOGIRI_SAX_TUPLE_NEW(_ctxt, _self) nokogiri_sax_tuple_new(_ctxt, _self)
|
201
|
-
#define NOKOGIRI_SAX_TUPLE_DESTROY(_tuple)
|
204
|
+
#define NOKOGIRI_SAX_TUPLE_DESTROY(_tuple) ruby_xfree(_tuple)
|
202
205
|
|
203
206
|
#define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v))
|
204
207
|
#define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v)
|
@@ -215,7 +218,7 @@ void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerSta
|
|
215
218
|
void Nokogiri_structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state);
|
216
219
|
VALUE Nokogiri_wrap_xml_syntax_error(xmlErrorPtr error);
|
217
220
|
void Nokogiri_error_array_pusher(void *ctx, xmlErrorPtr error);
|
218
|
-
|
221
|
+
NORETURN_DECL void Nokogiri_error_raise(void *ctx, xmlErrorPtr error);
|
219
222
|
void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, int nargs, VALUE handler,
|
220
223
|
const char *function_name) ;
|
221
224
|
|
@@ -223,7 +226,7 @@ static inline
|
|
223
226
|
nokogiriSAXTuplePtr
|
224
227
|
nokogiri_sax_tuple_new(xmlParserCtxtPtr ctxt, VALUE self)
|
225
228
|
{
|
226
|
-
nokogiriSAXTuplePtr tuple =
|
229
|
+
nokogiriSAXTuplePtr tuple = ruby_xmalloc(sizeof(nokogiriSAXTuple));
|
227
230
|
tuple->self = self;
|
228
231
|
tuple->ctxt = ctxt;
|
229
232
|
return tuple;
|
@@ -32,7 +32,7 @@ rb_foreign_error_handler(VALUE klass)
|
|
32
32
|
* Do NOT use this outside of the Nokogiri test suite.
|
33
33
|
*/
|
34
34
|
void
|
35
|
-
noko_init_test_global_handlers()
|
35
|
+
noko_init_test_global_handlers(void)
|
36
36
|
{
|
37
37
|
VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");
|
38
38
|
|
data/ext/nokogiri/xml_attr.c
CHANGED
@@ -13,7 +13,7 @@ attribute_type(VALUE self)
|
|
13
13
|
{
|
14
14
|
xmlAttributePtr node;
|
15
15
|
Noko_Node_Get_Struct(self, xmlAttribute, node);
|
16
|
-
return INT2NUM(
|
16
|
+
return INT2NUM(node->atype);
|
17
17
|
}
|
18
18
|
|
19
19
|
/*
|
@@ -59,7 +59,7 @@ enumeration(VALUE self)
|
|
59
59
|
}
|
60
60
|
|
61
61
|
void
|
62
|
-
noko_init_xml_attribute_decl()
|
62
|
+
noko_init_xml_attribute_decl(void)
|
63
63
|
{
|
64
64
|
assert(cNokogiriXmlNode);
|
65
65
|
cNokogiriXmlAttributeDecl = rb_define_class_under(mNokogiriXml, "AttributeDecl", cNokogiriXmlNode);
|
data/ext/nokogiri/xml_cdata.c
CHANGED
@@ -29,7 +29,7 @@ new (int argc, VALUE *argv, VALUE klass)
|
|
29
29
|
|
30
30
|
if (!NIL_P(content)) {
|
31
31
|
content_str = (xmlChar *)StringValuePtr(content);
|
32
|
-
content_str_len =
|
32
|
+
content_str_len = RSTRING_LENINT(content);
|
33
33
|
}
|
34
34
|
|
35
35
|
node = xmlNewCDataBlock(xml_doc->doc, content_str, content_str_len);
|
@@ -45,7 +45,7 @@ new (int argc, VALUE *argv, VALUE klass)
|
|
45
45
|
}
|
46
46
|
|
47
47
|
void
|
48
|
-
noko_init_xml_cdata()
|
48
|
+
noko_init_xml_cdata(void)
|
49
49
|
{
|
50
50
|
assert(cNokogiriXmlText);
|
51
51
|
/*
|
data/ext/nokogiri/xml_comment.c
CHANGED
data/ext/nokogiri/xml_document.c
CHANGED
@@ -65,14 +65,12 @@ dealloc(xmlDocPtr doc)
|
|
65
65
|
{
|
66
66
|
st_table *node_hash;
|
67
67
|
|
68
|
-
NOKOGIRI_DEBUG_START(doc);
|
69
|
-
|
70
68
|
node_hash = DOC_UNLINKED_NODE_HASH(doc);
|
71
69
|
|
72
70
|
st_foreach(node_hash, dealloc_node_i, (st_data_t)doc);
|
73
71
|
st_free_table(node_hash);
|
74
72
|
|
75
|
-
|
73
|
+
ruby_xfree(doc->_private);
|
76
74
|
|
77
75
|
/* When both Nokogiri and libxml-ruby are loaded, make sure that all nodes
|
78
76
|
* have their _private pointers cleared. This is to avoid libxml-ruby's
|
@@ -84,8 +82,6 @@ dealloc(xmlDocPtr doc)
|
|
84
82
|
}
|
85
83
|
|
86
84
|
xmlFreeDoc(doc);
|
87
|
-
|
88
|
-
NOKOGIRI_DEBUG_END(doc);
|
89
85
|
}
|
90
86
|
|
91
87
|
static void
|
@@ -540,6 +536,7 @@ rb_xml_document_canonicalize(int argc, VALUE *argv, VALUE self)
|
|
540
536
|
VALUE rb_mode;
|
541
537
|
VALUE rb_namespaces;
|
542
538
|
VALUE rb_comments_p;
|
539
|
+
int c_mode = 0;
|
543
540
|
xmlChar **c_namespaces;
|
544
541
|
|
545
542
|
xmlDocPtr c_doc;
|
@@ -551,8 +548,16 @@ rb_xml_document_canonicalize(int argc, VALUE *argv, VALUE self)
|
|
551
548
|
VALUE rb_io;
|
552
549
|
|
553
550
|
rb_scan_args(argc, argv, "03", &rb_mode, &rb_namespaces, &rb_comments_p);
|
554
|
-
if (!NIL_P(rb_mode)) {
|
555
|
-
|
551
|
+
if (!NIL_P(rb_mode)) {
|
552
|
+
Check_Type(rb_mode, T_FIXNUM);
|
553
|
+
c_mode = NUM2INT(rb_mode);
|
554
|
+
}
|
555
|
+
if (!NIL_P(rb_namespaces)) {
|
556
|
+
Check_Type(rb_namespaces, T_ARRAY);
|
557
|
+
if (c_mode == XML_C14N_1_0 || c_mode == XML_C14N_1_1) {
|
558
|
+
rb_raise(rb_eRuntimeError, "This canonicalizer does not support this operation");
|
559
|
+
}
|
560
|
+
}
|
556
561
|
|
557
562
|
Data_Get_Struct(self, xmlDoc, c_doc);
|
558
563
|
|
@@ -573,7 +578,7 @@ rb_xml_document_canonicalize(int argc, VALUE *argv, VALUE self)
|
|
573
578
|
c_namespaces = NULL;
|
574
579
|
} else {
|
575
580
|
long ns_len = RARRAY_LEN(rb_namespaces);
|
576
|
-
c_namespaces =
|
581
|
+
c_namespaces = ruby_xcalloc((size_t)ns_len + 1, sizeof(xmlChar *));
|
577
582
|
for (int j = 0 ; j < ns_len ; j++) {
|
578
583
|
VALUE entry = rb_ary_entry(rb_namespaces, j);
|
579
584
|
c_namespaces[j] = (xmlChar *)StringValueCStr(entry);
|
@@ -581,12 +586,12 @@ rb_xml_document_canonicalize(int argc, VALUE *argv, VALUE self)
|
|
581
586
|
}
|
582
587
|
|
583
588
|
xmlC14NExecute(c_doc, c_callback_wrapper, rb_callback,
|
584
|
-
|
589
|
+
c_mode,
|
585
590
|
c_namespaces,
|
586
591
|
(int)RTEST(rb_comments_p),
|
587
592
|
c_obuf);
|
588
593
|
|
589
|
-
|
594
|
+
ruby_xfree(c_namespaces);
|
590
595
|
xmlOutputBufferClose(c_obuf);
|
591
596
|
|
592
597
|
return rb_funcall(rb_io, rb_intern("string"), 0);
|
@@ -604,7 +609,7 @@ noko_xml_document_wrap_with_init_args(VALUE klass, xmlDocPtr c_document, int arg
|
|
604
609
|
|
605
610
|
rb_document = Data_Wrap_Struct(klass, mark, dealloc, c_document);
|
606
611
|
|
607
|
-
tuple = (nokogiriTuplePtr)
|
612
|
+
tuple = (nokogiriTuplePtr)ruby_xmalloc(sizeof(nokogiriTuple));
|
608
613
|
tuple->doc = rb_document;
|
609
614
|
tuple->unlinkedNodes = st_init_numtable_with_size(128);
|
610
615
|
tuple->node_cache = rb_ary_new();
|
@@ -659,7 +664,7 @@ noko_xml_document_pin_namespace(xmlNsPtr ns, xmlDocPtr doc)
|
|
659
664
|
|
660
665
|
|
661
666
|
void
|
662
|
-
noko_init_xml_document()
|
667
|
+
noko_init_xml_document(void)
|
663
668
|
{
|
664
669
|
assert(cNokogiriXmlNode);
|
665
670
|
/*
|
data/ext/nokogiri/xml_dtd.c
CHANGED
@@ -31,7 +31,7 @@ get_type(VALUE self)
|
|
31
31
|
xmlElementContentPtr elem;
|
32
32
|
Data_Get_Struct(self, xmlElementContent, elem);
|
33
33
|
|
34
|
-
return INT2NUM(
|
34
|
+
return INT2NUM(elem->type);
|
35
35
|
}
|
36
36
|
|
37
37
|
/*
|
@@ -79,7 +79,7 @@ get_occur(VALUE self)
|
|
79
79
|
xmlElementContentPtr elem;
|
80
80
|
Data_Get_Struct(self, xmlElementContent, elem);
|
81
81
|
|
82
|
-
return INT2NUM(
|
82
|
+
return INT2NUM(elem->ocur);
|
83
83
|
}
|
84
84
|
|
85
85
|
/*
|
@@ -112,7 +112,7 @@ noko_xml_element_content_wrap(VALUE doc, xmlElementContentPtr element)
|
|
112
112
|
}
|
113
113
|
|
114
114
|
void
|
115
|
-
noko_init_xml_element_content()
|
115
|
+
noko_init_xml_element_content(void)
|
116
116
|
{
|
117
117
|
cNokogiriXmlElementContent = rb_define_class_under(mNokogiriXml, "ElementContent", rb_cObject);
|
118
118
|
|
@@ -15,7 +15,7 @@ element_type(VALUE self)
|
|
15
15
|
{
|
16
16
|
xmlElementPtr node;
|
17
17
|
Noko_Node_Get_Struct(self, xmlElement, node);
|
18
|
-
return INT2NUM(
|
18
|
+
return INT2NUM(node->etype);
|
19
19
|
}
|
20
20
|
|
21
21
|
/*
|
@@ -56,7 +56,7 @@ prefix(VALUE self)
|
|
56
56
|
}
|
57
57
|
|
58
58
|
void
|
59
|
-
noko_init_xml_element_decl()
|
59
|
+
noko_init_xml_element_decl(void)
|
60
60
|
{
|
61
61
|
assert(cNokogiriXmlNode);
|
62
62
|
cNokogiriXmlElementDecl = rb_define_class_under(mNokogiriXml, "ElementDecl", cNokogiriXmlNode);
|
@@ -45,9 +45,9 @@ rb_xml_encoding_handler_s_delete(VALUE klass, VALUE name)
|
|
45
45
|
|
46
46
|
|
47
47
|
/*
|
48
|
-
* call-seq: Nokogiri::EncodingHandler.alias(
|
48
|
+
* call-seq: Nokogiri::EncodingHandler.alias(real_name, alias_name)
|
49
49
|
*
|
50
|
-
* Alias encoding handler with name +
|
50
|
+
* Alias encoding handler with name +real_name+ to name +alias_name+
|
51
51
|
*/
|
52
52
|
static VALUE
|
53
53
|
rb_xml_encoding_handler_s_alias(VALUE klass, VALUE from, VALUE to)
|
@@ -89,7 +89,7 @@ rb_xml_encoding_handler_name(VALUE self)
|
|
89
89
|
|
90
90
|
|
91
91
|
void
|
92
|
-
noko_init_xml_encoding_handler()
|
92
|
+
noko_init_xml_encoding_handler(void)
|
93
93
|
{
|
94
94
|
cNokogiriEncodingHandler = rb_define_class_under(mNokogiri, "EncodingHandler", rb_cObject);
|
95
95
|
|
@@ -32,7 +32,6 @@ _xml_namespace_dealloc(void *ptr)
|
|
32
32
|
* node set. see noko_xml_namespace_wrap().
|
33
33
|
*/
|
34
34
|
xmlNsPtr ns = ptr;
|
35
|
-
NOKOGIRI_DEBUG_START(ns) ;
|
36
35
|
|
37
36
|
if (ns->href) {
|
38
37
|
xmlFree(DISCARD_CONST_QUAL_XMLCHAR(ns->href));
|
@@ -41,7 +40,6 @@ _xml_namespace_dealloc(void *ptr)
|
|
41
40
|
xmlFree(DISCARD_CONST_QUAL_XMLCHAR(ns->prefix));
|
42
41
|
}
|
43
42
|
xmlFree(ns);
|
44
|
-
NOKOGIRI_DEBUG_END(ns) ;
|
45
43
|
}
|
46
44
|
|
47
45
|
#ifdef HAVE_RB_GC_LOCATION
|
@@ -76,10 +74,26 @@ static const rb_data_type_t nokogiri_xml_namespace_type_without_dealloc = {
|
|
76
74
|
};
|
77
75
|
|
78
76
|
/*
|
79
|
-
*
|
80
|
-
*
|
77
|
+
* :call-seq:
|
78
|
+
* prefix() → String or nil
|
81
79
|
*
|
82
|
-
*
|
80
|
+
* Return the prefix for this Namespace, or +nil+ if there is no prefix (e.g., default namespace).
|
81
|
+
*
|
82
|
+
* *Example*
|
83
|
+
*
|
84
|
+
* doc = Nokogiri::XML.parse(<<~XML)
|
85
|
+
* <?xml version="1.0"?>
|
86
|
+
* <root xmlns="http://nokogiri.org/ns/default" xmlns:noko="http://nokogiri.org/ns/noko">
|
87
|
+
* <child1 foo="abc" noko:bar="def"/>
|
88
|
+
* <noko:child2 foo="qwe" noko:bar="rty"/>
|
89
|
+
* </root>
|
90
|
+
* XML
|
91
|
+
*
|
92
|
+
* doc.root.elements.first.namespace.prefix
|
93
|
+
* # => nil
|
94
|
+
*
|
95
|
+
* doc.root.elements.last.namespace.prefix
|
96
|
+
* # => "noko"
|
83
97
|
*/
|
84
98
|
static VALUE
|
85
99
|
prefix(VALUE self)
|
@@ -93,10 +107,26 @@ prefix(VALUE self)
|
|
93
107
|
}
|
94
108
|
|
95
109
|
/*
|
96
|
-
*
|
97
|
-
*
|
110
|
+
* :call-seq:
|
111
|
+
* href() → String
|
112
|
+
*
|
113
|
+
* Returns the URI reference for this Namespace.
|
114
|
+
*
|
115
|
+
* *Example*
|
116
|
+
*
|
117
|
+
* doc = Nokogiri::XML.parse(<<~XML)
|
118
|
+
* <?xml version="1.0"?>
|
119
|
+
* <root xmlns="http://nokogiri.org/ns/default" xmlns:noko="http://nokogiri.org/ns/noko">
|
120
|
+
* <child1 foo="abc" noko:bar="def"/>
|
121
|
+
* <noko:child2 foo="qwe" noko:bar="rty"/>
|
122
|
+
* </root>
|
123
|
+
* XML
|
124
|
+
*
|
125
|
+
* doc.root.elements.first.namespace.href
|
126
|
+
* # => "http://nokogiri.org/ns/default"
|
98
127
|
*
|
99
|
-
*
|
128
|
+
* doc.root.elements.last.namespace.href
|
129
|
+
* # => "http://nokogiri.org/ns/noko"
|
100
130
|
*/
|
101
131
|
static VALUE
|
102
132
|
href(VALUE self)
|
@@ -145,7 +175,7 @@ noko_xml_namespace_wrap_xpath_copy(xmlNsPtr c_namespace)
|
|
145
175
|
}
|
146
176
|
|
147
177
|
void
|
148
|
-
noko_init_xml_namespace()
|
178
|
+
noko_init_xml_namespace(void)
|
149
179
|
{
|
150
180
|
cNokogiriXmlNamespace = rb_define_class_under(mNokogiriXml, "Namespace", rb_cObject);
|
151
181
|
|