nokogiri 1.11.0.rc4-java → 1.11.1-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a182d09ad7210fe2a8742dde28ab1024213def7b188e23b1791d8e8b087b324
4
- data.tar.gz: f82d5fc3380688961c8712df3061303dd27a821f033f2fcf27ecee07f8f721d0
3
+ metadata.gz: 7d85f8024902ba0c8e8000b2e697368ccd2b5f3cb24daa6d2696baf09ca8efeb
4
+ data.tar.gz: a34653303414cf3670c64ba5e820d804efa566575b6e6fd0372c587da253e96f
5
5
  SHA512:
6
- metadata.gz: f748183ad8608e7720923692435b594035dd8ee1736c1f0282d5d65a8e329efdb19db80d6372b4fbd52195595ea70c2d7c9aec93e7b29e9a311c6fd2dd5b64f2
7
- data.tar.gz: cb4f27a1b144f3071f9849292f0056c77771d2c75285d54944f1ae4a99089ddd86f6ceafc9816664bcccbd85205840db7bc24ed0a7c9ef000ea3f6b9abd0490a
6
+ metadata.gz: d402f90c16cfbecb8746b9afa8b918735c083b1d6363a86d313911a3329fc936ac9fc2ac12122d2fe21c49d212ba95d7b09d2309dd69ea713afb16e7e5f79814
7
+ data.tar.gz: ec647fdf9fe11f57374ed845cd5cafded912b3ec239cf72cf7a08621772166bb5c9386b271e5513925f0d6ee63d0877629d0c83b721a66fa872df3500c548c69
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/README.md CHANGED
@@ -1,21 +1,27 @@
1
+ <div><img src="https://nokogiri.org/images/nokogiri-serif-black.png" align="right"/></div>
2
+
1
3
  # Nokogiri
2
4
 
3
- ## Description
5
+ Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a sensible, easy-to-understand API for reading, writing, modifying, and querying documents. It is fast and standards-compliant by relying on native parsers like libxml2 (C) and xerces (Java).
6
+
7
+ ## Guiding Principles
8
+
9
+ Some guiding principles Nokogiri tries to follow:
4
10
 
5
- Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among
6
- Nokogiri's many features is the ability to search documents via XPath
7
- or CSS3 selectors.
11
+ - be secure-by-default by treating all documents as **untrusted** by default
12
+ - be a **thin-as-reasonable layer** on top of the underlying parsers, and don't attempt to fix behavioral differences between the parsers
8
13
 
9
14
 
10
- ## Links
15
+ ## Features Overview
11
16
 
