nokogiri 1.16.8-x86-mingw32 → 1.17.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +11 -21
- data/README.md +4 -0
- data/dependencies.yml +6 -6
- data/ext/nokogiri/extconf.rb +191 -137
- data/ext/nokogiri/gumbo.c +69 -53
- data/ext/nokogiri/html4_document.c +10 -4
- data/ext/nokogiri/html4_element_description.c +18 -18
- data/ext/nokogiri/html4_sax_parser.c +40 -0
- data/ext/nokogiri/html4_sax_parser_context.c +48 -58
- data/ext/nokogiri/html4_sax_push_parser.c +25 -24
- data/ext/nokogiri/include/libexslt/exsltconfig.h +3 -3
- data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +12 -19
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +1 -12
- data/ext/nokogiri/include/libxml2/libxml/debugXML.h +1 -1
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +9 -0
- data/ext/nokogiri/include/libxml2/libxml/entities.h +12 -1
- data/ext/nokogiri/include/libxml2/libxml/hash.h +19 -0
- data/ext/nokogiri/include/libxml2/libxml/list.h +2 -2
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +17 -0
- data/ext/nokogiri/include/libxml2/libxml/parser.h +60 -54
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +9 -1
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +6 -0
- data/ext/nokogiri/include/libxml2/libxml/tree.h +32 -12
- data/ext/nokogiri/include/libxml2/libxml/uri.h +11 -0
- data/ext/nokogiri/include/libxml2/libxml/valid.h +29 -2
- data/ext/nokogiri/include/libxml2/libxml/xinclude.h +7 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +21 -4
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +14 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +111 -15
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +8 -45
- data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +2 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +5 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +165 -1
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +7 -171
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +1 -0
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +4 -0
- data/ext/nokogiri/include/libxslt/xsltInternals.h +3 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +4 -37
- data/ext/nokogiri/libxml2_polyfill.c +114 -0
- data/ext/nokogiri/nokogiri.c +9 -2
- data/ext/nokogiri/nokogiri.h +18 -33
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_cdata.c +2 -10
- data/ext/nokogiri/xml_comment.c +3 -8
- data/ext/nokogiri/xml_document.c +163 -156
- data/ext/nokogiri/xml_document_fragment.c +10 -25
- data/ext/nokogiri/xml_dtd.c +1 -1
- data/ext/nokogiri/xml_element_content.c +9 -9
- data/ext/nokogiri/xml_encoding_handler.c +4 -4
- data/ext/nokogiri/xml_namespace.c +6 -6
- data/ext/nokogiri/xml_node.c +130 -104
- data/ext/nokogiri/xml_node_set.c +46 -44
- data/ext/nokogiri/xml_reader.c +54 -58
- data/ext/nokogiri/xml_relax_ng.c +35 -56
- data/ext/nokogiri/xml_sax_parser.c +156 -88
- data/ext/nokogiri/xml_sax_parser_context.c +213 -131
- data/ext/nokogiri/xml_sax_push_parser.c +68 -49
- data/ext/nokogiri/xml_schema.c +50 -85
- data/ext/nokogiri/xml_syntax_error.c +19 -11
- data/ext/nokogiri/xml_text.c +2 -4
- data/ext/nokogiri/xml_xpath_context.c +2 -2
- data/ext/nokogiri/xslt_stylesheet.c +8 -8
- data/lib/nokogiri/3.0/nokogiri.so +0 -0
- data/lib/nokogiri/3.1/nokogiri.so +0 -0
- data/lib/nokogiri/3.2/nokogiri.so +0 -0
- data/lib/nokogiri/3.3/nokogiri.so +0 -0
- data/lib/nokogiri/class_resolver.rb +1 -1
- data/lib/nokogiri/css/node.rb +6 -2
- data/lib/nokogiri/css/parser.rb +6 -4
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/parser_extras.rb +6 -66
- data/lib/nokogiri/css/selector_cache.rb +38 -0
- data/lib/nokogiri/css/tokenizer.rb +4 -4
- data/lib/nokogiri/css/tokenizer.rex +9 -8
- data/lib/nokogiri/css/xpath_visitor.rb +42 -6
- data/lib/nokogiri/css.rb +86 -20
- data/lib/nokogiri/decorators/slop.rb +3 -5
- data/lib/nokogiri/encoding_handler.rb +2 -2
- data/lib/nokogiri/html4/document.rb +44 -23
- data/lib/nokogiri/html4/document_fragment.rb +124 -12
- data/lib/nokogiri/html4/encoding_reader.rb +1 -1
- data/lib/nokogiri/html4/sax/parser.rb +23 -38
- data/lib/nokogiri/html4/sax/parser_context.rb +4 -9
- data/lib/nokogiri/html4.rb +9 -14
- data/lib/nokogiri/html5/builder.rb +40 -0
- data/lib/nokogiri/html5/document.rb +61 -30
- data/lib/nokogiri/html5/document_fragment.rb +130 -20
- data/lib/nokogiri/html5/node.rb +4 -4
- data/lib/nokogiri/html5.rb +114 -72
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +8 -1
- data/lib/nokogiri/xml/document.rb +70 -26
- data/lib/nokogiri/xml/document_fragment.rb +84 -13
- data/lib/nokogiri/xml/node.rb +82 -11
- data/lib/nokogiri/xml/node_set.rb +9 -7
- data/lib/nokogiri/xml/parse_options.rb +1 -1
- data/lib/nokogiri/xml/pp/node.rb +6 -1
- data/lib/nokogiri/xml/reader.rb +46 -13
- data/lib/nokogiri/xml/relax_ng.rb +57 -20
- data/lib/nokogiri/xml/sax/document.rb +174 -83
- data/lib/nokogiri/xml/sax/parser.rb +115 -41
- data/lib/nokogiri/xml/sax/parser_context.rb +116 -8
- data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
- data/lib/nokogiri/xml/sax.rb +48 -0
- data/lib/nokogiri/xml/schema.rb +112 -45
- data/lib/nokogiri/xml/searchable.rb +6 -8
- data/lib/nokogiri/xml/syntax_error.rb +22 -0
- data/lib/nokogiri/xml.rb +13 -24
- data/lib/nokogiri/xslt.rb +3 -9
- data/lib/xsd/xmlparser/nokogiri.rb +3 -4
- metadata +8 -4
- data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
@@ -0,0 +1,114 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
#ifndef HAVE_XMLCTXTSETOPTIONS
|
4
|
+
/* based on libxml2-2.14.0-dev (1d8bd126) parser.c xmlCtxtSetInternalOptions */
|
5
|
+
int
|
6
|
+
xmlCtxtSetOptions(xmlParserCtxtPtr ctxt, int options)
|
7
|
+
{
|
8
|
+
int keepMask = 0;
|
9
|
+
int allMask;
|
10
|
+
|
11
|
+
if (ctxt == NULL) {
|
12
|
+
return (-1);
|
13
|
+
}
|
14
|
+
|
15
|
+
/*
|
16
|
+
* XInclude options aren't handled by the parser.
|
17
|
+
*
|
18
|
+
* XML_PARSE_XINCLUDE
|
19
|
+
* XML_PARSE_NOXINCNODE
|
20
|
+
* XML_PARSE_NOBASEFIX
|
21
|
+
*/
|
22
|
+
allMask = XML_PARSE_RECOVER |
|
23
|
+
XML_PARSE_NOENT |
|
24
|
+
XML_PARSE_DTDLOAD |
|
25
|
+
XML_PARSE_DTDATTR |
|
26
|
+
XML_PARSE_DTDVALID |
|
27
|
+
XML_PARSE_NOERROR |
|
28
|
+
XML_PARSE_NOWARNING |
|
29
|
+
XML_PARSE_PEDANTIC |
|
30
|
+
XML_PARSE_NOBLANKS |
|
31
|
+
#ifdef LIBXML_SAX1_ENABLED
|
32
|
+
XML_PARSE_SAX1 |
|
33
|
+
#endif
|
34
|
+
XML_PARSE_NONET |
|
35
|
+
XML_PARSE_NODICT |
|
36
|
+
XML_PARSE_NSCLEAN |
|
37
|
+
XML_PARSE_NOCDATA |
|
38
|
+
XML_PARSE_COMPACT |
|
39
|
+
XML_PARSE_OLD10 |
|
40
|
+
XML_PARSE_HUGE |
|
41
|
+
XML_PARSE_OLDSAX |
|
42
|
+
XML_PARSE_IGNORE_ENC |
|
43
|
+
XML_PARSE_BIG_LINES;
|
44
|
+
|
45
|
+
ctxt->options = (ctxt->options & keepMask) | (options & allMask);
|
46
|
+
|
47
|
+
/*
|
48
|
+
* For some options, struct members are historically the source
|
49
|
+
* of truth. The values are initalized from global variables and
|
50
|
+
* old code could also modify them directly. Several older API
|
51
|
+
* functions that don't take an options argument rely on these
|
52
|
+
* deprecated mechanisms.
|
53
|
+
*
|
54
|
+
* Once public access to struct members and the globals are
|
55
|
+
* disabled, we can use the options bitmask as source of
|
56
|
+
* truth, making all these struct members obsolete.
|
57
|
+
*
|
58
|
+
* The XML_DETECT_IDS flags is misnamed. It simply enables
|
59
|
+
* loading of the external subset.
|
60
|
+
*/
|
61
|
+
ctxt->recovery = (options & XML_PARSE_RECOVER) ? 1 : 0;
|
62
|
+
ctxt->replaceEntities = (options & XML_PARSE_NOENT) ? 1 : 0;
|
63
|
+
ctxt->loadsubset = (options & XML_PARSE_DTDLOAD) ? XML_DETECT_IDS : 0;
|
64
|
+
ctxt->loadsubset |= (options & XML_PARSE_DTDATTR) ? XML_COMPLETE_ATTRS : 0;
|
65
|
+
ctxt->validate = (options & XML_PARSE_DTDVALID) ? 1 : 0;
|
66
|
+
ctxt->pedantic = (options & XML_PARSE_PEDANTIC) ? 1 : 0;
|
67
|
+
ctxt->keepBlanks = (options & XML_PARSE_NOBLANKS) ? 0 : 1;
|
68
|
+
ctxt->dictNames = (options & XML_PARSE_NODICT) ? 0 : 1;
|
69
|
+
|
70
|
+
/*
|
71
|
+
* Changing SAX callbacks is a bad idea. This should be fixed.
|
72
|
+
*/
|
73
|
+
if (options & XML_PARSE_NOBLANKS) {
|
74
|
+
ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
|
75
|
+
}
|
76
|
+
if (options & XML_PARSE_NOCDATA) {
|
77
|
+
ctxt->sax->cdataBlock = NULL;
|
78
|
+
}
|
79
|
+
if (options & XML_PARSE_HUGE) {
|
80
|
+
if (ctxt->dict != NULL) {
|
81
|
+
xmlDictSetLimit(ctxt->dict, 0);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
ctxt->linenumbers = 1;
|
86
|
+
|
87
|
+
return (options & ~allMask);
|
88
|
+
}
|
89
|
+
#endif
|
90
|
+
|
91
|
+
#ifndef HAVE_XMLCTXTGETOPTIONS
|
92
|
+
int
|
93
|
+
xmlCtxtGetOptions(xmlParserCtxtPtr ctxt)
|
94
|
+
{
|
95
|
+
return (ctxt->options);
|
96
|
+
}
|
97
|
+
#endif
|
98
|
+
|
99
|
+
#ifndef HAVE_XMLSWITCHENCODINGNAME
|
100
|
+
int
|
101
|
+
xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding)
|
102
|
+
{
|
103
|
+
if (ctxt == NULL) {
|
104
|
+
return (-1);
|
105
|
+
}
|
106
|
+
|
107
|
+
xmlCharEncodingHandlerPtr handler = xmlFindCharEncodingHandler(encoding);
|
108
|
+
if (handler == NULL) {
|
109
|
+
return (-1);
|
110
|
+
}
|
111
|
+
|
112
|
+
return (xmlSwitchToEncoding(ctxt, handler));
|
113
|
+
}
|
114
|
+
#endif
|
data/ext/nokogiri/nokogiri.c
CHANGED
@@ -46,6 +46,7 @@ void noko_init_html_element_description(void);
|
|
46
46
|
void noko_init_html_entity_lookup(void);
|
47
47
|
void noko_init_html_sax_parser_context(void);
|
48
48
|
void noko_init_html_sax_push_parser(void);
|
49
|
+
void noko_init_html4_sax_parser(void);
|
49
50
|
void noko_init_gumbo(void);
|
50
51
|
void noko_init_test_global_handlers(void);
|
51
52
|
|
@@ -184,8 +185,8 @@ Init_nokogiri(void)
|
|
184
185
|
{
|
185
186
|
mNokogiri = rb_define_module("Nokogiri");
|
186
187
|
mNokogiriGumbo = rb_define_module_under(mNokogiri, "Gumbo");
|
187
|
-
mNokogiriHtml4
|
188
|
-
mNokogiriHtml4Sax
|
188
|
+
mNokogiriHtml4 = rb_define_module_under(mNokogiri, "HTML4");
|
189
|
+
mNokogiriHtml4Sax = rb_define_module_under(mNokogiriHtml4, "SAX");
|
189
190
|
mNokogiriHtml5 = rb_define_module_under(mNokogiri, "HTML5");
|
190
191
|
mNokogiriXml = rb_define_module_under(mNokogiri, "XML");
|
191
192
|
mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX");
|
@@ -202,6 +203,9 @@ Init_nokogiri(void)
|
|
202
203
|
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
|
203
204
|
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));
|
204
205
|
|
206
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_ZLIB_ENABLED"),
|
207
|
+
xmlHasFeature(XML_WITH_ZLIB) == 1 ? Qtrue : Qfalse);
|
208
|
+
|
205
209
|
#ifdef NOKOGIRI_PACKAGED_LIBRARIES
|
206
210
|
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
|
207
211
|
# ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
|
@@ -244,7 +248,10 @@ Init_nokogiri(void)
|
|
244
248
|
noko_init_xml_namespace();
|
245
249
|
noko_init_xml_node_set();
|
246
250
|
noko_init_xml_reader();
|
251
|
+
|
247
252
|
noko_init_xml_sax_parser();
|
253
|
+
noko_init_html4_sax_parser();
|
254
|
+
|
248
255
|
noko_init_xml_xpath_context();
|
249
256
|
noko_init_xslt_stylesheet();
|
250
257
|
noko_init_html_element_description();
|
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -56,11 +56,15 @@
|
|
56
56
|
|
57
57
|
#include <libexslt/exslt.h>
|
58
58
|
|
59
|
-
/*
|
60
|
-
#ifndef
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
/* libxml2_polyfill.c */
|
60
|
+
#ifndef HAVE_XMLCTXTSETOPTIONS
|
61
|
+
int xmlCtxtSetOptions(xmlParserCtxtPtr ctxt, int options);
|
62
|
+
#endif
|
63
|
+
#ifndef HAVE_XMLCTXTGETOPTIONS
|
64
|
+
int xmlCtxtGetOptions(xmlParserCtxtPtr ctxt);
|
65
|
+
#endif
|
66
|
+
#ifndef HAVE_XMLSWITCHENCODINGNAME
|
67
|
+
int xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding);
|
64
68
|
#endif
|
65
69
|
|
66
70
|
#define XMLNS_PREFIX "xmlns"
|
@@ -148,6 +152,7 @@ NOKOPUBVAR VALUE cNokogiriXsltStylesheet ;
|
|
148
152
|
NOKOPUBVAR VALUE cNokogiriHtml4Document ;
|
149
153
|
NOKOPUBVAR VALUE cNokogiriHtml4SaxPushParser ;
|
150
154
|
NOKOPUBVAR VALUE cNokogiriHtml4ElementDescription ;
|
155
|
+
NOKOPUBVAR VALUE cNokogiriHtml4SaxParser;
|
151
156
|
NOKOPUBVAR VALUE cNokogiriHtml4SaxParserContext;
|
152
157
|
NOKOPUBVAR VALUE cNokogiriHtml5Document ;
|
153
158
|
|
@@ -158,12 +163,6 @@ typedef struct _nokogiriTuple {
|
|
158
163
|
} nokogiriTuple;
|
159
164
|
typedef nokogiriTuple *nokogiriTuplePtr;
|
160
165
|
|
161
|
-
typedef struct _nokogiriSAXTuple {
|
162
|
-
xmlParserCtxtPtr ctxt;
|
163
|
-
VALUE self;
|
164
|
-
} nokogiriSAXTuple;
|
165
|
-
typedef nokogiriSAXTuple *nokogiriSAXTuplePtr;
|
166
|
-
|
167
166
|
typedef struct _libxmlStructuredErrorHandlerState {
|
168
167
|
void *user_data;
|
169
168
|
xmlStructuredErrorFunc handler;
|
@@ -203,12 +202,13 @@ xmlDocPtr noko_xml_document_unwrap(VALUE rb_document);
|
|
203
202
|
NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass,
|
204
203
|
xmlDocPtr doc); /* deprecated. use noko_xml_document_wrap() instead. */
|
205
204
|
|
206
|
-
xmlSAXHandlerPtr
|
205
|
+
xmlSAXHandlerPtr noko_xml_sax_parser_unwrap(VALUE rb_sax_handler);
|
207
206
|
|
208
207
|
xmlParserCtxtPtr noko_xml_sax_push_parser_unwrap(VALUE rb_parser);
|
209
208
|
|
210
209
|
VALUE noko_xml_sax_parser_context_wrap(VALUE klass, xmlParserCtxtPtr c_context);
|
211
210
|
xmlParserCtxtPtr noko_xml_sax_parser_context_unwrap(VALUE rb_context);
|
211
|
+
void noko_xml_sax_parser_context_set_encoding(xmlParserCtxtPtr c_context, VALUE rb_encoding);
|
212
212
|
|
213
213
|
#define DOC_RUBY_OBJECT_TEST(x) ((nokogiriTuplePtr)(x->_private))
|
214
214
|
#define DOC_RUBY_OBJECT(x) (((nokogiriTuplePtr)(x->_private))->doc)
|
@@ -216,11 +216,6 @@ xmlParserCtxtPtr noko_xml_sax_parser_context_unwrap(VALUE rb_context);
|
|
216
216
|
#define DOC_NODE_CACHE(x) (((nokogiriTuplePtr)(x->_private))->node_cache)
|
217
217
|
#define NOKOGIRI_NAMESPACE_EH(node) ((node)->type == XML_NAMESPACE_DECL)
|
218
218
|
|
219
|
-
#define NOKOGIRI_SAX_SELF(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->self
|
220
|
-
#define NOKOGIRI_SAX_CTXT(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->ctxt
|
221
|
-
#define NOKOGIRI_SAX_TUPLE_NEW(_ctxt, _self) nokogiri_sax_tuple_new(_ctxt, _self)
|
222
|
-
#define NOKOGIRI_SAX_TUPLE_DESTROY(_tuple) ruby_xfree(_tuple)
|
223
|
-
|
224
219
|
#define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v))
|
225
220
|
#define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v)
|
226
221
|
|
@@ -230,24 +225,14 @@ xmlParserCtxtPtr noko_xml_sax_parser_context_unwrap(VALUE rb_context);
|
|
230
225
|
# define NOKO_WARN_DEPRECATION(message...) rb_warning(message)
|
231
226
|
#endif
|
232
227
|
|
233
|
-
void
|
234
|
-
void
|
228
|
+
void noko__structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state);
|
229
|
+
void noko__structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data,
|
235
230
|
xmlStructuredErrorFunc handler);
|
236
|
-
void
|
237
|
-
VALUE
|
238
|
-
void
|
239
|
-
NORETURN_DECL void
|
231
|
+
void noko__structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state);
|
232
|
+
VALUE noko_xml_syntax_error__wrap(xmlErrorConstPtr error);
|
233
|
+
void noko__error_array_pusher(void *ctx, xmlErrorConstPtr error);
|
234
|
+
NORETURN_DECL void noko__error_raise(void *ctx, xmlErrorConstPtr error);
|
240
235
|
void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, int nargs, VALUE handler,
|
241
236
|
const char *function_name) ;
|
242
237
|
|
243
|
-
static inline
|
244
|
-
nokogiriSAXTuplePtr
|
245
|
-
nokogiri_sax_tuple_new(xmlParserCtxtPtr ctxt, VALUE self)
|
246
|
-
{
|
247
|
-
nokogiriSAXTuplePtr tuple = ruby_xmalloc(sizeof(nokogiriSAXTuple));
|
248
|
-
tuple->self = self;
|
249
|
-
tuple->ctxt = ctxt;
|
250
|
-
return tuple;
|
251
|
-
}
|
252
|
-
|
253
238
|
#endif /* NOKOGIRI_NATIVE */
|
data/ext/nokogiri/xml_attr.c
CHANGED
@@ -6,7 +6,7 @@ VALUE cNokogiriXmlAttr;
|
|
6
6
|
* call-seq:
|
7
7
|
* value=(content)
|
8
8
|
*
|
9
|
-
* Set the value for this Attr to +content+. Use
|
9
|
+
* Set the value for this Attr to +content+. Use +nil+ to remove the value
|
10
10
|
* (e.g., a HTML boolean attribute).
|
11
11
|
*/
|
12
12
|
static VALUE
|
data/ext/nokogiri/xml_cdata.c
CHANGED
@@ -20,11 +20,10 @@ rb_xml_cdata_s_new(int argc, VALUE *argv, VALUE klass)
|
|
20
20
|
VALUE rb_content;
|
21
21
|
VALUE rb_rest;
|
22
22
|
VALUE rb_node;
|
23
|
-
xmlChar *c_content = NULL;
|
24
|
-
int c_content_len = 0;
|
25
23
|
|
26
24
|
rb_scan_args(argc, argv, "2*", &rb_document, &rb_content, &rb_rest);
|
27
25
|
|
26
|
+
Check_Type(rb_content, T_STRING);
|
28
27
|
if (!rb_obj_is_kind_of(rb_document, cNokogiriXmlNode)) {
|
29
28
|
rb_raise(rb_eTypeError,
|
30
29
|
"expected first parameter to be a Nokogiri::XML::Document, received %"PRIsVALUE,
|
@@ -40,15 +39,8 @@ rb_xml_cdata_s_new(int argc, VALUE *argv, VALUE klass)
|
|
40
39
|
c_document = noko_xml_document_unwrap(rb_document);
|
41
40
|
}
|
42
41
|
|
43
|
-
|
44
|
-
c_content = (xmlChar *)StringValuePtr(rb_content);
|
45
|
-
c_content_len = RSTRING_LENINT(rb_content);
|
46
|
-
}
|
47
|
-
|
48
|
-
c_node = xmlNewCDataBlock(c_document, c_content, c_content_len);
|
49
|
-
|
42
|
+
c_node = xmlNewCDataBlock(c_document, (xmlChar *)StringValueCStr(rb_content), RSTRING_LENINT(rb_content));
|
50
43
|
noko_xml_document_pin_node(c_node);
|
51
|
-
|
52
44
|
rb_node = noko_xml_node_wrap(klass, c_node);
|
53
45
|
rb_obj_call_init(rb_node, argc, argv);
|
54
46
|
|
data/ext/nokogiri/xml_comment.c
CHANGED
@@ -23,25 +23,20 @@ new (int argc, VALUE *argv, VALUE klass)
|
|
23
23
|
|
24
24
|
rb_scan_args(argc, argv, "2*", &document, &content, &rest);
|
25
25
|
|
26
|
+
Check_Type(content, T_STRING);
|
26
27
|
if (rb_obj_is_kind_of(document, cNokogiriXmlNode)) {
|
27
28
|
document = rb_funcall(document, document_id, 0);
|
28
29
|
} else if (!rb_obj_is_kind_of(document, cNokogiriXmlDocument)
|
29
30
|
&& !rb_obj_is_kind_of(document, cNokogiriXmlDocumentFragment)) {
|
30
31
|
rb_raise(rb_eArgError, "first argument must be a XML::Document or XML::Node");
|
31
32
|
}
|
32
|
-
|
33
33
|
xml_doc = noko_xml_document_unwrap(document);
|
34
34
|
|
35
|
-
node = xmlNewDocComment(
|
36
|
-
|
37
|
-
(const xmlChar *)StringValueCStr(content)
|
38
|
-
);
|
39
|
-
|
35
|
+
node = xmlNewDocComment(xml_doc, (const xmlChar *)StringValueCStr(content));
|
36
|
+
noko_xml_document_pin_node(node);
|
40
37
|
rb_node = noko_xml_node_wrap(klass, node);
|
41
38
|
rb_obj_call_init(rb_node, argc, argv);
|
42
39
|
|
43
|
-
noko_xml_document_pin_node(node);
|
44
|
-
|
45
40
|
if (rb_block_given_p()) { rb_yield(rb_node); }
|
46
41
|
|
47
42
|
return rb_node;
|