nokogiri 1.11.0.rc4 → 1.11.3

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.

Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/LICENSE-DEPENDENCIES.md +12 -12
  4. data/LICENSE.md +1 -1
  5. data/README.md +168 -91
  6. data/ext/nokogiri/depend +34 -474
  7. data/ext/nokogiri/extconf.rb +270 -183
  8. data/ext/nokogiri/html_document.c +10 -15
  9. data/ext/nokogiri/html_element_description.c +84 -71
  10. data/ext/nokogiri/html_entity_lookup.c +21 -16
  11. data/ext/nokogiri/html_sax_parser_context.c +67 -64
  12. data/ext/nokogiri/html_sax_push_parser.c +42 -34
  13. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  14. data/ext/nokogiri/nokogiri.c +171 -60
  15. data/ext/nokogiri/nokogiri.h +158 -75
  16. data/ext/nokogiri/test_global_handlers.c +40 -0
  17. data/ext/nokogiri/xml_attr.c +15 -15
  18. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  19. data/ext/nokogiri/xml_cdata.c +13 -18
  20. data/ext/nokogiri/xml_comment.c +19 -26
  21. data/ext/nokogiri/xml_document.c +246 -188
  22. data/ext/nokogiri/xml_document_fragment.c +13 -15
  23. data/ext/nokogiri/xml_dtd.c +54 -48
  24. data/ext/nokogiri/xml_element_content.c +30 -27
  25. data/ext/nokogiri/xml_element_decl.c +22 -22
  26. data/ext/nokogiri/xml_encoding_handler.c +17 -11
  27. data/ext/nokogiri/xml_entity_decl.c +32 -30
  28. data/ext/nokogiri/xml_entity_reference.c +16 -18
  29. data/ext/nokogiri/xml_namespace.c +56 -49
  30. data/ext/nokogiri/xml_node.c +371 -320
  31. data/ext/nokogiri/xml_node_set.c +168 -156
  32. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  33. data/ext/nokogiri/xml_reader.c +191 -157
  34. data/ext/nokogiri/xml_relax_ng.c +29 -23
  35. data/ext/nokogiri/xml_sax_parser.c +117 -112
  36. data/ext/nokogiri/xml_sax_parser_context.c +101 -84
  37. data/ext/nokogiri/xml_sax_push_parser.c +36 -27
  38. data/ext/nokogiri/xml_schema.c +48 -42
  39. data/ext/nokogiri/xml_syntax_error.c +42 -21
  40. data/ext/nokogiri/xml_text.c +13 -17
  41. data/ext/nokogiri/xml_xpath_context.c +134 -127
  42. data/ext/nokogiri/xslt_stylesheet.c +157 -157
  43. data/lib/nokogiri/css/parser.rb +1 -1
  44. data/lib/nokogiri/extension.rb +26 -0
  45. data/lib/nokogiri/html/document_fragment.rb +15 -15
  46. data/lib/nokogiri/version/constant.rb +1 -1
  47. data/lib/nokogiri/version/info.rb +31 -8
  48. data/lib/nokogiri/xml/document.rb +74 -28
  49. data/lib/nokogiri/xml/node.rb +39 -42
  50. data/lib/nokogiri/xml/reader.rb +2 -9
  51. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  52. data/lib/nokogiri/xml/xpath.rb +1 -3
  53. data/lib/nokogiri.rb +2 -6
  54. data/patches/libxml2/0009-avoid-isnan-isinf.patch +81 -0
  55. data/patches/libxml2/0010-parser.c-shrink-the-input-buffer-when-appropriate.patch +70 -0
  56. data/patches/libxml2/0011-update-automake-files-for-arm64.patch +2511 -0
  57. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2511 -0
  58. metadata +66 -160
  59. data/ext/nokogiri/html_document.h +0 -10
  60. data/ext/nokogiri/html_element_description.h +0 -10
  61. data/ext/nokogiri/html_entity_lookup.h +0 -8
  62. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  63. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  64. data/ext/nokogiri/xml_attr.h +0 -9
  65. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  66. data/ext/nokogiri/xml_cdata.h +0 -9
  67. data/ext/nokogiri/xml_comment.h +0 -9
  68. data/ext/nokogiri/xml_document.h +0 -23
  69. data/ext/nokogiri/xml_document_fragment.h +0 -10
  70. data/ext/nokogiri/xml_dtd.h +0 -10
  71. data/ext/nokogiri/xml_element_content.h +0 -10
  72. data/ext/nokogiri/xml_element_decl.h +0 -9
  73. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  74. data/ext/nokogiri/xml_entity_decl.h +0 -10
  75. data/ext/nokogiri/xml_entity_reference.h +0 -9
  76. data/ext/nokogiri/xml_io.c +0 -63
  77. data/ext/nokogiri/xml_io.h +0 -11
  78. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  79. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  80. data/ext/nokogiri/xml_namespace.h +0 -14
  81. data/ext/nokogiri/xml_node.h +0 -13
  82. data/ext/nokogiri/xml_node_set.h +0 -12
  83. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  84. data/ext/nokogiri/xml_reader.h +0 -10
  85. data/ext/nokogiri/xml_relax_ng.h +0 -9
  86. data/ext/nokogiri/xml_sax_parser.h +0 -39
  87. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  88. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  89. data/ext/nokogiri/xml_schema.h +0 -9
  90. data/ext/nokogiri/xml_syntax_error.h +0 -13
  91. data/ext/nokogiri/xml_text.h +0 -9
  92. data/ext/nokogiri/xml_xpath_context.h +0 -10
  93. data/ext/nokogiri/xslt_stylesheet.h +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9921a07571567ba6a57123d7908a809da81890c73206fc180fdd6e376d59d6c8