12
- * https://nokogiri.org
13
- * [Installation Help](https://nokogiri.org/tutorials/installing_nokogiri.html)
14
- * [Tutorials](https://nokogiri.org/tutorials/toc.html)
15
- * [Cheat Sheet](https://github.com/sparklemotion/nokogiri/wiki/Cheat-sheet)
16
- * [GitHub](https://github.com/sparklemotion/nokogiri)
17
- * [Mailing List](https://groups.google.com/group/nokogiri-talk)
18
- * [Chat/Gitter](https://gitter.im/sparklemotion/nokogiri)
17
+ - DOM Parser for XML and HTML4
18
+ - SAX Parser for XML and HTML4
19
+ - Push Parser for XML and HTML4
20
+ - Document search via XPath 1.0
21
+ - Document search via CSS3 selectors, with some jquery-like extensions
22
+ - XSD Schema validation
23
+ - XSLT transformation
24
+ - "Builder" DSL for XML and HTML documents
19
25
 
20
26
 
21
27
  ## Status
@@ -30,76 +36,118 @@ or CSS3 selectors.
30
36
  [![Tidelift dependencies](https://tidelift.com/badges/package/rubygems/nokogiri)](https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme)
31
37
 
32
38
 
33
- ## Features
39
+ ## Support and Help
34
40
 
35
- * XML/HTML DOM parser which handles broken HTML
36
- * XML/HTML SAX parser
37
- * XML/HTML Push parser
38
- * XPath 1.0 support for document searching
39
- * CSS3 selector support for document searching
40
- * XML/HTML builder
41
- * XSLT transformer
41
+ All official documentation is posted at https://nokogiri.org (the source for which is at https://github.com/sparklemotion/nokogiri.org/, and we welcome contributions).
42
42
 
43
- Nokogiri parses and searches XML/HTML using native libraries (either C
44
- or Java, depending on your Ruby), which means it's fast and
45
- standards-compliant.
43
+ ### Reading
46
44
 
45
+ Your first stops for API documentation should be:
47
46
 
48
- ## Installation
47
+ - RDocs: https://nokogiri.org/rdoc/index.html
48
+ - An excellent community-maintained [Cheat Sheet](https://github.com/sparklemotion/nokogiri/wiki/Cheat-sheet)
49
49
 
50
- If this doesn't work:
51
50
 
52
- ```
53
- gem install nokogiri
54
- ```
51
+ ### Questions
52
+
53
+ If you'd like to talk to a human:
54
+
55
+ - The Discord chat channel is `#nokogiri-💎` at https://discord.gg/UyQnKrT
56
+ - The Gitter chat channel is https://gitter.im/sparklemotion/nokogiri
57
+ - The IRC chat channel is `#nokogiri` on freenode.
58
+ - The Nokogiri mailing list is active at https://groups.google.com/group/nokogiri-talk
59
+ - The Nokogiri bug tracker is at https://github.com/sparklemotion/nokogiri/issues
55
60
 
56
- then please start troubleshooting here:
61
+ Consider subscribing to [Tidelift][tidelift] which provides license assurances and timely security notifications for your open source dependencies, including Nokogiri. [Tidelift][tidelift] subscriptions also help the Nokogiri maintainers fund our [automated testing](https://ci.nokogiri.org) which in turn allows us to ship releases, bugfixes, and security updates more often.
57
62
 
58
- > https://nokogiri.org/tutorials/installing_nokogiri.html
63
+ [tidelift]: https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme
59
64
 
60
- There are currently 1,237 Stack Overflow questions about Nokogiri
61
- installation. The vast majority of them are out of date and therefore
62
- incorrect. __Please do not use Stack Overflow.__
63
65
 
64
- Instead, [tell us](https://nokogiri.org/tutorials/getting_help.html)
65
- when the above instructions don't work for you. This allows us to both
66
- help you directly and improve the documentation.
66
+ ### Security and Vulnerability Reporting
67
67
 
68
+ Please report vulnerabilities at https://hackerone.com/nokogiri
68
69
 
69
- ### Binary packages
70
+ Full information and description of our security policy is in [`SECURITY.md`](SECURITY.md)
70
71
 
71
- Binary packages are available for some distributions.
72
72
 
73
- * Debian: https://packages.debian.org/sid/ruby-nokogiri
74
- * openSUSE/SLE: https://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/
75
- * Fedora: http://s390.koji.fedoraproject.org/koji/packageinfo?packageID=6756
73
+ ### Semantic Versioning Policy
76
74
 
75
+ Nokogiri follows [Semantic Versioning](https://semver.org/) (since 2017 or so). [![Dependabot's SemVer compatibility score for Nokogiri](https://api.dependabot.com/badges/compatibility_score?dependency-name=nokogiri&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score/?dependency-name=nokogiri&package-manager=bundler)
77
76
 
78
- ## Support
77
+ We bump `Major.Minor.Patch` versions following this guidance:
79
78
 
80
- All official documentation is posted at https://nokogiri.org (the source for which is at https://github.com/sparklemotion/nokogiri.org/, and we welcome contributions).
79
+ `Major`: (we've never done this)
81
80
 
82
- * The Nokogiri mailing list is active: https://groups.google.com/group/nokogiri-talk
83
- * The Nokogiri bug tracker is here: https://github.com/sparklemotion/nokogiri/issues
84
- * Before filing a bug report, please read our submission guidelines: http://nokogiri.org/tutorials/getting_help.html
85
- * The IRC channel is `#nokogiri` on freenode.
86
- * The project's GitHub wiki has an excellent community-maintained [Cheat Sheet](https://github.com/sparklemotion/nokogiri/wiki/Cheat-sheet) which might be useful.
81
+ - Significant backwards-incompatible changes to the public API that would require rewriting existing application code.
82
+ - Some examples of backwards-incompatible changes we might someday consider for a Major release are at [`ROADMAP.md`](ROADMAP.md).
87
83
 
88
- Consider subscribing to [Tidelift][tidelift] which provides license assurances and timely security notifications for your open source dependencies, including Nokogiri. [Tidelift][tidelift] subscriptions also help the Nokogiri maintainers fund our [automated testing](https://ci.nokogiri.org) which in turn allows us to ship releases, bugfixes, and security updates more often.
84
+ `Minor`:
89
85
 
90
- [tidelift]: https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme
86
+ - Features and bugfixes.
87
+ - Updating packaged libraries for non-security-related reasons.
88
+ - Dropping support for EOLed Ruby versions. [Some folks find this objectionable](https://github.com/sparklemotion/nokogiri/issues/1568), but [SemVer says this is OK if the public API hasn't changed](https://semver.org/#what-should-i-do-if-i-update-my-own-dependencies-without-changing-the-public-api).
89
+ - Backwards-incompatible changes to internal or private methods and constants. These are detailed in the "Changes" section of each changelog entry.
91
90
 
91
+ `Patch`:
92
92
 
93
- ## Security and Vulnerability Reporting
93
+ - Bugfixes.
94
+ - Security updates.
95
+ - Updating packaged libraries for security-related reasons.
94
96
 
95
- Please report vulnerabilities at https://hackerone.com/nokogiri
96
97
 
97
- Full information and description of our security policy is in [`SECURITY.md`](SECURITY.md)
98
+ ## Installation
99
+
100
+ Requirements:
101
+
102
+ - Ruby >= 2.5
103
+ - JRuby >= 9.2.0.0
104
+
105
+
106
+ ### Native Gems: Faster, more reliable installation
107
+
108
+ "Native gems" contain pre-compiled libraries for a specific machine architecture. On supported platforms, this removes the need for compiling the C extension and the packaged libraries, or for system dependencies to exist. This results in **much faster installation** and **more reliable installation**, which as you probably know are the biggest headaches for Nokogiri users.
109
+
110
+ ### Supported Platforms
111
+
112
+ As of v1.11.0, Nokogiri ships pre-compiled, "native" gems for the following platforms:
113
+
114
+ - Linux: `x86-linux` and `x86_64-linux` (req: `glibc >= 2.17`), including musl platforms like Alpine
115
+ - Darwin/MacOS: `x86_64-darwin` and `arm64-darwin`
116
+ - Windows: `x86-mingw32` and `x64-mingw32`
117
+ - Java: any platform running JRuby 9.2 or higher
118
+
119
+ 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'`.
120
+
121
+ If you're on a supported platform, either `gem install` or `bundle install` should install a native gem without any additional action on your part. This installation should only take a few seconds, and your output should look something like:
122
+
123
+ ``` sh
124
+ $ gem install nokogiri
125
+ Fetching nokogiri-1.11.0-x86_64-linux.gem
126
+ Successfully installed nokogiri-1.11.0-x86_64-linux
127
+ 1 gem installed
128
+ ```
129
+
130
+
131
+ ### Other Installation Options
132
+
133
+ Because Nokogiri is a C extension, it requires that you have a C compiler toolchain, Ruby development header files, and some system dependencies installed.
134
+
135
+ The following may work for you if you have an appropriately-configured system:
136
+
137
+ ``` bash
138
+ gem install nokogiri
139
+ ```
98
140
 
141
+ If you have any issues, please visit [Installing Nokogiri](https://nokogiri.org/tutorials/installing_nokogiri.html) for more complete instructions and troubleshooting.
99
142
 
100
- ## Synopsis
101
143
 
102
- Nokogiri is a large library, but here is example usage for parsing and examining a document:
144
+ ## How To Use Nokogiri
145
+
146
+ Nokogiri is a large library, and so it's challenging to briefly summarize it. We've tried to provide long, real-world examples at [Tutorials](https://nokogiri.org/tutorials/toc.html).
147
+
148
+ ### Parsing and Querying
149
+
150
+ Here is example usage for parsing and querying a document:
103
151
 
104
152
  ```ruby
105
153
  #! /usr/bin/env ruby
@@ -110,45 +158,24 @@ require 'open-uri'
110
158
  # Fetch and parse HTML document
111
159
  doc = Nokogiri::HTML(URI.open('https://nokogiri.org/tutorials/installing_nokogiri.html'))
112
160
 
113
- puts "### Search for nodes by css"
161
+ # Search for nodes by css
114
162
  doc.css('nav ul.menu li a', 'article h2').each do |link|
115
163
  puts link.content
116
164
  end
117
165
 
118
- puts "### Search for nodes by xpath"
166
+ # Search for nodes by xpath
119
167
  doc.xpath('//nav//ul//li/a', '//article//h2').each do |link|
120
168
  puts link.content
121
169
  end
122
170
 
123
- puts "### Or mix and match."
171
+ # Or mix and match
124
172
  doc.search('nav ul.menu li a', '//article//h2').each do |link|
125
173
  puts link.content
126
174
  end
127
175
  ```
128
176
 
129
177
 
130
- ## Requirements
131
-
132
- Ruby 2.5.0 or higher, including any development packages necessary to compile native extensions.
133
-
134
- In Nokogiri 1.6.0 and later libxml2 and libxslt are bundled with the gem, but if you want to use the system versions:
135
-
136
- * First, check out [the long list](http://www.xmlsoft.org/news.html)
137
- of fixes and changes between releases before deciding to use any
138
- version older than is bundled with Nokogiri.
139
-
140
- * At install time, set the environment variable
141
- `NOKOGIRI_USE_SYSTEM_LIBRARIES` or else use the
142
- `--use-system-libraries` argument. (See
143
- https://nokogiri.org/tutorials/installing_nokogiri.html#install-with-system-libraries
144
- for specifics.)
145
-
146
- * libxml2 >=2.6.21 with iconv support (libxml2-dev/-devel is also required)
147
-
148
- * libxslt, built with and supported by the given libxml2 (libxslt-dev/-devel is also required)
149
-
150
-
151
- ## Encoding
178
+ ### Encoding
152
179
 
153
180
  Strings are always stored as UTF-8 internally. Methods that return
154
181
  text values will always return UTF-8 encoded strings. Methods that
@@ -174,11 +201,43 @@ explicitly setting the encoding to EUC-JP on the parser:
174
201
  ```
175
202
 
176
203
 
177
- ## Development
204
+ ## Technical Overview
205
+
206
+ ### Guiding Principles
207
+
208
+ As noted above, two guiding principles of the software are:
209
+
210
+ - be secure-by-default by treating all documents as **untrusted** by default
211
+ - be a **thin-as-reasonable layer** on top of the underlying parsers, and don't attempt to fix behavioral differences between the parsers
212
+
213
+ Notably, despite all parsers being standards-compliant, there are behavioral inconsistencies between the parsers used in the CRuby and JRuby implementations, and Nokogiri does not and should not attempt to remove these inconsistencies. Instead, we surface these differences in the test suite when they are important/semantic; or we intentionally write tests to depend only on the important/semantic bits (omitting whitespace from regex matchers on results, for example).
214
+
215
+
216
+ ### CRuby
217
+
218
+ The Ruby (a.k.a., CRuby, MRI, YARV) implementation is a C extension that depends on libxml2 and libxslt (which in turn depend on zlib and possibly libiconv).
219
+
220
+ These dependencies are met by default by Nokogiri's packaged versions of the libxml2 and libxslt source code, but a configuration option `--use-system-libraries` is provided to allow specification of alternative library locations. See [Installing Nokogiri](https://nokogiri.org/tutorials/installing_nokogiri.html) for full documentation.
221
+
222
+ We provide native gems by pre-compiling libxml2 and libxslt (and potentially zlib and libiconv) and packaging them into the gem file. In this case, no compilation is necessary at installation time, which leads to faster and more reliable installation.
223
+
224
+ See [`LICENSE-DEPENDENCIES.md`](LICENSE-DEPENDENCIES.md) for more information on which dependencies are provided in which native and source gems.
225
+
226
+
227
+ ### JRuby
228
+
229
+ The Java (a.k.a. JRuby) implementation is a Java extension that depends primarily on Xerces and NekoHTML for parsing, though additional dependencies are on `isorelax`, `nekodtd`, `jing`, `serializer`, `xalan-j`, and `xml-apis`.
230
+
231
+ These dependencies are provided by pre-compiled jar files packaged in the `java` platform gem.
232
+
233
+ See [`LICENSE-DEPENDENCIES.md`](LICENSE-DEPENDENCIES.md) for more information on which dependencies are provided in which native and source gems.
234
+
235
+
236
+ ## Contributing
178
237
 
179
238
  ```bash
180
- bundle install
181
- bundle exec rake compile test
239
+ bundle install
240
+ bundle exec rake compile test
182
241
  ```
183
242
 
184
243
 
@@ -187,14 +246,27 @@ explicitly setting the encoding to EUC-JP on the parser:
187
246
  We've adopted the Contributor Covenant code of conduct, which you can read in full in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
188
247
 
189
248
 
190
- ## Semantic Versioning
191
-
192
- [![SemVer compatibility](https://api.dependabot.com/badges/compatibility_score?dependency-name=nokogiri&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score/?dependency-name=nokogiri&package-manager=bundler)
193
-
194
- Nokogiri follows [Semantic Versioning](https://semver.org/). See [`CHANGELOG.md`](CHANGELOG.md) for more details.
195
-
196
249
  ## License
197
250
 
198
251
  This project is licensed under the terms of the MIT license.
199
252
 
200
253
  See this license at [`LICENSE.md`](LICENSE.md).
254
+
255
+
256
+ ### Dependencies
257
+
258
+ Some additional libraries may be distributed with your version of Nokogiri. Please see [`LICENSE-DEPENDENCIES.md`](LICENSE-DEPENDENCIES.md) for a discussion of the variations as well as the licenses thereof.
259
+
260
+
261
+ ## Authors
262
+
263
+ - Mike Dalessio
264
+ - Aaron Patterson
265
+ - Yoko Harada
266
+ - Akinori MUSHA
267
+ - John Shahid
268
+ - Karol Bucek
269
+ - Lars Kanis
270
+ - Sergio Arbeo
271
+ - Timothy Elliott
272
+ - Nobuyoshi Nakada
@@ -33,6 +33,10 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
33
33
  --disable-clean
34
34
  Do not clean out intermediate files after successful build
35
35
 
36
+ --prevent-strip
37
+ Take steps to prevent stripping the symbol table and debugging info from the shared
38
+ library, potentially overriding RbConfig's CFLAGS/LDFLAGS/DLDFLAGS.
39
+
36
40
 
37
41
  Flags only used when using system libraries:
38
42
 
@@ -81,6 +85,7 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
81
85
  --enable-cross-build
82
86
  Enable cross-build mode. (You probably do not want to set this manually.)
83
87
 
88
+
84
89
  Environment variables used:
85
90
 
86
91
  NOKOGIRI_USE_SYSTEM_LIBRARIES
@@ -513,10 +518,22 @@ end
513
518
  # use same c compiler for libxml and libxslt
514
519
  ENV['CC'] = RbConfig::CONFIG['CC']
515
520
 
521
+ if arg_config('--prevent-strip')
522
+ old_cflags = $CFLAGS.split.join(" ")
523
+ old_ldflags = $LDFLAGS.split.join(" ")
524
+ old_dldflags = $DLDFLAGS.split.join(" ")
525
+ $CFLAGS = $CFLAGS.split.reject { |flag| flag == "-s" }.join(" ")
526
+ $LDFLAGS = $LDFLAGS.split.reject { |flag| flag == "-s" }.join(" ")
527
+ $DLDFLAGS = $DLDFLAGS.split.reject { |flag| flag == "-s" }.join(" ")
528
+ puts "Prevent stripping by removing '-s' from $CFLAGS" if old_cflags != $CFLAGS
529
+ puts "Prevent stripping by removing '-s' from $LDFLAGS" if old_ldflags != $LDFLAGS
530
+ puts "Prevent stripping by removing '-s' from $DLDFLAGS" if old_dldflags != $DLDFLAGS
531
+ end
532
+
516
533
  # adopt environment config
517
- append_cflags(ENV["CFLAGS"].split(/\s+/)) if !ENV["CFLAGS"].nil?
518
- append_cppflags(ENV["CPPFLAGS"].split(/\s+/)) if !ENV["CPPFLAGS"].nil?
519
- append_ldflags(ENV["LDFLAGS"].split(/\s+/)) if !ENV["LDFLAGS"].nil?
534
+ append_cflags(ENV["CFLAGS"].split) if !ENV["CFLAGS"].nil?
535
+ append_cppflags(ENV["CPPFLAGS"].split) if !ENV["CPPFLAGS"].nil?
536
+ append_ldflags(ENV["LDFLAGS"].split) if !ENV["LDFLAGS"].nil?
520
537
  $LIBS = concat_flags($LIBS, ENV["LIBS"])
521
538
 
522
539
  append_cflags("-g") # always include debugging information
@@ -92,6 +92,8 @@ parse_with(VALUE self, VALUE sax_handler)
92
92
  ctxt->sax = sax;
93
93
  ctxt->userData = (void *)NOKOGIRI_SAX_TUPLE_NEW(ctxt, sax_handler);
94
94
 
95
+ xmlSetStructuredErrorFunc(NULL, NULL);
96
+
95
97
  rb_ensure(parse_doc, (VALUE)ctxt, parse_doc_finalize, (VALUE)ctxt);
96
98
 
97
99
  return self;
@@ -9,9 +9,10 @@
9
9
  static VALUE native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
10
10
  {
11
11
  xmlParserCtxtPtr ctx;
12
- const char * chunk = NULL;
13
- int size = 0;
14
-
12
+ const char * chunk = NULL;
13
+ int size = 0;
14
+ int status = 0;
15
+ libxmlStructuredErrorHandlerState handler_state;
15
16
 
16
17
  Data_Get_Struct(self, xmlParserCtxt, ctx);
17
18
 
@@ -20,11 +21,16 @@ static VALUE native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
20
21
  size = (int)RSTRING_LEN(_chunk);
21
22
  }
22
23
 
23
- if(htmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0)) {
24
- if (!(ctx->options & XML_PARSE_RECOVER)) {
25
- xmlErrorPtr e = xmlCtxtGetLastError(ctx);
26
- Nokogiri_error_raise(NULL, e);
27
- }
24
+ Nokogiri_structured_error_func_save_and_set(&handler_state, NULL, NULL);
25
+
26
+ status = htmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0);
27
+
28
+ Nokogiri_structured_error_func_restore(&handler_state);
29
+
30
+ if ((status != 0) && !(ctx->options & XML_PARSE_RECOVER)) {
31
+ // TODO: there appear to be no tests for this block
32
+ xmlErrorPtr e = xmlCtxtGetLastError(ctx);
33
+ Nokogiri_error_raise(NULL, e);
28
34
  }
29
35
 
30
36
  return self;
@@ -1,5 +1,7 @@
1
1
  #include <nokogiri.h>
2
2
 
3
+ void init_test_global_handlers(); /* in lieu of test_global_handlers.h */
4
+
3
5
  VALUE mNokogiri ;
4
6
  VALUE mNokogiriXml ;
5
7
  VALUE mNokogiriHtml ;
@@ -132,4 +134,5 @@ void Init_nokogiri()
132
134
  init_xml_relax_ng();
133
135
  init_nokogiri_io();
134
136
  init_xml_encoding_handler();
137
+ init_test_global_handlers();
135
138
  }
@@ -0,0 +1,41 @@
1
+ #include <nokogiri.h>
2
+ #include "libxml/xmlerror.h"
3
+
4
+ static VALUE foreign_error_handler_block = Qnil;
5
+
6
+ static void 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
+ init_test_global_handlers()
36
+ {
37
+ VALUE mNokogiri = rb_define_module("Nokogiri");
38
+ VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");
39
+
40
+ rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0);
41
+ }
@@ -120,6 +120,8 @@ parse_with(VALUE self, VALUE sax_handler)
120
120
  ctxt->sax = sax;
121
121
  ctxt->userData = (void *)NOKOGIRI_SAX_TUPLE_NEW(ctxt, sax_handler);
122
122
 
123
+ xmlSetStructuredErrorFunc(NULL, NULL);
124
+
123
125
  rb_ensure(parse_doc, (VALUE)ctxt, parse_doc_finalize, (VALUE)ctxt);
124
126
 
125
127
  return Qnil;
@@ -35,6 +35,8 @@ static VALUE native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
35
35
  size = (int)RSTRING_LEN(_chunk);
36
36
  }
37
37
 
38
+ xmlSetStructuredErrorFunc(NULL, NULL);
39
+
38
40
  if (xmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0)) {
39
41
  if (!(ctx->options & XML_PARSE_RECOVER)) {
40
42
  xmlErrorPtr e = xmlCtxtGetLastError(ctx);
@@ -1,5 +1,28 @@
1
1
  #include <xml_syntax_error.h>
2
2
 
3
+ void
4
+ Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state)
5
+ {
6
+ /* this method is tightly coupled to the implementation of xmlSetStructuredErrorFunc */
7
+ handler_state->user_data = xmlStructuredErrorContext;
8
+ handler_state->handler = xmlStructuredError;
9
+ }
10
+
11
+ void
12
+ Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state,
13
+ void *user_data,
14
+ xmlStructuredErrorFunc handler)
15
+ {
16
+ Nokogiri_structured_error_func_save(handler_state);
17
+ xmlSetStructuredErrorFunc(user_data, handler);
18
+ }
19
+
20
+ void
21
+ Nokogiri_structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state)
22
+ {
23
+ xmlSetStructuredErrorFunc(handler_state->user_data, handler_state->handler);
24
+ }
25
+
3
26
  void Nokogiri_error_array_pusher(void * ctx, xmlErrorPtr error)
4
27
  {
5
28
  VALUE list = (VALUE)ctx;
@@ -11,7 +11,24 @@ end
11
11
  begin
12
12
  RUBY_VERSION =~ /(\d+\.\d+)/
13
13
  require "nokogiri/#{$1}/nokogiri"
14
- rescue LoadError
14
+ rescue LoadError => e
15
+ if e.message =~ /GLIBC/
16
+ warn <<~EOM
17
+
18
+ ERROR: It looks like you're trying to use Nokogiri as a precompiled native gem on a system with glibc < 2.17:
19
+
20
+ #{e.message}
21
+
22
+ If that's the case, then please install Nokogiri via the `ruby` platform gem:
23
+ gem install nokogiri --platform=ruby
24
+ or:
25
+ bundle config set force_ruby_platform true
26
+
27
+ Please visit https://nokogiri.org/tutorials/installing_nokogiri.html for more help.
28
+
29
+ EOM
30
+ raise e
31
+ end
15
32
  require 'nokogiri/nokogiri'
16
33
  end
17
34
  require 'nokogiri/version'
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Nokogiri
3
3
  # The version of Nokogiri you are using
4
- VERSION = "1.11.0.rc4"
4
+ VERSION = "1.11.1"
5
5
  end
metadata CHANGED
@@ -1,20 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0.rc4
4
+ version: 1.11.1
5
5
  platform: java
6
6
  authors:
7
7
  - Mike Dalessio
8
8
  - Aaron Patterson
9
- - John Shahid
10
9
  - Yoko Harada
11
10
  - Akinori MUSHA
11
+ - John Shahid
12
+ - Karol Bucek
12
13
  - Lars Kanis
13
- - Tim Elliott
14
+ - Sergio Arbeo
15
+ - Timothy Elliott
16
+ - Nobuyoshi Nakada
14
17
  autorequire:
15
18
  bindir: bin
16
19
  cert_chain: []
17
- date: 2020-12-29 00:00:00.000000000 Z
20
+ date: 2021-01-06 00:00:00.000000000 Z
18
21
  dependencies:
19
22
  - !ruby/object:Gem::Dependency
20
23
  requirement: !ruby/object:Gem::Requirement
@@ -35,91 +38,29 @@ dependencies:
35
38
  requirements:
36
39
  - - "~>"
37
40
  - !ruby/object:Gem::Version
38
- version: '0.41'
39
- name: concourse
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '0.41'
47
- - !ruby/object:Gem::Dependency
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: '3.22'
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 3.22.1
56
- name: hoe
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '3.22'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 3.22.1
67
- - !ruby/object:Gem::Dependency
68
- requirement: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '1.2'
73
- name: hoe-bundler
41
+ version: '2.2'
42
+ name: bundler
74
43
  type: :development
75
44
  prerelease: false
76
45
  version_requirements: !ruby/object:Gem::Requirement
77
46
  requirements:
78
47
  - - "~>"
79
48
  - !ruby/object:Gem::Version
80
- version: '1.2'
49
+ version: '2.2'
81
50
  - !ruby/object:Gem::Dependency
82
51
  requirement: !ruby/object:Gem::Requirement
83
52
  requirements:
84
53
  - - "~>"
85
54
  - !ruby/object:Gem::Version
86
- version: '2.0'
87
- name: hoe-debugging
88
- type: :development
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - "~>"
93
- - !ruby/object:Gem::Version
94
- version: '2.0'
95
- - !ruby/object:Gem::Dependency
96
- requirement: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - "~>"
99
- - !ruby/object:Gem::Version
100
- version: '1.0'
101
- name: hoe-gemspec
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '1.0'
109
- - !ruby/object:Gem::Dependency
110
- requirement: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - "~>"
113
- - !ruby/object:Gem::Version
114
- version: '1.6'
115
- name: hoe-git
55
+ version: '0.41'
56
+ name: concourse
116
57
  type: :development
117
58
  prerelease: false
118
59
  version_requirements: !ruby/object:Gem::Requirement
119
60
  requirements:
120
61
  - - "~>"
121
62
  - !ruby/object:Gem::Version
122
- version: '1.6'
63
+ version: '0.41'
123
64
  - !ruby/object:Gem::Dependency
124
65
  requirement: !ruby/object:Gem::Requirement
125
66
  requirements:
@@ -223,7 +164,7 @@ dependencies:
223
164
  requirements:
224
165
  - - "~>"
225
166
  - !ruby/object:Gem::Version
226
- version: '0.88'
167
+ version: '1.7'
227
168
  name: rubocop
228
169
  type: :development
229
170
  prerelease: false
@@ -231,13 +172,13 @@ dependencies:
231
172
  requirements:
232
173
  - - "~>"
233
174
  - !ruby/object:Gem::Version
234
- version: '0.88'
175
+ version: '1.7'
235
176
  - !ruby/object:Gem::Dependency
236
177
  requirement: !ruby/object:Gem::Requirement
237
178
  requirements:
238
179
  - - "~>"
239
180
  - !ruby/object:Gem::Version
240
- version: 0.17.0
181
+ version: '0.20'
241
182
  name: simplecov
242
183
  type: :development
243
184
  prerelease: false
@@ -245,74 +186,68 @@ dependencies:
245
186
  requirements:
246
187
  - - "~>"
247
188
  - !ruby/object:Gem::Version
248
- version: 0.17.0
189
+ version: '0.20'
249
190
  - !ruby/object:Gem::Dependency
250
191
  requirement: !ruby/object:Gem::Requirement
251
192
  requirements:
252
- - - ">="
253
- - !ruby/object:Gem::Version
254
- version: '4.0'
255
- - - "<"
193
+ - - "~>"
256
194
  - !ruby/object:Gem::Version
257
- version: '7'
258
- name: rdoc
195
+ version: '0.9'
196
+ name: yard
259
197
  type: :development
260
198
  prerelease: false
261
199
  version_requirements: !ruby/object:Gem::Requirement
262
200
  requirements:
263
- - - ">="
264
- - !ruby/object:Gem::Version
265
- version: '4.0'
266
- - - "<"
201
+ - - "~>"
267
202
  - !ruby/object:Gem::Version
268
- version: '7'
269
- description: |-
270
- Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among
271
- Nokogiri's many features is the ability to search documents via XPath
272
- or CSS3 selectors.
203
+ version: '0.9'
204
+ description: |
205
+ Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a
206
+ sensible, easy-to-understand API for reading, writing, modifying, and querying documents. It is
207
+ fast and standards-compliant by relying on native parsers like libxml2 (C) and xerces (Java).
273
208
  email: nokogiri-talk@googlegroups.com
274
209
  executables:
275
210
  - nokogiri
276
211
  extensions: []
277
212
  extra_rdoc_files:
278
- - LICENSE-DEPENDENCIES.md
279
- - LICENSE.md
280
- - README.md
281
- - ext/nokogiri/html_document.c
282
- - ext/nokogiri/html_element_description.c
283
- - ext/nokogiri/html_entity_lookup.c
284
- - ext/nokogiri/html_sax_parser_context.c
285
- - ext/nokogiri/html_sax_push_parser.c
286
- - ext/nokogiri/nokogiri.c
213
+ - ext/nokogiri/xml_dtd.c
214
+ - ext/nokogiri/xml_xpath_context.c
287
215
  - ext/nokogiri/xml_attr.c
288
- - ext/nokogiri/xml_attribute_decl.c
289
- - ext/nokogiri/xml_cdata.c
290
216
  - ext/nokogiri/xml_comment.c
291
- - ext/nokogiri/xml_document.c
292
- - ext/nokogiri/xml_document_fragment.c
293
- - ext/nokogiri/xml_dtd.c
217
+ - ext/nokogiri/nokogiri.c
218
+ - ext/nokogiri/xml_sax_parser_context.c
219
+ - ext/nokogiri/xml_node_set.c
220
+ - ext/nokogiri/xml_reader.c
221
+ - ext/nokogiri/xml_libxml2_hacks.c
222
+ - ext/nokogiri/xml_cdata.c
294
223
  - ext/nokogiri/xml_element_content.c
224
+ - ext/nokogiri/html_entity_lookup.c
225
+ - ext/nokogiri/xml_namespace.c
226
+ - ext/nokogiri/xml_io.c
227
+ - ext/nokogiri/xml_document.c
295
228
  - ext/nokogiri/xml_element_decl.c
229
+ - ext/nokogiri/xml_schema.c
230
+ - ext/nokogiri/html_document.c
231
+ - ext/nokogiri/xml_processing_instruction.c
232
+ - ext/nokogiri/xml_text.c
233
+ - ext/nokogiri/xml_syntax_error.c
234
+ - ext/nokogiri/xml_document_fragment.c
235
+ - ext/nokogiri/xml_sax_push_parser.c
296
236
  - ext/nokogiri/xml_encoding_handler.c
237
+ - ext/nokogiri/html_sax_push_parser.c
238
+ - ext/nokogiri/xml_relax_ng.c
297
239
  - ext/nokogiri/xml_entity_decl.c
298
- - ext/nokogiri/xml_entity_reference.c
299
- - ext/nokogiri/xml_io.c
300
- - ext/nokogiri/xml_libxml2_hacks.c
301
- - ext/nokogiri/xml_namespace.c
240
+ - ext/nokogiri/test_global_handlers.c
302
241
  - ext/nokogiri/xml_node.c
303
- - ext/nokogiri/xml_node_set.c
304
- - ext/nokogiri/xml_processing_instruction.c
305
- - ext/nokogiri/xml_reader.c
306
- - ext/nokogiri/xml_relax_ng.c
307
- - ext/nokogiri/xml_sax_parser.c
308
- - ext/nokogiri/xml_sax_parser_context.c
309
- - ext/nokogiri/xml_sax_push_parser.c
310
- - ext/nokogiri/xml_schema.c
311
- - ext/nokogiri/xml_syntax_error.c
312
- - ext/nokogiri/xml_text.c
313
- - ext/nokogiri/xml_xpath_context.c
242
+ - ext/nokogiri/xml_entity_reference.c
314
243
  - ext/nokogiri/xslt_stylesheet.c
244
+ - ext/nokogiri/html_sax_parser_context.c
245
+ - ext/nokogiri/xml_sax_parser.c
246
+ - ext/nokogiri/xml_attribute_decl.c
247
+ - ext/nokogiri/html_element_description.c
248
+ - README.md
315
249
  files:
250
+ - Gemfile
316
251
  - LICENSE-DEPENDENCIES.md
317
252
  - LICENSE.md
318
253
  - README.md
@@ -413,6 +348,7 @@ files:
413
348
  - ext/nokogiri/html_sax_parser_context.c
414
349
  - ext/nokogiri/html_sax_push_parser.c
415
350
  - ext/nokogiri/nokogiri.c
351
+ - ext/nokogiri/test_global_handlers.c
416
352
  - ext/nokogiri/xml_attr.c
417
353
  - ext/nokogiri/xml_attribute_decl.c
418
354
  - ext/nokogiri/xml_cdata.c
@@ -538,12 +474,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
538
474
  version: 2.5.0
539
475
  required_rubygems_version: !ruby/object:Gem::Requirement
540
476
  requirements:
541
- - - ">"
477
+ - - ">="
542
478
  - !ruby/object:Gem::Version
543
- version: 1.3.1
479
+ version: '0'
544
480
  requirements: []
545
481
  rubygems_version: 3.0.6
546
482
  signing_key:
547
483
  specification_version: 4
548
- summary: Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser
484
+ summary: Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby.
549
485
  test_files: []