nokogiri 1.15.4 → 1.17.2
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 +12 -19
- data/README.md +8 -1
- data/dependencies.yml +9 -8
- data/ext/nokogiri/extconf.rb +194 -141
- 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 +26 -25
- data/ext/nokogiri/libxml2_polyfill.c +114 -0
- data/ext/nokogiri/nokogiri.c +9 -2
- data/ext/nokogiri/nokogiri.h +25 -33
- data/ext/nokogiri/test_global_handlers.c +1 -1
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_cdata.c +3 -12
- data/ext/nokogiri/xml_comment.c +3 -8
- data/ext/nokogiri/xml_document.c +167 -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 -10
- data/ext/nokogiri/xml_node.c +142 -108
- data/ext/nokogiri/xml_node_set.c +46 -44
- data/ext/nokogiri/xml_reader.c +74 -100
- 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 +214 -128
- data/ext/nokogiri/xml_sax_push_parser.c +69 -50
- data/ext/nokogiri/xml_schema.c +51 -87
- data/ext/nokogiri/xml_syntax_error.c +19 -11
- data/ext/nokogiri/xml_text.c +3 -6
- data/ext/nokogiri/xml_xpath_context.c +4 -7
- data/ext/nokogiri/xslt_stylesheet.c +16 -11
- data/gumbo-parser/Makefile +18 -0
- 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 +64 -23
- data/gumbo-parser/src/tokenizer.c +7 -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 +43 -27
- 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 +45 -24
- data/lib/nokogiri/html4/document_fragment.rb +124 -12
- data/lib/nokogiri/html4/encoding_reader.rb +2 -2
- 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 -138
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +6 -5
- data/lib/nokogiri/xml/attr.rb +2 -2
- data/lib/nokogiri/xml/builder.rb +8 -1
- data/lib/nokogiri/xml/document.rb +74 -31
- data/lib/nokogiri/xml/document_fragment.rb +86 -15
- data/lib/nokogiri/xml/namespace.rb +1 -2
- data/lib/nokogiri/xml/node.rb +113 -35
- data/lib/nokogiri/xml/node_set.rb +12 -10
- data/lib/nokogiri/xml/parse_options.rb +1 -1
- data/lib/nokogiri/xml/pp/node.rb +6 -1
- data/lib/nokogiri/xml/reader.rb +51 -17
- 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 +9 -11
- data/lib/nokogiri/xml/syntax_error.rb +23 -1
- data/lib/nokogiri/xml.rb +14 -25
- data/lib/nokogiri/xslt/stylesheet.rb +29 -7
- data/lib/nokogiri/xslt.rb +4 -10
- data/lib/nokogiri.rb +1 -1
- data/lib/xsd/xmlparser/nokogiri.rb +3 -4
- data/ports/archives/libxml2-2.13.5.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.42.tar.xz +0 -0
- metadata +15 -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.11.5.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.38.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
|
-
|
36
|
-
|
32
|
+
xmlErrorConstPtr e = xmlCtxtGetLastError(ctx);
|
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,16 +56,27 @@
|
|
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"
|
67
71
|
#define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */
|
68
72
|
|
73
|
+
#ifndef xmlErrorConstPtr
|
74
|
+
# if LIBXML_VERSION >= 21200
|
75
|
+
# define xmlErrorConstPtr const xmlError *
|
76
|
+
# else
|
77
|
+
# define xmlErrorConstPtr xmlError *
|
78
|
+
# endif
|
79
|
+
#endif
|
69
80
|
|
70
81
|
#include <ruby.h>
|
71
82
|
#include <ruby/st.h>
|
@@ -141,6 +152,7 @@ NOKOPUBVAR VALUE cNokogiriXsltStylesheet ;
|
|
141
152
|
NOKOPUBVAR VALUE cNokogiriHtml4Document ;
|
142
153
|
NOKOPUBVAR VALUE cNokogiriHtml4SaxPushParser ;
|
143
154
|
NOKOPUBVAR VALUE cNokogiriHtml4ElementDescription ;
|
155
|
+
NOKOPUBVAR VALUE cNokogiriHtml4SaxParser;
|
144
156
|
NOKOPUBVAR VALUE cNokogiriHtml4SaxParserContext;
|
145
157
|
NOKOPUBVAR VALUE cNokogiriHtml5Document ;
|
146
158
|
|
@@ -151,12 +163,6 @@ typedef struct _nokogiriTuple {
|
|
151
163
|
} nokogiriTuple;
|
152
164
|
typedef nokogiriTuple *nokogiriTuplePtr;
|
153
165
|
|
154
|
-
typedef struct _nokogiriSAXTuple {
|
155
|
-
xmlParserCtxtPtr ctxt;
|
156
|
-
VALUE self;
|
157
|
-
} nokogiriSAXTuple;
|
158
|
-
typedef nokogiriSAXTuple *nokogiriSAXTuplePtr;
|
159
|
-
|
160
166
|
typedef struct _libxmlStructuredErrorHandlerState {
|
161
167
|
void *user_data;
|
162
168
|
xmlStructuredErrorFunc handler;
|
@@ -196,12 +202,13 @@ xmlDocPtr noko_xml_document_unwrap(VALUE rb_document);
|
|
196
202
|
NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass,
|
197
203
|
xmlDocPtr doc); /* deprecated. use noko_xml_document_wrap() instead. */
|
198
204
|
|
199
|
-
xmlSAXHandlerPtr
|
205
|
+
xmlSAXHandlerPtr noko_xml_sax_parser_unwrap(VALUE rb_sax_handler);
|
200
206
|
|
201
207
|
xmlParserCtxtPtr noko_xml_sax_push_parser_unwrap(VALUE rb_parser);
|
202
208
|
|
203
209
|
VALUE noko_xml_sax_parser_context_wrap(VALUE klass, xmlParserCtxtPtr c_context);
|
204
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);
|
205
212
|
|
206
213
|
#define DOC_RUBY_OBJECT_TEST(x) ((nokogiriTuplePtr)(x->_private))
|
207
214
|
#define DOC_RUBY_OBJECT(x) (((nokogiriTuplePtr)(x->_private))->doc)
|
@@ -209,11 +216,6 @@ xmlParserCtxtPtr noko_xml_sax_parser_context_unwrap(VALUE rb_context);
|
|
209
216
|
#define DOC_NODE_CACHE(x) (((nokogiriTuplePtr)(x->_private))->node_cache)
|
210
217
|
#define NOKOGIRI_NAMESPACE_EH(node) ((node)->type == XML_NAMESPACE_DECL)
|
211
218
|
|
212
|
-
#define NOKOGIRI_SAX_SELF(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->self
|
213
|
-
#define NOKOGIRI_SAX_CTXT(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->ctxt
|
214
|
-
#define NOKOGIRI_SAX_TUPLE_NEW(_ctxt, _self) nokogiri_sax_tuple_new(_ctxt, _self)
|
215
|
-
#define NOKOGIRI_SAX_TUPLE_DESTROY(_tuple) ruby_xfree(_tuple)
|
216
|
-
|
217
219
|
#define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v))
|
218
220
|
#define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v)
|
219
221
|
|
@@ -223,24 +225,14 @@ xmlParserCtxtPtr noko_xml_sax_parser_context_unwrap(VALUE rb_context);
|
|
223
225
|
# define NOKO_WARN_DEPRECATION(message...) rb_warning(message)
|
224
226
|
#endif
|
225
227
|
|
226
|
-
void
|
227
|
-
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,
|
228
230
|
xmlStructuredErrorFunc handler);
|
229
|
-
void
|
230
|
-
VALUE
|
231
|
-
void
|
232
|
-
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);
|
233
235
|
void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, int nargs, VALUE handler,
|
234
236
|
const char *function_name) ;
|
235
237
|
|
236
|
-
static inline
|
237
|
-
nokogiriSAXTuplePtr
|
238
|
-
nokogiri_sax_tuple_new(xmlParserCtxtPtr ctxt, VALUE self)
|
239
|
-
{
|
240
|
-
nokogiriSAXTuplePtr tuple = ruby_xmalloc(sizeof(nokogiriSAXTuple));
|
241
|
-
tuple->self = self;
|
242
|
-
tuple->ctxt = ctxt;
|
243
|
-
return tuple;
|
244
|
-
}
|
245
|
-
|
246
238
|
#endif /* NOKOGIRI_NATIVE */
|
@@ -3,7 +3,7 @@
|
|
3
3
|
static VALUE foreign_error_handler_block = Qnil;
|
4
4
|
|
5
5
|
static void
|
6
|
-
foreign_error_handler(void *user_data,
|
6
|
+
foreign_error_handler(void *user_data, xmlErrorConstPtr c_error)
|
7
7
|
{
|
8
8
|
rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
|
9
9
|
}
|
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,
|
@@ -33,23 +32,15 @@ rb_xml_cdata_s_new(int argc, VALUE *argv, VALUE klass)
|
|
33
32
|
|
34
33
|
if (!rb_obj_is_kind_of(rb_document, cNokogiriXmlDocument)) {
|
35
34
|
xmlNodePtr deprecated_node_type_arg;
|
36
|
-
// TODO:
|
37
|
-
NOKO_WARN_DEPRECATION("Passing a Node as the first parameter to CDATA.new is deprecated. Please pass a Document instead. This will become an error in a future release of Nokogiri.");
|
35
|
+
NOKO_WARN_DEPRECATION("Passing a Node as the first parameter to CDATA.new is deprecated. Please pass a Document instead. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.15.3, remove in v1.17.0
|
38
36
|
Noko_Node_Get_Struct(rb_document, xmlNode, deprecated_node_type_arg);
|
39
37
|
c_document = deprecated_node_type_arg->doc;
|
40
38
|
} else {
|
41
39
|
c_document = noko_xml_document_unwrap(rb_document);
|
42
40
|
}
|
43
41
|
|
44
|
-
|
45
|
-
c_content = (xmlChar *)StringValuePtr(rb_content);
|
46
|
-
c_content_len = RSTRING_LENINT(rb_content);
|
47
|
-
}
|
48
|
-
|
49
|
-
c_node = xmlNewCDataBlock(c_document, c_content, c_content_len);
|
50
|
-
|
42
|
+
c_node = xmlNewCDataBlock(c_document, (xmlChar *)StringValueCStr(rb_content), RSTRING_LENINT(rb_content));
|
51
43
|
noko_xml_document_pin_node(c_node);
|
52
|
-
|
53
44
|
rb_node = noko_xml_node_wrap(klass, c_node);
|
54
45
|
rb_obj_call_init(rb_node, argc, argv);
|
55
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;
|