4
- data.tar.gz: 444e6ab366d0b5abe7914d4f2f8562b1b1cda6d3d4b4ff7ed95173a20c0442eb
3
+ metadata.gz: 26502f1ceffcb70db4821bae32463f59a8f50b2901010fa516c00dcfeba9d794
4
+ data.tar.gz: 22b116583b2d0313f6517478c8c970d0af2d283ae239a568f57ae26b89938426
5
5
  SHA512:
6
- metadata.gz: b73282ab01ee491a73c5cb0e28ed73643f1152610f08bd0bc7f5e5358a899b95c0f37c34ea622e9d0fe18927867a07993386516c62f675e0a9de5d307c5d299d
7
- data.tar.gz: df0a5ee23faa5ea65df54af7d927fe8ba1fbc0d630d400f04768cd713f979547cb08d9996a9c6beef58c597f02e6ba647bf07153a13c7df76e19e6c26e9ad22e
6
+ metadata.gz: fa4dbd117a666fef11fe169ac8afb9ec98c5fc10f1f35bc87e95490ebf317c2ac5af938bea77de2a1451d8d8c9dac3a6b31ac84b965c1ae163d0f62efbac4d1e
7
+ data.tar.gz: 50a25639ff7ef0ea13d82eac230c8f901ca8baa03fc311b2d694ea07b1dffb7202f0f7d0776b09403b8101c435b8894b98dfa6884cb7d7ee2062d7b15969df55
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -7,22 +7,22 @@ Note that this document is broken into multiple sections, each of which describe
7
7
  <!-- toc -->
8
8
 
