nokogiri 1.16.7 → 1.18.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/Gemfile +14 -22
- data/LICENSE-DEPENDENCIES.md +6 -6
- data/README.md +8 -5
- data/dependencies.yml +6 -6
- data/ext/nokogiri/extconf.rb +188 -142
- 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/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 +141 -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 +219 -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 +103 -100
- data/ext/nokogiri/xslt_stylesheet.c +8 -8
- data/gumbo-parser/src/ascii.c +2 -2
- data/gumbo-parser/src/error.c +76 -48
- data/gumbo-parser/src/error.h +5 -1
- data/gumbo-parser/src/nokogiri_gumbo.h +11 -2
- data/gumbo-parser/src/parser.c +63 -25
- data/gumbo-parser/src/tokenizer.c +6 -6
- 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 +38 -42
- data/lib/nokogiri/xml/syntax_error.rb +22 -0
- data/lib/nokogiri/xml/xpath_context.rb +14 -3
- data/lib/nokogiri/xml.rb +13 -24
- data/lib/nokogiri/xslt.rb +3 -9
- data/lib/xsd/xmlparser/nokogiri.rb +3 -4
- data/patches/libxml2/0019-xpath-Use-separate-static-hash-table-for-standard-fu.patch +244 -0
- data/ports/archives/libxml2-2.13.5.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.42.tar.xz +0 -0
- metadata +13 -14
- data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
- data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +0 -25
- data/ports/archives/libxml2-2.12.9.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.39.tar.xz +0 -0
@@ -3,13 +3,10 @@
|
|
3
3
|
VALUE cNokogiriHtml4SaxPushParser;
|
4
4
|
|
5
5
|
/*
|
6
|
-
* call-seq:
|
7
|
-
* native_write(chunk, last_chunk)
|
8
|
-
*
|
9
6
|
* Write +chunk+ to PushParser. +last_chunk+ triggers the end_document handle
|
10
7
|
*/
|
11
8
|
static VALUE
|
12
|
-
|
9
|
+
noko_html4_sax_push_parser__native_write(VALUE self, VALUE rb_chunk, VALUE rb_last_chunk)
|
13
10
|
{
|
14
11
|
xmlParserCtxtPtr ctx;
|
15
12
|
const char *chunk = NULL;
|
@@ -19,44 +16,45 @@ native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
|
|
19
16
|
|
20
17
|
ctx = noko_xml_sax_push_parser_unwrap(self);
|
21
18
|
|
22
|
-
if (Qnil !=
|
23
|
-
chunk = StringValuePtr(
|
24
|
-
size = (int)RSTRING_LEN(
|
19
|
+
if (Qnil != rb_chunk) {
|
20
|
+
chunk = StringValuePtr(rb_chunk);
|
21
|
+
size = (int)RSTRING_LEN(rb_chunk);
|
25
22
|
}
|
26
23
|
|
27
|
-
|
24
|
+
noko__structured_error_func_save_and_set(&handler_state, NULL, NULL);
|
28
25
|
|
29
|
-
status = htmlParseChunk(ctx, chunk, size, Qtrue ==
|
26
|
+
status = htmlParseChunk(ctx, chunk, size, Qtrue == rb_last_chunk ? 1 : 0);
|
30
27
|
|
31
|
-
|
28
|
+
noko__structured_error_func_restore(&handler_state);
|
32
29
|
|
33
|
-
if ((status != 0) && !(ctx
|
30
|
+
if ((status != 0) && !(xmlCtxtGetOptions(ctx) & XML_PARSE_RECOVER)) {
|
34
31
|
// TODO: there appear to be no tests for this block
|
35
32
|
xmlErrorConstPtr e = xmlCtxtGetLastError(ctx);
|
36
|
-
|
33
|
+
noko__error_raise(NULL, e);
|
37
34
|
}
|
38
35
|
|
39
36
|
return self;
|
40
37
|
}
|
41
38
|
|
42
39
|
/*
|
43
|
-
* call-seq:
|
44
|
-
* initialize_native(xml_sax, filename)
|
45
|
-
*
|
46
40
|
* Initialize the push parser with +xml_sax+ using +filename+
|
47
41
|
*/
|
48
42
|
static VALUE
|
49
|
-
|
50
|
-
|
43
|
+
noko_html4_sax_push_parser__initialize_native(
|
44
|
+
VALUE self,
|
45
|
+
VALUE rb_xml_sax,
|
46
|
+
VALUE rb_filename,
|
47
|
+
VALUE encoding
|
48
|
+
)
|
51
49
|
{
|
52
50
|
htmlSAXHandlerPtr sax;
|
53
51
|
const char *filename = NULL;
|
54
52
|
htmlParserCtxtPtr ctx;
|
55
53
|
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
56
54
|
|
57
|
-
sax =
|
55
|
+
sax = noko_xml_sax_parser_unwrap(rb_xml_sax);
|
58
56
|
|
59
|
-
if (
|
57
|
+
if (rb_filename != Qnil) { filename = StringValueCStr(rb_filename); }
|
60
58
|
|
61
59
|
if (!NIL_P(encoding)) {
|
62
60
|
enc = xmlParseCharEncoding(StringValueCStr(encoding));
|
@@ -77,9 +75,9 @@ initialize_native(VALUE self, VALUE _xml_sax, VALUE _filename,
|
|
77
75
|
rb_raise(rb_eRuntimeError, "Could not create a parser context");
|
78
76
|
}
|
79
77
|
|
80
|
-
ctx->userData =
|
78
|
+
ctx->userData = ctx;
|
79
|
+
ctx->_private = (void *)rb_xml_sax;
|
81
80
|
|
82
|
-
ctx->sax2 = 1;
|
83
81
|
DATA_PTR(self) = ctx;
|
84
82
|
return self;
|
85
83
|
}
|
@@ -88,8 +86,11 @@ void
|
|
88
86
|
noko_init_html_sax_push_parser(void)
|
89
87
|
{
|
90
88
|
assert(cNokogiriXmlSaxPushParser);
|
91
|
-
cNokogiriHtml4SaxPushParser =
|
89
|
+
cNokogiriHtml4SaxPushParser =
|
90
|
+
rb_define_class_under(mNokogiriHtml4Sax, "PushParser", cNokogiriXmlSaxPushParser);
|
92
91
|
|
93
|
-
rb_define_private_method(cNokogiriHtml4SaxPushParser, "initialize_native",
|
94
|
-
|
92
|
+
rb_define_private_method(cNokogiriHtml4SaxPushParser, "initialize_native",
|
93
|
+
noko_html4_sax_push_parser__initialize_native, 3);
|
94
|
+
rb_define_private_method(cNokogiriHtml4SaxPushParser, "native_write",
|
95
|
+
noko_html4_sax_push_parser__native_write, 2);
|
95
96
|
}
|
@@ -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;
|