nokogiri 1.17.2-x86_64-darwin → 1.18.0-x86_64-darwin
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 +5 -4
- data/LICENSE-DEPENDENCIES.md +6 -6
- data/README.md +4 -5
- data/ext/nokogiri/extconf.rb +5 -13
- data/ext/nokogiri/xml_xpath_context.c +102 -99
- data/lib/nokogiri/3.1/nokogiri.bundle +0 -0
- data/lib/nokogiri/3.2/nokogiri.bundle +0 -0
- data/lib/nokogiri/3.3/nokogiri.bundle +0 -0
- data/lib/nokogiri/{3.0 → 3.4}/nokogiri.bundle +0 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/xml/searchable.rb +32 -34
- data/lib/nokogiri/xml/xpath_context.rb +14 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54bafe728e1eaf92f7d8abe7f4688953555829d33a3e506a4fcd92a12bc53ffc
|
4
|
+
data.tar.gz: 3e3c3bcd2d8206b80393835e087ce03dfc6d2239276904dba614abbe27691179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00c3dde2650092903fcf63b05923d32855d7eb7b2a7557f31af4a45b1f580b19c2cc168ef103d09754d485712e6166a08ad52af9eaa9fc3500b498b2e08e37b3
|
7
|
+
data.tar.gz: f8600e5f4cf297e80be69b425e1f1e41dddbeed19c4c4326d8964ad0519340dda778d175946625cc02a4d971c9ee2e2726afcb9ed8957793599afaa54b892a72
|
data/Gemfile
CHANGED
@@ -11,20 +11,20 @@ group :development do
|
|
11
11
|
|
12
12
|
# building extensions
|
13
13
|
gem "rake-compiler", "1.2.8"
|
14
|
-
gem "rake-compiler-dock", "1.
|
14
|
+
gem "rake-compiler-dock", "1.7.0"
|
15
15
|
|
16
16
|
# parser generator
|
17
17
|
gem "rexical", "1.0.8"
|
18
18
|
|
19
19
|
# tests
|
20
|
-
gem "minitest", "5.25.
|
20
|
+
gem "minitest", "5.25.4"
|
21
21
|
gem "minitest-parallel_fork", "2.0.0"
|
22
22
|
gem "ruby_memcheck", "3.0.0"
|
23
23
|
gem "rubyzip", "~> 2.3.2"
|
24
24
|
gem "simplecov", "= 0.21.2"
|
25
25
|
|
26
26
|
# rubocop
|
27
|
-
gem "standard", "1.
|
27
|
+
gem "standard", "1.43.0"
|
28
28
|
gem "rubocop-minitest", "0.36.0"
|
29
29
|
gem "rubocop-packaging", "0.5.2"
|
30
30
|
gem "rubocop-rake", "0.6.0"
|
@@ -34,5 +34,6 @@ end
|
|
34
34
|
# `bundle config set --local without rdoc`
|
35
35
|
# Then re-run `bundle install`.
|
36
36
|
group :rdoc do
|
37
|
-
gem "rdoc", "6.
|
37
|
+
gem "rdoc", "6.10.0"
|
38
|
+
gem "jar-dependencies", "0.4.1" if RUBY_PLATFORM == "java" # https://github.com/jruby/jruby/issues/7262
|
38
39
|
end
|
data/LICENSE-DEPENDENCIES.md
CHANGED
@@ -10,9 +10,9 @@ Note that this document is broken into multiple sections, each of which describe
|
|
10
10
|
|
11
11
|
- [Platform Releases](#platform-releases)
|
12
12
|
* [Default platform release ("ruby")](#default-platform-release-ruby)
|
13
|
-
* [Native LinuxⓇ platform releases ("x86_64-linux", "
|
13
|
+
* [Native LinuxⓇ platform releases ("x86_64-linux", "aarch64-linux", and "arm-linux")](#native-linux%E2%93%A1-platform-releases-x86_64-linux-aarch64-linux-and-arm-linux)
|
14
14
|
* [Native Darwin (macOSⓇ) platform releases ("x86_64-darwin" and "arm64-darwin")](#native-darwin-macos%E2%93%A1-platform-releases-x86_64-darwin-and-arm64-darwin)
|
15
|
-
* [Native WindowsⓇ platform releases ("
|
15
|
+
* [Native WindowsⓇ platform releases ("x64-mingw-ucrt")](#native-windows%E2%93%A1-platform-releases-x64-mingw-ucrt)
|
16
16
|
* [JavaⓇ (JRuby) platform release ("java")](#java%E2%93%A1-jruby-platform-release-java)
|
17
17
|
- [Appendix: Dependencies' License Texts](#appendix-dependencies-license-texts)
|
18
18
|
* [libgumbo](#libgumbo)
|
@@ -51,7 +51,7 @@ The default platform release distributes the following dependencies in source fo
|
|
51
51
|
This distribution can be identified by inspecting the included Gem::Specification, which will have the value "ruby" for its "platform" attribute.
|
52
52
|
|
53
53
|
|
54
|
-
### Native LinuxⓇ platform releases ("x86_64-linux", "
|
54
|
+
### Native LinuxⓇ platform releases ("x86_64-linux", "aarch64-linux", and "arm-linux")
|
55
55
|
|
56
56
|
The native LinuxⓇ platform release distributes the following dependencies in source form:
|
57
57
|
|
@@ -60,7 +60,7 @@ The native LinuxⓇ platform release distributes the following dependencies in s
|
|
60
60
|
* [libgumbo](#libgumbo)
|
61
61
|
* [zlib](#zlib)
|
62
62
|
|
63
|
-
This distribution can be identified by inspecting the included Gem::Specification, which will have a value similar to "x86_64-linux" or "
|
63
|
+
This distribution can be identified by inspecting the included Gem::Specification, which will have a value similar to "x86_64-linux" or "aarch64-linux" for its "platform.cpu" attribute.
|
64
64
|
|
65
65
|
|
66
66
|
### Native Darwin (macOSⓇ) platform releases ("x86_64-darwin" and "arm64-darwin")
|
@@ -76,7 +76,7 @@ The native Darwin platform release distributes the following dependencies in sou
|
|
76
76
|
This distribution can be identified by inspecting the included Gem::Specification, which will have a value similar to "x86_64-darwin" or "arm64-darwin" for its "platform.cpu" attribute. Darwin is also known more familiarly as "OSX" or "macOSⓇ" and is the operating system for many AppleⓇ computers.
|
77
77
|
|
78
78
|
|
79
|
-
### Native WindowsⓇ platform releases ("
|
79
|
+
### Native WindowsⓇ platform releases ("x64-mingw-ucrt")
|
80
80
|
|
81
81
|
The native WindowsⓇ platform release distributes the following dependencies in source form:
|
82
82
|
|
@@ -86,7 +86,7 @@ The native WindowsⓇ platform release distributes the following dependencies in
|
|
86
86
|
* [zlib](#zlib)
|
87
87
|
* [libiconv](#libiconv)
|
88
88
|
|
89
|
-
This distribution can be identified by inspecting the included Gem::Specification, which will have a value similar to "x64-
|
89
|
+
This distribution can be identified by inspecting the included Gem::Specification, which will have a value similar to "x64-mingw-ucrt" for its "platform.cpu" attribute.
|
90
90
|
|
91
91
|
|
92
92
|
### JavaⓇ (JRuby) platform release ("java")
|
data/README.md
CHANGED
@@ -114,7 +114,7 @@ You can help sponsor the maintainers of this software through one of these organ
|
|
114
114
|
|
115
115
|
Requirements:
|
116
116
|
|
117
|
-
- Ruby >= 3.
|
117
|
+
- Ruby >= 3.1
|
118
118
|
- JRuby >= 9.4.0.0
|
119
119
|
|
120
120
|
If you are compiling the native extension against a system version of libxml2:
|
@@ -131,11 +131,10 @@ If you are compiling the native extension against a system version of libxml2:
|
|
131
131
|
Nokogiri ships pre-compiled, "native" gems for the following platforms:
|
132
132
|
|
133
133
|
- Linux:
|
134
|
-
- `
|
135
|
-
- `aarch64-linux
|
136
|
-
- Note that musl platforms like Alpine **are** supported
|
134
|
+
- `x86_64-linux-gnu`, `aarch64-linux-gnu`, and `arm-linux-gnu` (req: `glibc >= 2.29`)
|
135
|
+
- `x86_64-linux-musl`, `aarch64-linux-musl`, and `arm-linux-musl`
|
137
136
|
- Darwin/MacOS: `x86_64-darwin` and `arm64-darwin`
|
138
|
-
- Windows: `
|
137
|
+
- Windows: `x64-mingw-ucrt`
|
139
138
|
- Java: any platform running JRuby 9.4 or higher
|
140
139
|
|
141
140
|
To determine whether your system supports one of these gems, look at the output of `bundle platform` or `ruby -e 'puts Gem::Platform.local.to_s'`.
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -847,7 +847,7 @@ else
|
|
847
847
|
# The libiconv configure script doesn't accept "arm64" host string but "aarch64"
|
848
848
|
recipe.host = recipe.host.gsub("arm64-apple-darwin", "aarch64-apple-darwin")
|
849
849
|
|
850
|
-
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-
|
850
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
|
851
851
|
|
852
852
|
recipe.configure_options += [
|
853
853
|
"--disable-dependency-tracking",
|
@@ -911,7 +911,7 @@ else
|
|
911
911
|
end
|
912
912
|
|
913
913
|
cppflags = concat_flags(ENV["CPPFLAGS"])
|
914
|
-
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-
|
914
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
|
915
915
|
|
916
916
|
if cross_build_p
|
917
917
|
cppflags = concat_flags(cppflags, "-DNOKOGIRI_PRECOMPILED_LIBRARIES")
|
@@ -952,7 +952,6 @@ else
|
|
952
952
|
"--with-c14n",
|
953
953
|
"--with-debug",
|
954
954
|
"--with-threads",
|
955
|
-
"--without-tls", # see https://github.com/sparklemotion/nokogiri/issues/3031
|
956
955
|
"CPPFLAGS=#{cppflags}",
|
957
956
|
"CFLAGS=#{cflags}",
|
958
957
|
]
|
@@ -971,7 +970,7 @@ else
|
|
971
970
|
recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", "libxslt", "*.patch")].sort
|
972
971
|
end
|
973
972
|
|
974
|
-
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-
|
973
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
|
975
974
|
|
976
975
|
if darwin? && !cross_build_p
|
977
976
|
recipe.configure_options << "RANLIB=/usr/bin/ranlib" unless ENV.key?("RANLIB")
|
@@ -1117,14 +1116,7 @@ else
|
|
1117
1116
|
end
|
1118
1117
|
env["RANLIB"] = "#{host}-ranlib"
|
1119
1118
|
if windows?
|
1120
|
-
|
1121
|
-
# msvcrt (ruby <= 3.0) or ucrt (ruby > 3.0), so even though this gets evaluated only once
|
1122
|
-
# per gem (and not per-version-of-ruby), it's OK.
|
1123
|
-
env["CFLAGS"] = if RbConfig::CONFIG["RUBY_SO_NAME"].include?("msvcrt")
|
1124
|
-
concat_flags(env["CFLAGS"], "-D_RUBY_MSVCRT")
|
1125
|
-
else
|
1126
|
-
concat_flags(env["CFLAGS"], "-D_RUBY_UCRT")
|
1127
|
-
end
|
1119
|
+
concat_flags(env["CFLAGS"], "-D_RUBY_UCRT")
|
1128
1120
|
end
|
1129
1121
|
end
|
1130
1122
|
|
@@ -1141,7 +1133,7 @@ end
|
|
1141
1133
|
have_func("xmlCtxtSetOptions") # introduced in libxml2 2.13.0
|
1142
1134
|
have_func("xmlCtxtGetOptions") # introduced in libxml2 2.14.0
|
1143
1135
|
have_func("xmlSwitchEncodingName") # introduced in libxml2 2.13.0
|
1144
|
-
have_func("rb_category_warning") # introduced in Ruby 3.0
|
1136
|
+
have_func("rb_category_warning") # introduced in Ruby 3.0 but had trouble resolving this symbol in truffleruby
|
1145
1137
|
|
1146
1138
|
other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k, v| [k, v].join(":") }.join(",")
|
1147
1139
|
append_cppflags(%[-DNOKOGIRI_OTHER_LIBRARY_VERSIONS="\\"#{other_library_versions_string}\\""])
|
@@ -12,23 +12,23 @@ static const xmlChar *NOKOGIRI_BUILTIN_PREFIX = (const xmlChar *)"nokogiri-built
|
|
12
12
|
static const xmlChar *NOKOGIRI_BUILTIN_URI = (const xmlChar *)"https://www.nokogiri.org/default_ns/ruby/builtins";
|
13
13
|
|
14
14
|
static void
|
15
|
-
|
15
|
+
_noko_xml_xpath_context_dfree(void *data)
|
16
16
|
{
|
17
17
|
xmlXPathContextPtr c_context = data;
|
18
18
|
xmlXPathFreeContext(c_context);
|
19
19
|
}
|
20
20
|
|
21
|
-
static const rb_data_type_t
|
21
|
+
static const rb_data_type_t _noko_xml_xpath_context_type = {
|
22
22
|
.wrap_struct_name = "xmlXPathContext",
|
23
23
|
.function = {
|
24
|
-
.dfree =
|
24
|
+
.dfree = _noko_xml_xpath_context_dfree,
|
25
25
|
},
|
26
26
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
27
27
|
};
|
28
28
|
|
29
29
|
/* find a CSS class in an HTML element's `class` attribute */
|
30
30
|
static const xmlChar *
|
31
|
-
|
31
|
+
_noko_xml_xpath_context__css_class(const xmlChar *str, const xmlChar *val)
|
32
32
|
{
|
33
33
|
int val_len;
|
34
34
|
|
@@ -62,9 +62,9 @@ builtin_css_class(const xmlChar *str, const xmlChar *val)
|
|
62
62
|
return (NULL);
|
63
63
|
}
|
64
64
|
|
65
|
-
/* xmlXPathFunction to wrap
|
65
|
+
/* xmlXPathFunction to wrap _noko_xml_xpath_context__css_class() */
|
66
66
|
static void
|
67
|
-
|
67
|
+
noko_xml_xpath_context_xpath_func_css_class(xmlXPathParserContextPtr ctxt, int nargs)
|
68
68
|
{
|
69
69
|
xmlXPathObjectPtr hay, needle;
|
70
70
|
|
@@ -85,7 +85,7 @@ xpath_builtin_css_class(xmlXPathParserContextPtr ctxt, int nargs)
|
|
85
85
|
XP_ERROR(XPATH_INVALID_TYPE);
|
86
86
|
}
|
87
87
|
|
88
|
-
if (
|
88
|
+
if (_noko_xml_xpath_context__css_class(hay->stringval, needle->stringval)) {
|
89
89
|
valuePush(ctxt, xmlXPathNewBoolean(1));
|
90
90
|
} else {
|
91
91
|
valuePush(ctxt, xmlXPathNewBoolean(0));
|
@@ -99,7 +99,7 @@ xpath_builtin_css_class(xmlXPathParserContextPtr ctxt, int nargs)
|
|
99
99
|
/* xmlXPathFunction to select nodes whose local name matches, for HTML5 CSS queries that should
|
100
100
|
* ignore namespaces */
|
101
101
|
static void
|
102
|
-
|
102
|
+
noko_xml_xpath_context_xpath_func_local_name_is(xmlXPathParserContextPtr ctxt, int nargs)
|
103
103
|
{
|
104
104
|
xmlXPathObjectPtr element_name;
|
105
105
|
|
@@ -124,25 +124,26 @@ xpath_builtin_local_name_is(xmlXPathParserContextPtr ctxt, int nargs)
|
|
124
124
|
* register_ns(prefix, uri) → Nokogiri::XML::XPathContext
|
125
125
|
*
|
126
126
|
* Register the namespace with +prefix+ and +uri+ for use in future queries.
|
127
|
+
* Passing a uri of +nil+ will unregister the namespace.
|
127
128
|
*
|
128
129
|
* [Returns] +self+
|
129
130
|
*/
|
130
131
|
static VALUE
|
131
|
-
|
132
|
+
noko_xml_xpath_context_register_ns(VALUE rb_context, VALUE prefix, VALUE uri)
|
132
133
|
{
|
133
134
|
xmlXPathContextPtr c_context;
|
135
|
+
const xmlChar *ns_uri;
|
134
136
|
|
135
|
-
TypedData_Get_Struct(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
137
|
+
TypedData_Get_Struct(rb_context, xmlXPathContext, &_noko_xml_xpath_context_type, c_context);
|
138
|
+
|
139
|
+
if (NIL_P(uri)) {
|
140
|
+
ns_uri = NULL;
|
141
|
+
} else {
|
142
|
+
ns_uri = (const xmlChar *)StringValueCStr(uri);
|
143
|
+
}
|
144
|
+
|
145
|
+
xmlXPathRegisterNs(c_context, (const xmlChar *)StringValueCStr(prefix), ns_uri);
|
141
146
|
|
142
|
-
xmlXPathRegisterNs(c_context,
|
143
|
-
(const xmlChar *)StringValueCStr(prefix),
|
144
|
-
(const xmlChar *)StringValueCStr(uri)
|
145
|
-
);
|
146
147
|
return rb_context;
|
147
148
|
}
|
148
149
|
|
@@ -151,29 +152,25 @@ rb_xml_xpath_context_register_ns(VALUE rb_context, VALUE prefix, VALUE uri)
|
|
151
152
|
* register_variable(name, value) → Nokogiri::XML::XPathContext
|
152
153
|
*
|
153
154
|
* Register the variable +name+ with +value+ for use in future queries.
|
155
|
+
* Passing a value of +nil+ will unregister the variable.
|
154
156
|
*
|
155
157
|
* [Returns] +self+
|
156
158
|
*/
|
157
159
|
static VALUE
|
158
|
-
|
160
|
+
noko_xml_xpath_context_register_variable(VALUE rb_context, VALUE name, VALUE value)
|
159
161
|
{
|
160
162
|
xmlXPathContextPtr c_context;
|
161
163
|
xmlXPathObjectPtr xmlValue;
|
162
164
|
|
163
|
-
TypedData_Get_Struct(
|
164
|
-
rb_context,
|
165
|
-
xmlXPathContext,
|
166
|
-
&xml_xpath_context_type,
|
167
|
-
c_context
|
168
|
-
);
|
165
|
+
TypedData_Get_Struct(rb_context, xmlXPathContext, &_noko_xml_xpath_context_type, c_context);
|
169
166
|
|
170
|
-
|
167
|
+
if (NIL_P(value)) {
|
168
|
+
xmlValue = NULL;
|
169
|
+
} else {
|
170
|
+
xmlValue = xmlXPathNewCString(StringValueCStr(value));
|
171
|
+
}
|
171
172
|
|
172
|
-
xmlXPathRegisterVariable(
|
173
|
-
c_context,
|
174
|
-
(const xmlChar *)StringValueCStr(name),
|
175
|
-
xmlValue
|
176
|
-
);
|
173
|
+
xmlXPathRegisterVariable(c_context, (const xmlChar *)StringValueCStr(name), xmlValue);
|
177
174
|
|
178
175
|
return rb_context;
|
179
176
|
}
|
@@ -184,7 +181,7 @@ rb_xml_xpath_context_register_variable(VALUE rb_context, VALUE name, VALUE value
|
|
184
181
|
* returns Qundef if no conversion was possible.
|
185
182
|
*/
|
186
183
|
static VALUE
|
187
|
-
|
184
|
+
_noko_xml_xpath_context__xpath2ruby(xmlXPathObjectPtr c_xpath_object, xmlXPathContextPtr c_context)
|
188
185
|
{
|
189
186
|
VALUE rb_retval;
|
190
187
|
|
@@ -238,7 +235,7 @@ Nokogiri_marshal_xpath_funcall_and_return_values(
|
|
238
235
|
|
239
236
|
for (int j = argc - 1 ; j >= 0 ; --j) {
|
240
237
|
c_xpath_object = valuePop(ctxt);
|
241
|
-
argv[j] =
|
238
|
+
argv[j] = _noko_xml_xpath_context__xpath2ruby(c_xpath_object, ctxt->context);
|
242
239
|
if (argv[j] == Qundef) {
|
243
240
|
argv[j] = NOKOGIRI_STR_NEW2(xmlXPathCastToString(c_xpath_object));
|
244
241
|
}
|
@@ -294,7 +291,7 @@ Nokogiri_marshal_xpath_funcall_and_return_values(
|
|
294
291
|
}
|
295
292
|
|
296
293
|
static void
|
297
|
-
|
294
|
+
_noko_xml_xpath_context__handler_invoker(xmlXPathParserContextPtr ctxt, int argc)
|
298
295
|
{
|
299
296
|
VALUE rb_xpath_handler = Qnil;
|
300
297
|
const char *method_name = NULL ;
|
@@ -316,15 +313,15 @@ method_caller(xmlXPathParserContextPtr ctxt, int argc)
|
|
316
313
|
}
|
317
314
|
|
318
315
|
static xmlXPathFunction
|
319
|
-
|
316
|
+
_noko_xml_xpath_context_handler_lookup(void *data, const xmlChar *c_name, const xmlChar *c_ns_uri)
|
320
317
|
{
|
321
318
|
VALUE rb_handler = (VALUE)data;
|
322
319
|
if (rb_respond_to(rb_handler, rb_intern((const char *)c_name))) {
|
323
320
|
if (c_ns_uri == NULL) {
|
324
321
|
NOKO_WARN_DEPRECATION("A custom XPath or CSS handler function named '%s' is being invoked without a namespace. Please update your query to reference this function as 'nokogiri:%s'. Invoking custom handler functions without a namespace is deprecated and will become an error in Nokogiri v1.17.0.",
|
325
|
-
c_name, c_name); // deprecated in v1.15.0, remove in v1.
|
322
|
+
c_name, c_name); // TODO deprecated in v1.15.0, remove in v1.19.0
|
326
323
|
}
|
327
|
-
return
|
324
|
+
return _noko_xml_xpath_context__handler_invoker;
|
328
325
|
}
|
329
326
|
|
330
327
|
return NULL;
|
@@ -332,7 +329,7 @@ handler_lookup(void *data, const xmlChar *c_name, const xmlChar *c_ns_uri)
|
|
332
329
|
|
333
330
|
PRINTFLIKE_DECL(2, 3)
|
334
331
|
static void
|
335
|
-
|
332
|
+
_noko_xml_xpath_context__generic_exception_pusher(void *data, const char *msg, ...)
|
336
333
|
{
|
337
334
|
VALUE rb_errors = (VALUE)data;
|
338
335
|
VALUE rb_message;
|
@@ -343,7 +340,7 @@ generic_exception_pusher(void *data, const char *msg, ...)
|
|
343
340
|
#ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
|
344
341
|
/* It is not currently possible to pass var args from native
|
345
342
|
functions to sulong, so we work around the issue here. */
|
346
|
-
rb_message = rb_sprintf("
|
343
|
+
rb_message = rb_sprintf("_noko_xml_xpath_context__generic_exception_pusher: %s", msg);
|
347
344
|
#else
|
348
345
|
va_list args;
|
349
346
|
va_start(args, msg);
|
@@ -365,58 +362,55 @@ generic_exception_pusher(void *data, const char *msg, ...)
|
|
365
362
|
* a +Float+, or a boolean.
|
366
363
|
*/
|
367
364
|
static VALUE
|
368
|
-
|
365
|
+
noko_xml_xpath_context_evaluate(int argc, VALUE *argv, VALUE rb_context)
|
369
366
|
{
|
370
|
-
VALUE search_path, xpath_handler;
|
371
|
-
VALUE retval = Qnil;
|
372
367
|
xmlXPathContextPtr c_context;
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
xmlXPathContext,
|
380
|
-
&xml_xpath_context_type,
|
381
|
-
c_context
|
382
|
-
);
|
368
|
+
VALUE rb_expression = Qnil;
|
369
|
+
VALUE rb_function_lookup_handler = Qnil;
|
370
|
+
xmlChar *c_expression_str = NULL;
|
371
|
+
VALUE rb_errors = rb_ary_new();
|
372
|
+
xmlXPathObjectPtr c_xpath_object;
|
373
|
+
VALUE rb_xpath_object = Qnil;
|
383
374
|
|
384
|
-
|
385
|
-
|
386
|
-
|
375
|
+
TypedData_Get_Struct(rb_context, xmlXPathContext, &_noko_xml_xpath_context_type, c_context);
|
376
|
+
|
377
|
+
rb_scan_args(argc, argv, "11", &rb_expression, &rb_function_lookup_handler);
|
387
378
|
|
388
|
-
|
379
|
+
c_expression_str = (xmlChar *)StringValueCStr(rb_expression);
|
389
380
|
|
390
|
-
if (Qnil !=
|
381
|
+
if (Qnil != rb_function_lookup_handler) {
|
391
382
|
/* FIXME: not sure if this is the correct place to shove private data. */
|
392
|
-
c_context->userData = (void *)
|
383
|
+
c_context->userData = (void *)rb_function_lookup_handler;
|
393
384
|
xmlXPathRegisterFuncLookup(
|
394
385
|
c_context,
|
395
|
-
|
396
|
-
(void *)
|
386
|
+
_noko_xml_xpath_context_handler_lookup,
|
387
|
+
(void *)rb_function_lookup_handler
|
397
388
|
);
|
398
389
|
}
|
399
390
|
|
400
|
-
|
401
|
-
|
391
|
+
/* TODO: use xmlXPathSetErrorHandler (as of 2.13.0) */
|
392
|
+
xmlSetStructuredErrorFunc((void *)rb_errors, noko__error_array_pusher);
|
393
|
+
xmlSetGenericErrorFunc((void *)rb_errors, _noko_xml_xpath_context__generic_exception_pusher);
|
402
394
|
|
403
|
-
|
395
|
+
c_xpath_object = xmlXPathEvalExpression(c_expression_str, c_context);
|
404
396
|
|
405
397
|
xmlSetStructuredErrorFunc(NULL, NULL);
|
406
398
|
xmlSetGenericErrorFunc(NULL, NULL);
|
407
399
|
|
408
|
-
|
409
|
-
|
400
|
+
xmlXPathRegisterFuncLookup(c_context, NULL, NULL);
|
401
|
+
|
402
|
+
if (c_xpath_object == NULL) {
|
403
|
+
rb_exc_raise(rb_ary_entry(rb_errors, 0));
|
410
404
|
}
|
411
405
|
|
412
|
-
|
413
|
-
if (
|
414
|
-
|
406
|
+
rb_xpath_object = _noko_xml_xpath_context__xpath2ruby(c_xpath_object, c_context);
|
407
|
+
if (rb_xpath_object == Qundef) {
|
408
|
+
rb_xpath_object = noko_xml_node_set_wrap(NULL, DOC_RUBY_OBJECT(c_context->doc));
|
415
409
|
}
|
416
410
|
|
417
|
-
xmlXPathFreeNodeSetList(
|
411
|
+
xmlXPathFreeNodeSetList(c_xpath_object);
|
418
412
|
|
419
|
-
return
|
413
|
+
return rb_xpath_object;
|
420
414
|
}
|
421
415
|
|
422
416
|
/*
|
@@ -426,45 +420,53 @@ rb_xml_xpath_context_evaluate(int argc, VALUE *argv, VALUE rb_context)
|
|
426
420
|
* Create a new XPathContext with +node+ as the context node.
|
427
421
|
*/
|
428
422
|
static VALUE
|
429
|
-
|
423
|
+
noko_xml_xpath_context_new(VALUE klass, VALUE rb_node)
|
430
424
|
{
|
431
|
-
xmlNodePtr
|
425
|
+
xmlNodePtr c_node;
|
432
426
|
xmlXPathContextPtr c_context;
|
433
427
|
VALUE rb_context;
|
434
428
|
|
435
|
-
Noko_Node_Get_Struct(rb_node, xmlNode,
|
429
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, c_node);
|
436
430
|
|
437
431
|
#if LIBXML_VERSION < 21000
|
438
|
-
/* deprecated in 40483d0 */
|
439
|
-
xmlXPathInit();
|
432
|
+
xmlXPathInit(); /* deprecated in 40483d0 */
|
440
433
|
#endif
|
441
434
|
|
442
|
-
c_context = xmlXPathNewContext(
|
443
|
-
c_context->node =
|
435
|
+
c_context = xmlXPathNewContext(c_node->doc);
|
436
|
+
c_context->node = c_node;
|
444
437
|
|
445
438
|
xmlXPathRegisterNs(c_context, NOKOGIRI_PREFIX, NOKOGIRI_URI);
|
446
439
|
xmlXPathRegisterNs(c_context, NOKOGIRI_BUILTIN_PREFIX, NOKOGIRI_BUILTIN_URI);
|
447
|
-
xmlXPathRegisterFuncNS(
|
448
|
-
c_context,
|
449
|
-
(const xmlChar *)"css-class",
|
450
|
-
NOKOGIRI_BUILTIN_URI,
|
451
|
-
xpath_builtin_css_class
|
452
|
-
);
|
453
|
-
xmlXPathRegisterFuncNS(
|
454
|
-
c_context,
|
455
|
-
(const xmlChar *)"local-name-is",
|
456
|
-
NOKOGIRI_BUILTIN_URI,
|
457
|
-
xpath_builtin_local_name_is
|
458
|
-
);
|
459
440
|
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
441
|
+
xmlXPathRegisterFuncNS(c_context,
|
442
|
+
(const xmlChar *)"css-class", NOKOGIRI_BUILTIN_URI,
|
443
|
+
noko_xml_xpath_context_xpath_func_css_class);
|
444
|
+
xmlXPathRegisterFuncNS(c_context,
|
445
|
+
(const xmlChar *)"local-name-is", NOKOGIRI_BUILTIN_URI,
|
446
|
+
noko_xml_xpath_context_xpath_func_local_name_is);
|
447
|
+
|
448
|
+
rb_context = TypedData_Wrap_Struct(klass, &_noko_xml_xpath_context_type, c_context);
|
449
|
+
|
465
450
|
return rb_context;
|
466
451
|
}
|
467
452
|
|
453
|
+
|
454
|
+
/* :nodoc: */
|
455
|
+
static VALUE
|
456
|
+
noko_xml_xpath_context_set_node(VALUE rb_context, VALUE rb_node)
|
457
|
+
{
|
458
|
+
xmlNodePtr c_node;
|
459
|
+
xmlXPathContextPtr c_context;
|
460
|
+
|
461
|
+
TypedData_Get_Struct(rb_context, xmlXPathContext, &_noko_xml_xpath_context_type, c_context);
|
462
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, c_node);
|
463
|
+
|
464
|
+
c_context->doc = c_node->doc;
|
465
|
+
c_context->node = c_node;
|
466
|
+
|
467
|
+
return rb_node;
|
468
|
+
}
|
469
|
+
|
468
470
|
void
|
469
471
|
noko_init_xml_xpath_context(void)
|
470
472
|
{
|
@@ -475,9 +477,10 @@ noko_init_xml_xpath_context(void)
|
|
475
477
|
|
476
478
|
rb_undef_alloc_func(cNokogiriXmlXpathContext);
|
477
479
|
|
478
|
-
rb_define_singleton_method(cNokogiriXmlXpathContext, "new",
|
480
|
+
rb_define_singleton_method(cNokogiriXmlXpathContext, "new", noko_xml_xpath_context_new, 1);
|
479
481
|
|
480
|
-
rb_define_method(cNokogiriXmlXpathContext, "evaluate",
|
481
|
-
rb_define_method(cNokogiriXmlXpathContext, "register_variable",
|
482
|
-
rb_define_method(cNokogiriXmlXpathContext, "register_ns",
|
482
|
+
rb_define_method(cNokogiriXmlXpathContext, "evaluate", noko_xml_xpath_context_evaluate, -1);
|
483
|
+
rb_define_method(cNokogiriXmlXpathContext, "register_variable", noko_xml_xpath_context_register_variable, 2);
|
484
|
+
rb_define_method(cNokogiriXmlXpathContext, "register_ns", noko_xml_xpath_context_register_ns, 2);
|
485
|
+
rb_define_method(cNokogiriXmlXpathContext, "node=", noko_xml_xpath_context_set_node, 1);
|
483
486
|
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -207,35 +207,26 @@ module Nokogiri
|
|
207
207
|
|
208
208
|
private
|
209
209
|
|
210
|
-
def
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
def xpath_internal(node, paths, handler, ns, binds)
|
215
|
-
document = node.document
|
216
|
-
return NodeSet.new(document) unless document
|
217
|
-
|
218
|
-
if paths.length == 1
|
219
|
-
return xpath_impl(node, paths.first, handler, ns, binds)
|
210
|
+
def extract_params(params) # :nodoc:
|
211
|
+
handler = params.find do |param|
|
212
|
+
![Hash, String, Symbol].include?(param.class)
|
220
213
|
end
|
214
|
+
params -= [handler] if handler
|
221
215
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
216
|
+
hashes = []
|
217
|
+
while Hash === params.last || params.last.nil?
|
218
|
+
hashes << params.pop
|
219
|
+
break if params.empty?
|
226
220
|
end
|
227
|
-
|
221
|
+
ns, binds = hashes.reverse
|
228
222
|
|
229
|
-
|
230
|
-
ctx = XPathContext.new(node)
|
231
|
-
ctx.register_namespaces(ns)
|
232
|
-
path = path.gsub("xmlns:", " :") unless Nokogiri.uses_libxml?
|
223
|
+
ns ||= document.root&.namespaces || {}
|
233
224
|
|
234
|
-
|
235
|
-
|
236
|
-
end
|
225
|
+
[params, handler, ns, binds]
|
226
|
+
end
|
237
227
|
|
238
|
-
|
228
|
+
def css_internal(node, rules, handler, ns)
|
229
|
+
xpath_internal(node, css_rules_to_xpath(rules, ns), handler, ns, nil)
|
239
230
|
end
|
240
231
|
|
241
232
|
def css_rules_to_xpath(rules, ns)
|
@@ -254,22 +245,29 @@ module Nokogiri
|
|
254
245
|
end.join(" | ")
|
255
246
|
end
|
256
247
|
|
257
|
-
def
|
258
|
-
|
259
|
-
|
248
|
+
def xpath_internal(node, paths, handler, ns, binds)
|
249
|
+
document = node.document
|
250
|
+
return NodeSet.new(document) unless document
|
251
|
+
|
252
|
+
if paths.length == 1
|
253
|
+
return xpath_impl(node, paths.first, handler, ns, binds)
|
260
254
|
end
|
261
|
-
params -= [handler] if handler
|
262
255
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
256
|
+
NodeSet.new(document) do |combined|
|
257
|
+
paths.each do |path|
|
258
|
+
xpath_impl(node, path, handler, ns, binds).each { |set| combined << set }
|
259
|
+
end
|
267
260
|
end
|
268
|
-
|
261
|
+
end
|
269
262
|
|
270
|
-
|
263
|
+
def xpath_impl(node, path, handler, ns, binds)
|
264
|
+
context = XPathContext.new(node)
|
265
|
+
context.register_namespaces(ns)
|
266
|
+
context.register_variables(binds)
|
271
267
|
|
272
|
-
|
268
|
+
path = path.gsub("xmlns:", " :") unless Nokogiri.uses_libxml?
|
269
|
+
|
270
|
+
context.evaluate(path, handler)
|
273
271
|
end
|
274
272
|
end
|
275
273
|
end
|
@@ -6,9 +6,20 @@ module Nokogiri
|
|
6
6
|
###
|
7
7
|
# Register namespaces in +namespaces+
|
8
8
|
def register_namespaces(namespaces)
|
9
|
-
namespaces.each do |
|
10
|
-
|
11
|
-
|
9
|
+
namespaces.each do |key, value|
|
10
|
+
key = key.to_s.gsub(/.*:/, "") # strip off 'xmlns:' or 'xml:'
|
11
|
+
|
12
|
+
register_ns(key, value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def register_variables(binds)
|
17
|
+
return if binds.nil?
|
18
|
+
|
19
|
+
binds.each do |key, value|
|
20
|
+
key = key.to_s
|
21
|
+
|
22
|
+
register_variable(key, value)
|
12
23
|
end
|
13
24
|
end
|
14
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokogiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.18.0
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- Mike Dalessio
|
@@ -20,7 +20,7 @@ authors:
|
|
20
20
|
autorequire:
|
21
21
|
bindir: bin
|
22
22
|
cert_chain: []
|
23
|
-
date: 2024-12-
|
23
|
+
date: 2024-12-25 00:00:00.000000000 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: racc
|
@@ -202,10 +202,10 @@ files:
|
|
202
202
|
- gumbo-parser/Makefile
|
203
203
|
- gumbo-parser/THANKS
|
204
204
|
- lib/nokogiri.rb
|
205
|
-
- lib/nokogiri/3.0/nokogiri.bundle
|
206
205
|
- lib/nokogiri/3.1/nokogiri.bundle
|
207
206
|
- lib/nokogiri/3.2/nokogiri.bundle
|
208
207
|
- lib/nokogiri/3.3/nokogiri.bundle
|
208
|
+
- lib/nokogiri/3.4/nokogiri.bundle
|
209
209
|
- lib/nokogiri/class_resolver.rb
|
210
210
|
- lib/nokogiri/css.rb
|
211
211
|
- lib/nokogiri/css/node.rb
|
@@ -304,10 +304,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
304
304
|
requirements:
|
305
305
|
- - ">="
|
306
306
|
- !ruby/object:Gem::Version
|
307
|
-
version: '3.
|
307
|
+
version: '3.1'
|
308
308
|
- - "<"
|
309
309
|
- !ruby/object:Gem::Version
|
310
|
-
version: 3.
|
310
|
+
version: 3.5.dev
|
311
311
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
312
|
requirements:
|
313
313
|
- - ">="
|