9
9
  - [Default platform release ("ruby")](#default-platform-release-ruby)
10
- - [Native LinuxⓇ platform releases ("x86_64-linux" and "arm64-linux")](#native-linux-platform-releases-x86_64-linux-and-arm64-linux)
10
+ - [Native LinuxⓇ platform releases ("x86_64-linux" and "arm64-linux")](#native-linux%E2%93%A1-platform-releases-x86_64-linux-and-arm64-linux)
11
11
  - [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)
12
12
  - [Native WindowsⓇ platform releases ("x86-mingw32" and "x64-mingw32")](#native-windows%E2%93%A1-platform-releases-x86-mingw32-and-x64-mingw32)
13
13
  - [JavaⓇ (JRuby) platform release ("java")](#java%E2%93%A1-jruby-platform-release-java)
14
14
  - [Appendix: Dependencies' License Texts](#appendix-dependencies-license-texts)
15
- * [libxml2](#libxml2)
16
- * [libxslt](#libxslt)
17
- * [zlib](#zlib)
18
- * [libiconv](#libiconv)
19
- * [isorelax](#isorelax)
20
- * [jing](#jing)
21
- * [nekodtd](#nekodtd)
22
- * [nekohtml](#nekohtml)
23
- * [xalan](#xalan)
24
- * [xerces](#xerces)
25
- * [xml-apis](#xml-apis)
15
+ * [libxml2](#libxml2)
16
+ * [libxslt](#libxslt)
17
+ * [zlib](#zlib)
18
+ * [libiconv](#libiconv)
19
+ * [isorelax](#isorelax)
20
+ * [jing](#jing)
21
+ * [nekodtd](#nekodtd)
22
+ * [nekohtml](#nekohtml)
23
+ * [xalan](#xalan)
24
+ * [xerces](#xerces)
25
+ * [xml-apis](#xml-apis)
26
26
 
27
27
  <!-- tocstop -->
28
28
 
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright 2008 -- 2018 by Aaron Patterson, Mike Dalessio, Charles Nutter, Sergio Arbeo, Patrick Mahoney, Yoko Harada, Akinori MUSHA, John Shahid, Lars Kanis
3
+ Copyright 2008 -- 2021 by Mike Dalessio, Aaron Patterson, Yoko Harada, Akinori MUSHA, John Shahid, Karol Bucek, Lars Kanis, Sergio Arbeo, Timothy Elliott, Nobuyoshi Nakada, Charles Nutter, Patrick Mahoney.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
data/README.md CHANGED
@@ -1,27 +1,33 @@
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
22
28
 
23
29
  [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/nokogiri/jobs/cruby-2.7/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/nokogiri)
24
- [![Appveyor CI](https://ci.appveyor.com/api/projects/status/xj2pqwvlxwuwgr06/branch/master?svg=true)](https://ci.appveyor.com/project/flavorjones/nokogiri/branch/master)
30
+ [![Appveyor CI](https://ci.appveyor.com/api/projects/status/xj2pqwvlxwuwgr06/branch/main?svg=true)](https://ci.appveyor.com/project/flavorjones/nokogiri/branch/main)
25
31
  [![Code Climate](https://codeclimate.com/github/sparklemotion/nokogiri.svg)](https://codeclimate.com/github/sparklemotion/nokogiri)
26
32
  [![Test Coverage](https://api.codeclimate.com/v1/badges/59c67b0e8976027a45ad/test_coverage)](https://codeclimate.com/github/sparklemotion/nokogiri/test_coverage)
27
33
 
@@ -30,76 +36,126 @@ 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, Getting Help, and Reporting Issues
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
+ 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.
46
44
 
45
+ [tidelift]: https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme
47
46
 
48
- ## Installation
47
+ ### Reading
49
48
 
50
- If this doesn't work:
49
+ Your first stops for learning more about Nokogiri should be:
51
50
 
52
- ```
53
- gem install nokogiri
54
- ```
51
+ - [API Documentation](https://nokogiri.org/rdoc/index.html)
52
+ - [Tutorials](https://nokogiri.org/tutorials/toc.html)
53
+ - An excellent community-maintained [Cheat Sheet](https://github.com/sparklemotion/nokogiri/wiki/Cheat-sheet)
55
54
 
56
- then please start troubleshooting here:
57
55
 
58
- > https://nokogiri.org/tutorials/installing_nokogiri.html
56
+ ### Ask For Help
59
57
 
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.__
58
+ There are a few ways to ask exploratory questions:
63
59
 
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.
60
+ - The Ruby Discord chat server is active at https://discord.gg/UyQnKrT
61
+ - The Nokogiri mailing list is active at https://groups.google.com/group/nokogiri-talk
62
+ - Open an issue using the "Help Request" template at https://github.com/sparklemotion/nokogiri/issues
67
63
 
64
+ Please do not mail the maintainers at their personal addresses.
68
65
 
69
- ### Binary packages
70
66
 
71
- Binary packages are available for some distributions.
67
+ ### Report A Bug
72
68
 
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
69
+ The Nokogiri bug tracker is at https://github.com/sparklemotion/nokogiri/issues
76
70
 
71
+ Please use the "Bug Report" or "Installation Difficulties" templates.
77
72
 
78
- ## Support
79
73
 
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).
74
+ ### Security and Vulnerability Reporting
81
75
 
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.
76
+ Please report vulnerabilities at https://hackerone.com/nokogiri
87
77
 
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.
78
+ Full information and description of our security policy is in [`SECURITY.md`](SECURITY.md)
89
79
 
90
- [tidelift]: https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme
91
80
 
81
+ ### Semantic Versioning Policy
92
82
 
93
- ## Security and Vulnerability Reporting
83
+ 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)
94
84
 
95
- Please report vulnerabilities at https://hackerone.com/nokogiri
85
+ We bump `Major.Minor.Patch` versions following this guidance:
96
86
 
97
- Full information and description of our security policy is in [`SECURITY.md`](SECURITY.md)
87
+ `Major`: (we've never done this)
88
+
89
+ - Significant backwards-incompatible changes to the public API that would require rewriting existing application code.
90
+ - Some examples of backwards-incompatible changes we might someday consider for a Major release are at [`ROADMAP.md`](ROADMAP.md).
91
+
92
+ `Minor`:
93
+
94
+ - Features and bugfixes.
95
+ - Updating packaged libraries for non-security-related reasons.
96
+ - 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).
97
+ - Backwards-incompatible changes to internal or private methods and constants. These are detailed in the "Changes" section of each changelog entry.
98
+
99
+ `Patch`:
98
100
 
101
+ - Bugfixes.
102
+ - Security updates.
103
+ - Updating packaged libraries for security-related reasons.
99
104
 
100
- ## Synopsis
101
105
 
102
- Nokogiri is a large library, but here is example usage for parsing and examining a document:
106
+ ## Installation
107
+
108
+ Requirements:
109
+
110
+ - Ruby >= 2.5
111
+ - JRuby >= 9.2.0.0
112
+
113
+
114
+ ### Native Gems: Faster, more reliable installation
115
+
116
+ "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.
117
+
118
+ ### Supported Platforms
119
+
120
+ As of v1.11.0, Nokogiri ships pre-compiled, "native" gems for the following platforms:
121
+
122
+ - Linux: `x86-linux` and `x86_64-linux` (req: `glibc >= 2.17`), including musl platforms like Alpine
123
+ - Darwin/MacOS: `x86_64-darwin` and `arm64-darwin`
124
+ - Windows: `x86-mingw32` and `x64-mingw32`
125
+ - Java: any platform running JRuby 9.2 or higher
126
+
127
+ 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'`.
128
+
129
+ 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:
130
+
131
+ ``` sh
132
+ $ gem install nokogiri
133
+ Fetching nokogiri-1.11.0-x86_64-linux.gem
134
+ Successfully installed nokogiri-1.11.0-x86_64-linux
135
+ 1 gem installed
136
+ ```
137
+
138
+
139
+ ### Other Installation Options
140
+
141
+ Because Nokogiri is a C extension, it requires that you have a C compiler toolchain, Ruby development header files, and some system dependencies installed.
142
+
143
+ The following may work for you if you have an appropriately-configured system:
144
+
145
+ ``` bash
146
+ gem install nokogiri
147
+ ```
148
+
149
+ If you have any issues, please visit [Installing Nokogiri](https://nokogiri.org/tutorials/installing_nokogiri.html) for more complete instructions and troubleshooting.
150
+
151
+
152
+ ## How To Use Nokogiri
153
+
154
+ 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).
155
+
156
+ ### Parsing and Querying
157
+
158
+ Here is example usage for parsing and querying a document:
103
159
 
104
160
  ```ruby
105
161
  #! /usr/bin/env ruby
@@ -110,45 +166,24 @@ require 'open-uri'
110
166
  # Fetch and parse HTML document
111
167
  doc = Nokogiri::HTML(URI.open('https://nokogiri.org/tutorials/installing_nokogiri.html'))
112
168
 
113
- puts "### Search for nodes by css"
169
+ # Search for nodes by css
114
170
  doc.css('nav ul.menu li a', 'article h2').each do |link|
115
171
  puts link.content
116
172
  end
117
173
 
118
- puts "### Search for nodes by xpath"
174
+ # Search for nodes by xpath
119
175
  doc.xpath('//nav//ul//li/a', '//article//h2').each do |link|
120
176
  puts link.content
121
177
  end
122
178
 
123
- puts "### Or mix and match."
179
+ # Or mix and match
124
180
  doc.search('nav ul.menu li a', '//article//h2').each do |link|
125
181
  puts link.content
126
182
  end
127
183
  ```
128
184
 
129
185
 
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
186
+ ### Encoding
152
187
 
153
188
  Strings are always stored as UTF-8 internally. Methods that return
154
189
  text values will always return UTF-8 encoded strings. Methods that
@@ -174,27 +209,69 @@ explicitly setting the encoding to EUC-JP on the parser:
174
209
  ```
175
210
 
176
211
 
177
- ## Development
212
+ ## Technical Overview
178
213
 
179
- ```bash
180
- bundle install
181
- bundle exec rake compile test
182
- ```
214
+ ### Guiding Principles
183
215
 
216
+ As noted above, two guiding principles of the software are:
184
217
 
185
- ## Code of Conduct
218
+ - be secure-by-default by treating all documents as **untrusted** by default
219
+ - be a **thin-as-reasonable layer** on top of the underlying parsers, and don't attempt to fix behavioral differences between the parsers
186
220
 
187
- We've adopted the Contributor Covenant code of conduct, which you can read in full in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
221
+ 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).
188
222
 
189
223
 
190
- ## Semantic Versioning
224
+ ### CRuby
191
225
 
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)
226
+ 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).
227
+
228
+ 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.
229
+
230
+ 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.
231
+
232
+ See [`LICENSE-DEPENDENCIES.md`](LICENSE-DEPENDENCIES.md) for more information on which dependencies are provided in which native and source gems.
233
+
234
+
235
+ ### JRuby
236
+
237
+ 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`.
238
+
239
+ These dependencies are provided by pre-compiled jar files packaged in the `java` platform gem.
240
+
241
+ See [`LICENSE-DEPENDENCIES.md`](LICENSE-DEPENDENCIES.md) for more information on which dependencies are provided in which native and source gems.
242
+
243
+
244
+ ## Contributing
245
+
246
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md) for an intro guide to developing Nokogiri.
247
+
248
+
249
+ ## Code of Conduct
250
+
251
+ We've adopted the Contributor Covenant code of conduct, which you can read in full in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
193
252
 
194
- Nokogiri follows [Semantic Versioning](https://semver.org/). See [`CHANGELOG.md`](CHANGELOG.md) for more details.
195
253
 
196
254
  ## License
197
255
 
198
256
  This project is licensed under the terms of the MIT license.
199
257
 
200
258
  See this license at [`LICENSE.md`](LICENSE.md).
259
+
260
+
261
+ ### Dependencies
262
+
263
+ 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.
264
+
265
+
266
+ ## Authors
267
+
268
+ - Mike Dalessio
269
+ - Aaron Patterson
270
+ - Yoko Harada
271
+ - Akinori MUSHA
272
+ - John Shahid
273
+ - Karol Bucek
274
+ - Lars Kanis
275
+ - Sergio Arbeo
276
+ - Timothy Elliott
277
+ - Nobuyoshi Nakada