nokogiri 1.11.0.rc3-java → 1.11.4-java
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 +3 -0
- data/LICENSE-DEPENDENCIES.md +1015 -947
- data/LICENSE.md +1 -1
- data/README.md +168 -91
- data/dependencies.yml +12 -12
- data/ext/java/nokogiri/EncodingHandler.java +76 -89
- data/ext/java/nokogiri/HtmlDocument.java +135 -144
- data/ext/java/nokogiri/HtmlElementDescription.java +102 -117
- data/ext/java/nokogiri/HtmlEntityLookup.java +33 -60
- data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -222
- data/ext/java/nokogiri/HtmlSaxPushParser.java +162 -169
- data/ext/java/nokogiri/NokogiriService.java +595 -556
- data/ext/java/nokogiri/XmlAttr.java +118 -126
- data/ext/java/nokogiri/XmlAttributeDecl.java +95 -106
- data/ext/java/nokogiri/XmlCdata.java +35 -58
- data/ext/java/nokogiri/XmlComment.java +46 -67
- data/ext/java/nokogiri/XmlDocument.java +645 -572
- data/ext/java/nokogiri/XmlDocumentFragment.java +125 -137
- data/ext/java/nokogiri/XmlDtd.java +448 -414
- data/ext/java/nokogiri/XmlElement.java +23 -48
- data/ext/java/nokogiri/XmlElementContent.java +343 -316
- data/ext/java/nokogiri/XmlElementDecl.java +124 -125
- data/ext/java/nokogiri/XmlEntityDecl.java +119 -127
- data/ext/java/nokogiri/XmlEntityReference.java +49 -72
- data/ext/java/nokogiri/XmlNamespace.java +175 -175
- data/ext/java/nokogiri/XmlNode.java +1843 -1622
- data/ext/java/nokogiri/XmlNodeSet.java +361 -331
- data/ext/java/nokogiri/XmlProcessingInstruction.java +47 -69
- data/ext/java/nokogiri/XmlReader.java +513 -450
- data/ext/java/nokogiri/XmlRelaxng.java +89 -101
- data/ext/java/nokogiri/XmlSaxParserContext.java +328 -310
- data/ext/java/nokogiri/XmlSaxPushParser.java +227 -220
- data/ext/java/nokogiri/XmlSchema.java +335 -242
- data/ext/java/nokogiri/XmlSyntaxError.java +113 -119
- data/ext/java/nokogiri/XmlText.java +55 -76
- data/ext/java/nokogiri/XmlXpathContext.java +242 -210
- data/ext/java/nokogiri/XsltStylesheet.java +280 -269
- data/ext/java/nokogiri/internals/ClosedStreamException.java +5 -2
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +201 -190
- data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +17 -10
- data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +43 -16
- data/ext/java/nokogiri/internals/NokogiriDomParser.java +63 -80
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +107 -88
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +27 -52
- data/ext/java/nokogiri/internals/NokogiriHandler.java +316 -286
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +736 -652
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +184 -173
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +79 -89
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +64 -79
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +84 -99
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +48 -65
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +119 -78
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -54
- data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +23 -46
- data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +55 -72
- data/ext/java/nokogiri/internals/ParserContext.java +206 -211
- data/ext/java/nokogiri/internals/ReaderNode.java +478 -403
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +822 -739
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +31 -54
- data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +129 -123
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +3 -34
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +206 -207
- data/ext/java/nokogiri/internals/XmlSaxParser.java +22 -47
- data/ext/java/nokogiri/internals/c14n/AttrCompare.java +71 -68
- data/ext/java/nokogiri/internals/c14n/C14nHelper.java +137 -118
- data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +27 -21
- data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +74 -61
- data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +230 -205
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +572 -547
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +17 -10
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +17 -10
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +323 -302
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +232 -219
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +22 -15
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +23 -16
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +23 -16
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +22 -15
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +575 -545
- data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +141 -120
- data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +39 -38
- data/ext/java/nokogiri/internals/c14n/Constants.java +13 -10
- data/ext/java/nokogiri/internals/c14n/ElementProxy.java +279 -247
- data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +66 -53
- data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +44 -37
- data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +135 -120
- data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +59 -48
- data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +384 -334
- data/ext/java/nokogiri/internals/c14n/NodeFilter.java +25 -24
- data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +151 -140
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +456 -423
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1466 -1500
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +626 -574
- data/ext/nokogiri/depend +37 -358
- data/ext/nokogiri/extconf.rb +581 -374
- data/ext/nokogiri/html_document.c +78 -82
- data/ext/nokogiri/html_element_description.c +84 -71
- data/ext/nokogiri/html_entity_lookup.c +21 -16
- data/ext/nokogiri/html_sax_parser_context.c +69 -66
- data/ext/nokogiri/html_sax_push_parser.c +42 -34
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +192 -93
- data/ext/nokogiri/test_global_handlers.c +40 -0
- data/ext/nokogiri/xml_attr.c +15 -15
- data/ext/nokogiri/xml_attribute_decl.c +18 -18
- data/ext/nokogiri/xml_cdata.c +13 -18
- data/ext/nokogiri/xml_comment.c +19 -26
- data/ext/nokogiri/xml_document.c +246 -188
- data/ext/nokogiri/xml_document_fragment.c +13 -15
- data/ext/nokogiri/xml_dtd.c +54 -48
- data/ext/nokogiri/xml_element_content.c +30 -27
- data/ext/nokogiri/xml_element_decl.c +22 -22
- data/ext/nokogiri/xml_encoding_handler.c +17 -11
- data/ext/nokogiri/xml_entity_decl.c +32 -30
- data/ext/nokogiri/xml_entity_reference.c +16 -18
- data/ext/nokogiri/xml_namespace.c +56 -49
- data/ext/nokogiri/xml_node.c +371 -320
- data/ext/nokogiri/xml_node_set.c +168 -156
- data/ext/nokogiri/xml_processing_instruction.c +17 -19
- data/ext/nokogiri/xml_reader.c +191 -157
- data/ext/nokogiri/xml_relax_ng.c +52 -28
- data/ext/nokogiri/xml_sax_parser.c +118 -118
- data/ext/nokogiri/xml_sax_parser_context.c +103 -86
- data/ext/nokogiri/xml_sax_push_parser.c +36 -27
- data/ext/nokogiri/xml_schema.c +95 -47
- data/ext/nokogiri/xml_syntax_error.c +42 -21
- data/ext/nokogiri/xml_text.c +13 -17
- data/ext/nokogiri/xml_xpath_context.c +206 -123
- data/ext/nokogiri/xslt_stylesheet.c +158 -161
- data/lib/nokogiri.rb +3 -7
- data/lib/nokogiri/css/parser.rb +3 -3
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/xpath_visitor.rb +70 -42
- data/lib/nokogiri/extension.rb +26 -0
- data/lib/nokogiri/html/document.rb +12 -26
- data/lib/nokogiri/html/document_fragment.rb +15 -15
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +2 -149
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +205 -0
- data/lib/nokogiri/xml/document.rb +91 -35
- data/lib/nokogiri/xml/document_fragment.rb +4 -6
- data/lib/nokogiri/xml/node.rb +89 -69
- data/lib/nokogiri/xml/parse_options.rb +6 -0
- data/lib/nokogiri/xml/reader.rb +2 -9
- data/lib/nokogiri/xml/relax_ng.rb +6 -2
- data/lib/nokogiri/xml/schema.rb +12 -4
- data/lib/nokogiri/xml/searchable.rb +3 -1
- data/lib/nokogiri/xml/xpath.rb +1 -3
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
- metadata +86 -177
- data/ext/nokogiri/html_document.h +0 -10
- data/ext/nokogiri/html_element_description.h +0 -10
- data/ext/nokogiri/html_entity_lookup.h +0 -8
- data/ext/nokogiri/html_sax_parser_context.h +0 -11
- data/ext/nokogiri/html_sax_push_parser.h +0 -9
- data/ext/nokogiri/nokogiri.h +0 -134
- data/ext/nokogiri/xml_attr.h +0 -9
- data/ext/nokogiri/xml_attribute_decl.h +0 -9
- data/ext/nokogiri/xml_cdata.h +0 -9
- data/ext/nokogiri/xml_comment.h +0 -9
- data/ext/nokogiri/xml_document.h +0 -23
- data/ext/nokogiri/xml_document_fragment.h +0 -10
- data/ext/nokogiri/xml_dtd.h +0 -10
- data/ext/nokogiri/xml_element_content.h +0 -10
- data/ext/nokogiri/xml_element_decl.h +0 -9
- data/ext/nokogiri/xml_encoding_handler.h +0 -8
- data/ext/nokogiri/xml_entity_decl.h +0 -10
- data/ext/nokogiri/xml_entity_reference.h +0 -9
- data/ext/nokogiri/xml_io.c +0 -63
- data/ext/nokogiri/xml_io.h +0 -11
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
- data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
- data/ext/nokogiri/xml_namespace.h +0 -14
- data/ext/nokogiri/xml_node.h +0 -13
- data/ext/nokogiri/xml_node_set.h +0 -12
- data/ext/nokogiri/xml_processing_instruction.h +0 -9
- data/ext/nokogiri/xml_reader.h +0 -10
- data/ext/nokogiri/xml_relax_ng.h +0 -9
- data/ext/nokogiri/xml_sax_parser.h +0 -39
- data/ext/nokogiri/xml_sax_parser_context.h +0 -10
- data/ext/nokogiri/xml_sax_push_parser.h +0 -9
- data/ext/nokogiri/xml_schema.h +0 -9
- data/ext/nokogiri/xml_syntax_error.h +0 -13
- data/ext/nokogiri/xml_text.h +0 -9
- data/ext/nokogiri/xml_xpath_context.h +0 -10
- data/ext/nokogiri/xslt_stylesheet.h +0 -14
data/ext/nokogiri/nokogiri.c
CHANGED
@@ -1,107 +1,184 @@
|
|
1
1
|
#include <nokogiri.h>
|
2
2
|
|
3
3
|
VALUE mNokogiri ;
|
4
|
-
VALUE mNokogiriXml ;
|
5
4
|
VALUE mNokogiriHtml ;
|
6
|
-
VALUE mNokogiriXslt ;
|
7
|
-
VALUE mNokogiriXmlSax ;
|
8
5
|
VALUE mNokogiriHtmlSax ;
|
6
|
+
VALUE mNokogiriXml ;
|
7
|
+
VALUE mNokogiriXmlSax ;
|
8
|
+
VALUE mNokogiriXmlXpath ;
|
9
|
+
VALUE mNokogiriXslt ;
|
9
10
|
|
10
|
-
|
11
|
+
VALUE cNokogiriSyntaxError;
|
12
|
+
VALUE cNokogiriXmlCharacterData;
|
13
|
+
VALUE cNokogiriXmlElement;
|
14
|
+
VALUE cNokogiriXmlXpathSyntaxError;
|
15
|
+
|
16
|
+
void noko_init_xml_attr();
|
17
|
+
void noko_init_xml_attribute_decl();
|
18
|
+
void noko_init_xml_cdata();
|
19
|
+
void noko_init_xml_comment();
|
20
|
+
void noko_init_xml_document();
|
21
|
+
void noko_init_xml_document_fragment();
|
22
|
+
void noko_init_xml_dtd();
|
23
|
+
void noko_init_xml_element_content();
|
24
|
+
void noko_init_xml_element_decl();
|
25
|
+
void noko_init_xml_encoding_handler();
|
26
|
+
void noko_init_xml_entity_decl();
|
27
|
+
void noko_init_xml_entity_reference();
|
28
|
+
void noko_init_xml_namespace();
|
29
|
+
void noko_init_xml_node();
|
30
|
+
void noko_init_xml_node_set();
|
31
|
+
void noko_init_xml_processing_instruction();
|
32
|
+
void noko_init_xml_reader();
|
33
|
+
void noko_init_xml_relax_ng();
|
34
|
+
void noko_init_xml_sax_parser();
|
35
|
+
void noko_init_xml_sax_parser_context();
|
36
|
+
void noko_init_xml_sax_push_parser();
|
37
|
+
void noko_init_xml_schema();
|
38
|
+
void noko_init_xml_syntax_error();
|
39
|
+
void noko_init_xml_text();
|
40
|
+
void noko_init_xml_xpath_context();
|
41
|
+
void noko_init_xslt_stylesheet();
|
42
|
+
void noko_init_html_document();
|
43
|
+
void noko_init_html_element_description();
|
44
|
+
void noko_init_html_entity_lookup();
|
45
|
+
void noko_init_html_sax_parser_context();
|
46
|
+
void noko_init_html_sax_push_parser();
|
47
|
+
void noko_init_test_global_handlers();
|
48
|
+
|
49
|
+
static ID id_read, id_write;
|
50
|
+
|
51
|
+
|
52
|
+
#ifndef HAVE_VASPRINTF
|
11
53
|
/*
|
12
|
-
* I srsly hate windows. it doesn't have vasprintf.
|
13
54
|
* Thank you Geoffroy Couprie for this implementation of vasprintf!
|
14
55
|
*/
|
15
|
-
int
|
56
|
+
int
|
57
|
+
vasprintf(char **strp, const char *fmt, va_list ap)
|
16
58
|
{
|
17
59
|
/* Mingw32/64 have a broken vsnprintf implementation that fails when
|
18
60
|
* using a zero-byte limit in order to retrieve the required size for malloc.
|
19
61
|
* So we use a one byte buffer instead.
|
20
62
|
*/
|
21
63
|
char tmp[1];
|
22
|
-
int len = vsnprintf
|
64
|
+
int len = vsnprintf(tmp, 1, fmt, ap) + 1;
|
23
65
|
char *res = (char *)malloc((unsigned int)len);
|
24
|
-
if (res == NULL)
|
25
|
-
|
66
|
+
if (res == NULL) {
|
67
|
+
return -1;
|
68
|
+
}
|
26
69
|
*strp = res;
|
27
70
|
return vsnprintf(res, (unsigned int)len, fmt, ap);
|
28
71
|
}
|
29
72
|
#endif
|
30
73
|
|
31
|
-
|
74
|
+
|
75
|
+
static VALUE
|
76
|
+
read_check(VALUE val)
|
32
77
|
{
|
33
|
-
|
78
|
+
VALUE *args = (VALUE *)val;
|
79
|
+
return rb_funcall(args[0], id_read, 1, args[1]);
|
34
80
|
}
|
35
81
|
|
36
|
-
#ifdef HAVE_RUBY_UTIL_H
|
37
|
-
#include "ruby/util.h"
|
38
|
-
#else
|
39
|
-
#include "util.h"
|
40
|
-
#endif
|
41
82
|
|
42
|
-
|
83
|
+
static VALUE
|
84
|
+
read_failed(VALUE arg, VALUE exc)
|
85
|
+
{
|
86
|
+
return Qundef;
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
int
|
91
|
+
noko_io_read(void *ctx, char *buffer, int len)
|
92
|
+
{
|
93
|
+
VALUE string, args[2];
|
94
|
+
size_t str_len, safe_len;
|
95
|
+
|
96
|
+
args[0] = (VALUE)ctx;
|
97
|
+
args[1] = INT2NUM(len);
|
98
|
+
|
99
|
+
string = rb_rescue(read_check, (VALUE)args, read_failed, 0);
|
100
|
+
|
101
|
+
if (NIL_P(string)) { return 0; }
|
102
|
+
if (string == Qundef) { return -1; }
|
103
|
+
if (TYPE(string) != T_STRING) { return -1; }
|
104
|
+
|
105
|
+
str_len = (size_t)RSTRING_LEN(string);
|
106
|
+
safe_len = str_len > (size_t)len ? (size_t)len : str_len;
|
107
|
+
memcpy(buffer, StringValuePtr(string), safe_len);
|
108
|
+
|
109
|
+
return (int)safe_len;
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
write_check(VALUE val)
|
43
115
|
{
|
44
|
-
|
45
|
-
|
116
|
+
VALUE *args = (VALUE *)val;
|
117
|
+
return rb_funcall(args[0], id_write, 1, args[1]);
|
118
|
+
}
|
46
119
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
120
|
+
|
121
|
+
static VALUE
|
122
|
+
write_failed(VALUE arg, VALUE exc)
|
123
|
+
{
|
124
|
+
return Qundef;
|
51
125
|
}
|
52
126
|
|
53
|
-
|
127
|
+
|
128
|
+
int
|
129
|
+
noko_io_write(void *ctx, char *buffer, int len)
|
54
130
|
{
|
55
|
-
|
131
|
+
VALUE args[2], size;
|
132
|
+
|
133
|
+
args[0] = (VALUE)ctx;
|
134
|
+
args[1] = rb_str_new(buffer, (long)len);
|
56
135
|
|
57
|
-
|
58
|
-
|
59
|
-
|
136
|
+
size = rb_rescue(write_check, (VALUE)args, write_failed, 0);
|
137
|
+
|
138
|
+
if (size == Qundef) { return -1; }
|
139
|
+
|
140
|
+
return NUM2INT(size);
|
60
141
|
}
|
61
142
|
|
62
|
-
|
143
|
+
|
144
|
+
int
|
145
|
+
noko_io_close(void *ctx)
|
63
146
|
{
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
(xmlReallocFunc)ruby_xrealloc,
|
68
|
-
ruby_strdup
|
69
|
-
);
|
147
|
+
return 0;
|
148
|
+
}
|
149
|
+
|
70
150
|
|
151
|
+
void
|
152
|
+
Init_nokogiri()
|
153
|
+
{
|
71
154
|
mNokogiri = rb_define_module("Nokogiri");
|
72
155
|
mNokogiriXml = rb_define_module_under(mNokogiri, "XML");
|
73
156
|
mNokogiriHtml = rb_define_module_under(mNokogiri, "HTML");
|
74
157
|
mNokogiriXslt = rb_define_module_under(mNokogiri, "XSLT");
|
158
|
+
mNokogiriXmlXpath = rb_define_module_under(mNokogiriXml, "XPath");
|
75
159
|
mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX");
|
76
160
|
mNokogiriHtmlSax = rb_define_module_under(mNokogiriHtml, "SAX");
|
77
161
|
|
78
|
-
rb_const_set(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
rb_const_set(
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
rb_const_set(
|
93
|
-
rb_intern("LIBXSLT_LOADED_VERSION"),
|
94
|
-
NOKOGIRI_STR_NEW2(xsltEngineVersion)
|
95
|
-
);
|
96
|
-
|
97
|
-
#ifdef NOKOGIRI_USE_PACKAGED_LIBRARIES
|
98
|
-
rb_const_set(mNokogiri, rb_intern("NOKOGIRI_USE_PACKAGED_LIBRARIES"), Qtrue);
|
99
|
-
rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " "));
|
100
|
-
rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " "));
|
162
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION));
|
163
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xmlParserVersion));
|
164
|
+
|
165
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
|
166
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));
|
167
|
+
|
168
|
+
#ifdef NOKOGIRI_PACKAGED_LIBRARIES
|
169
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
|
170
|
+
# ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
|
171
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qtrue);
|
172
|
+
# else
|
173
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
174
|
+
# endif
|
175
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " "));
|
176
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " "));
|
101
177
|
#else
|
102
|
-
rb_const_set(mNokogiri, rb_intern("
|
103
|
-
rb_const_set(mNokogiri, rb_intern("
|
104
|
-
rb_const_set(mNokogiri, rb_intern("
|
178
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qfalse);
|
179
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
180
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), Qnil);
|
181
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), Qnil);
|
105
182
|
#endif
|
106
183
|
|
107
184
|
#ifdef LIBXML_ICONV_ENABLED
|
@@ -110,38 +187,60 @@ void Init_nokogiri()
|
|
110
187
|
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse);
|
111
188
|
#endif
|
112
189
|
|
190
|
+
#ifdef NOKOGIRI_OTHER_LIBRARY_VERSIONS
|
191
|
+
rb_const_set(mNokogiri, rb_intern("OTHER_LIBRARY_VERSIONS"), NOKOGIRI_STR_NEW2(NOKOGIRI_OTHER_LIBRARY_VERSIONS));
|
192
|
+
#endif
|
193
|
+
|
194
|
+
xmlMemSetup((xmlFreeFunc)ruby_xfree, (xmlMallocFunc)ruby_xmalloc, (xmlReallocFunc)ruby_xrealloc, ruby_strdup);
|
195
|
+
|
113
196
|
xmlInitParser();
|
114
197
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
198
|
+
cNokogiriSyntaxError = rb_define_class_under(mNokogiri, "SyntaxError", rb_eStandardError);
|
199
|
+
noko_init_xml_syntax_error();
|
200
|
+
assert(cNokogiriXmlSyntaxError);
|
201
|
+
cNokogiriXmlXpathSyntaxError = rb_define_class_under(mNokogiriXmlXpath, "SyntaxError", cNokogiriXmlSyntaxError);
|
202
|
+
|
203
|
+
noko_init_xml_element_content();
|
204
|
+
noko_init_xml_encoding_handler();
|
205
|
+
noko_init_xml_namespace();
|
206
|
+
noko_init_xml_node_set();
|
207
|
+
noko_init_xml_reader();
|
208
|
+
noko_init_xml_sax_parser();
|
209
|
+
noko_init_xml_xpath_context();
|
210
|
+
noko_init_xslt_stylesheet();
|
211
|
+
noko_init_html_element_description();
|
212
|
+
noko_init_html_entity_lookup();
|
213
|
+
|
214
|
+
noko_init_xml_schema();
|
215
|
+
noko_init_xml_relax_ng();
|
216
|
+
|
217
|
+
noko_init_xml_sax_parser_context();
|
218
|
+
noko_init_html_sax_parser_context();
|
219
|
+
|
220
|
+
noko_init_xml_sax_push_parser();
|
221
|
+
noko_init_html_sax_push_parser();
|
222
|
+
|
223
|
+
noko_init_xml_node();
|
224
|
+
noko_init_xml_attr();
|
225
|
+
noko_init_xml_attribute_decl();
|
226
|
+
noko_init_xml_dtd();
|
227
|
+
noko_init_xml_element_decl();
|
228
|
+
noko_init_xml_entity_decl();
|
229
|
+
noko_init_xml_entity_reference();
|
230
|
+
noko_init_xml_processing_instruction();
|
231
|
+
assert(cNokogiriXmlNode);
|
232
|
+
cNokogiriXmlElement = rb_define_class_under(mNokogiriXml, "Element", cNokogiriXmlNode);
|
233
|
+
cNokogiriXmlCharacterData = rb_define_class_under(mNokogiriXml, "CharacterData", cNokogiriXmlNode);
|
234
|
+
noko_init_xml_comment();
|
235
|
+
noko_init_xml_text();
|
236
|
+
noko_init_xml_cdata();
|
237
|
+
|
238
|
+
noko_init_xml_document_fragment();
|
239
|
+
noko_init_xml_document();
|
240
|
+
noko_init_html_document();
|
241
|
+
|
242
|
+
noko_init_test_global_handlers();
|
243
|
+
|
244
|
+
id_read = rb_intern("read");
|
245
|
+
id_write = rb_intern("write");
|
147
246
|
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
static VALUE foreign_error_handler_block = Qnil;
|
4
|
+
|
5
|
+
static void
|
6
|
+
foreign_error_handler(void *user_data, xmlErrorPtr c_error)
|
7
|
+
{
|
8
|
+
rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
|
9
|
+
}
|
10
|
+
|
11
|
+
/*
|
12
|
+
* call-seq:
|
13
|
+
* __foreign_error_handler { ... } -> nil
|
14
|
+
*
|
15
|
+
* Override libxml2's global error handlers to call the block. This method thus has very little
|
16
|
+
* value except to test that Nokogiri is properly setting error handlers elsewhere in the code. See
|
17
|
+
* test/helper.rb for how this is being used.
|
18
|
+
*/
|
19
|
+
static VALUE
|
20
|
+
rb_foreign_error_handler(VALUE klass)
|
21
|
+
{
|
22
|
+
rb_need_block();
|
23
|
+
foreign_error_handler_block = rb_block_proc();
|
24
|
+
xmlSetStructuredErrorFunc(NULL, foreign_error_handler);
|
25
|
+
return Qnil;
|
26
|
+
}
|
27
|
+
|
28
|
+
/*
|
29
|
+
* Document-module: Nokogiri::Test
|
30
|
+
*
|
31
|
+
* The Nokogiri::Test module should only be used for testing Nokogiri.
|
32
|
+
* Do NOT use this outside of the Nokogiri test suite.
|
33
|
+
*/
|
34
|
+
void
|
35
|
+
noko_init_test_global_handlers()
|
36
|
+
{
|
37
|
+
VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");
|
38
|
+
|
39
|
+
rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0);
|
40
|
+
}
|
data/ext/nokogiri/xml_attr.c
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#include <
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlAttr;
|
2
4
|
|
3
5
|
/*
|
4
6
|
* call-seq:
|
@@ -7,7 +9,8 @@
|
|
7
9
|
* Set the value for this Attr to +content+. Use `nil` to remove the value
|
8
10
|
* (e.g., a HTML boolean attribute).
|
9
11
|
*/
|
10
|
-
static VALUE
|
12
|
+
static VALUE
|
13
|
+
set_value(VALUE self, VALUE content)
|
11
14
|
{
|
12
15
|
xmlAttrPtr attr;
|
13
16
|
xmlChar *value;
|
@@ -49,7 +52,8 @@ static VALUE set_value(VALUE self, VALUE content)
|
|
49
52
|
*
|
50
53
|
* Create a new Attr element on the +document+ with +name+
|
51
54
|
*/
|
52
|
-
static VALUE
|
55
|
+
static VALUE
|
56
|
+
new (int argc, VALUE *argv, VALUE klass)
|
53
57
|
{
|
54
58
|
xmlDocPtr xml_doc;
|
55
59
|
VALUE document;
|
@@ -72,9 +76,9 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
72
76
|
NULL
|
73
77
|
);
|
74
78
|
|
75
|
-
|
79
|
+
noko_xml_document_pin_node((xmlNodePtr)node);
|
76
80
|
|
77
|
-
rb_node =
|
81
|
+
rb_node = noko_xml_node_wrap(klass, (xmlNodePtr)node);
|
78
82
|
rb_obj_call_init(rb_node, argc, argv);
|
79
83
|
|
80
84
|
if (rb_block_given_p()) {
|
@@ -84,20 +88,16 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
84
88
|
return rb_node;
|
85
89
|
}
|
86
90
|
|
87
|
-
|
88
|
-
|
91
|
+
void
|
92
|
+
noko_init_xml_attr()
|
89
93
|
{
|
90
|
-
|
91
|
-
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
92
|
-
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
93
|
-
|
94
|
+
assert(cNokogiriXmlNode);
|
94
95
|
/*
|
95
96
|
* Attr represents a Attr node in an xml document.
|
96
97
|
*/
|
97
|
-
|
98
|
+
cNokogiriXmlAttr = rb_define_class_under(mNokogiriXml, "Attr", cNokogiriXmlNode);
|
98
99
|
|
99
|
-
cNokogiriXmlAttr
|
100
|
+
rb_define_singleton_method(cNokogiriXmlAttr, "new", new, -1);
|
100
101
|
|
101
|
-
|
102
|
-
rb_define_method(klass, "value=", set_value, 1);
|
102
|
+
rb_define_method(cNokogiriXmlAttr, "value=", set_value, 1);
|
103
103
|
}
|
@@ -1,4 +1,6 @@
|
|
1
|
-
#include <
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlAttributeDecl;
|
2
4
|
|
3
5
|
/*
|
4
6
|
* call-seq:
|
@@ -6,7 +8,8 @@
|
|
6
8
|
*
|
7
9
|
* The attribute_type for this AttributeDecl
|
8
10
|
*/
|
9
|
-
static VALUE
|
11
|
+
static VALUE
|
12
|
+
attribute_type(VALUE self)
|
10
13
|
{
|
11
14
|
xmlAttributePtr node;
|
12
15
|
Data_Get_Struct(self, xmlAttribute, node);
|
@@ -19,12 +22,13 @@ static VALUE attribute_type(VALUE self)
|
|
19
22
|
*
|
20
23
|
* The default value
|
21
24
|
*/
|
22
|
-
static VALUE
|
25
|
+
static VALUE
|
26
|
+
default_value(VALUE self)
|
23
27
|
{
|
24
28
|
xmlAttributePtr node;
|
25
29
|
Data_Get_Struct(self, xmlAttribute, node);
|
26
30
|
|
27
|
-
if(node->defaultValue) return NOKOGIRI_STR_NEW2(node->defaultValue);
|
31
|
+
if (node->defaultValue) { return NOKOGIRI_STR_NEW2(node->defaultValue); }
|
28
32
|
return Qnil;
|
29
33
|
}
|
30
34
|
|
@@ -34,7 +38,8 @@ static VALUE default_value(VALUE self)
|
|
34
38
|
*
|
35
39
|
* An enumeration of possible values
|
36
40
|
*/
|
37
|
-
static VALUE
|
41
|
+
static VALUE
|
42
|
+
enumeration(VALUE self)
|
38
43
|
{
|
39
44
|
xmlAttributePtr node;
|
40
45
|
xmlEnumerationPtr enm;
|
@@ -45,7 +50,7 @@ static VALUE enumeration(VALUE self)
|
|
45
50
|
list = rb_ary_new();
|
46
51
|
enm = node->tree;
|
47
52
|
|
48
|
-
while(enm) {
|
53
|
+
while (enm) {
|
49
54
|
rb_ary_push(list, NOKOGIRI_STR_NEW2(enm->name));
|
50
55
|
enm = enm->next;
|
51
56
|
}
|
@@ -53,18 +58,13 @@ static VALUE enumeration(VALUE self)
|
|
53
58
|
return list;
|
54
59
|
}
|
55
60
|
|
56
|
-
|
57
|
-
|
58
|
-
void init_xml_attribute_decl()
|
61
|
+
void
|
62
|
+
noko_init_xml_attribute_decl()
|
59
63
|
{
|
60
|
-
|
61
|
-
|
62
|
-
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
63
|
-
VALUE klass = rb_define_class_under(xml, "AttributeDecl", node);
|
64
|
-
|
65
|
-
cNokogiriXmlAttributeDecl = klass;
|
64
|
+
assert(cNokogiriXmlNode);
|
65
|
+
cNokogiriXmlAttributeDecl = rb_define_class_under(mNokogiriXml, "AttributeDecl", cNokogiriXmlNode);
|
66
66
|
|
67
|
-
rb_define_method(
|
68
|
-
rb_define_method(
|
69
|
-
rb_define_method(
|
67
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "attribute_type", attribute_type, 0);
|
68
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "default", default_value, 0);
|
69
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "enumeration", enumeration, 0);
|
70
70
|
}
|