nokogiri 1.18.8 → 1.19.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -6
  3. data/LICENSE-DEPENDENCIES.md +216 -0
  4. data/README.md +18 -3
  5. data/dependencies.yml +12 -23
  6. data/ext/nokogiri/extconf.rb +3 -2
  7. data/ext/nokogiri/gumbo.c +83 -6
  8. data/ext/nokogiri/html4_document.c +10 -3
  9. data/ext/nokogiri/libxml2_polyfill.c +12 -0
  10. data/ext/nokogiri/nokogiri.c +90 -5
  11. data/ext/nokogiri/nokogiri.h +30 -3
  12. data/ext/nokogiri/xml_attr.c +28 -23
  13. data/ext/nokogiri/xml_document.c +73 -35
  14. data/ext/nokogiri/xml_node.c +151 -52
  15. data/ext/nokogiri/xml_node_set.c +10 -10
  16. data/ext/nokogiri/xml_reader.c +198 -107
  17. data/ext/nokogiri/xml_sax_parser.c +3 -3
  18. data/ext/nokogiri/xml_sax_parser_context.c +38 -7
  19. data/ext/nokogiri/xml_sax_push_parser.c +12 -0
  20. data/ext/nokogiri/xml_xpath_context.c +135 -27
  21. data/ext/nokogiri/xslt_stylesheet.c +154 -22
  22. data/gumbo-parser/src/Makefile +2 -0
  23. data/gumbo-parser/src/hashmap.c +1154 -0
  24. data/gumbo-parser/src/hashmap.h +62 -0
  25. data/gumbo-parser/src/parser.c +49 -13
  26. data/gumbo-parser/src/string_set.c +41 -0
  27. data/gumbo-parser/src/string_set.h +21 -0
  28. data/gumbo-parser/src/tokenizer.c +49 -19
  29. data/lib/nokogiri/class_resolver.rb +0 -2
  30. data/lib/nokogiri/css/parser.rb +35 -18
  31. data/lib/nokogiri/css/parser.y +35 -17
  32. data/lib/nokogiri/css/tokenizer.rb +5 -5
  33. data/lib/nokogiri/css/tokenizer.rex +4 -4
  34. data/lib/nokogiri/css/xpath_visitor.rb +71 -28
  35. data/lib/nokogiri/html5/document.rb +9 -0
  36. data/lib/nokogiri/html5/document_fragment.rb +16 -1
  37. data/lib/nokogiri/html5/node.rb +1 -1
  38. data/lib/nokogiri/html5.rb +16 -0
  39. data/lib/nokogiri/jruby/nokogiri_jars.rb +16 -11
  40. data/lib/nokogiri/version/constant.rb +1 -1
  41. data/lib/nokogiri/version/info.rb +10 -0
  42. data/lib/nokogiri/xml/attr.rb +2 -0
  43. data/lib/nokogiri/xml/attribute_decl.rb +2 -1
  44. data/lib/nokogiri/xml/builder.rb +24 -32
  45. data/lib/nokogiri/xml/document.rb +4 -2
  46. data/lib/nokogiri/xml/dtd.rb +2 -1
  47. data/lib/nokogiri/xml/element_decl.rb +2 -1
  48. data/lib/nokogiri/xml/entity_decl.rb +2 -1
  49. data/lib/nokogiri/xml/node.rb +65 -12
  50. data/lib/nokogiri/xml/parse_options.rb +11 -7
  51. data/lib/nokogiri/xml/sax/document.rb +1 -1
  52. data/lib/nokogiri/xslt/stylesheet.rb +8 -3
  53. data/lib/nokogiri/xslt.rb +11 -2
  54. data/ports/archives/libxml2-2.13.9.tar.xz +0 -0
  55. metadata +8 -4
  56. data/ports/archives/libxml2-2.13.8.tar.xz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04001de0ab4b8543534be620640875efa4269a98e60b34f3af7d9e72a83807e5
4
- data.tar.gz: deca5e00af9e343535f93b9c9696549df903397cf6f942fcb4077d1c7ad56aea
3
+ metadata.gz: 9b6ae8d128fac90392dfbe122d0c1e1e8c056fd6dc1c49cfecdef2ac1d09788f
4
+ data.tar.gz: 315ef5552e29320fe8008f9fceff8316718ce263668bf13d1e2f015715203540
5
5
  SHA512:
6
- metadata.gz: 7ce21b266ca6f5f3ddd51c5e9ff26f0b4941e4e176acfd7c96df845a5b04ef40961bc111d9686958dabaa16bf4003d8d1b0d0547b884c3c6196f03a1b3002bcd
7
- data.tar.gz: cc2ef070c1509d782868df1a79b636d393b79e1c0482d68719ddd73fa3a0382187e9e53556d254afb1338aad2900d6183e70847099c9aa515ff028ce5910e70c
6
+ metadata.gz: 18e131261027295c823d6e4b4d4d0c739ac8dcfc2a5d570409f3081917f39b4c69f6719f55eb4a9e78c34e390c442abb50267bd9e0cfe8a25bfd3076a4de0bdd
7
+ data.tar.gz: 9ac2042bf9ce20532e61b2b0e29b9582127c034914ddf370bde9a6b0b8abad067c1e4030551451c2f171bb3b48981f83b69aa2c8b45ddb939ffd3fe88d1453ba
data/Gemfile CHANGED
@@ -6,19 +6,19 @@ gemspec
6
6
 
7
7
  group :development do
8
8
  # bootstrapping
9
- gem "bundler", "~> 2.3"
10
9
  gem "rake", "13.2.1"
11
10
 
12
11
  # building extensions
13
- gem "rake-compiler", "1.2.8"
14
- gem "rake-compiler-dock", "1.7.0"
12
+ gem "rake-compiler", "1.3.1"
13
+ gem "rake-compiler-dock", "1.11.1"
15
14
 
16
15
  # parser generator
17
16
  gem "rexical", "1.0.8"
18
17
 
19
18
  # tests
20
- gem "minitest", "5.25.4"
21
- gem "minitest-parallel_fork", "2.0.0"
19
+ gem "minitest", "6.0.1"
20
+ gem "minitest-mock", "5.27.0"
21
+ gem "minitest-parallel_fork", "2.1.1"
22
22
  gem "ruby_memcheck", "3.0.0"
23
23
  gem "rubyzip", "~> 2.3.2"
24
24
  gem "simplecov", "= 0.21.2"
@@ -36,5 +36,5 @@ end
36
36
  # `bundle config set --local without rdoc`
37
37
  # Then re-run `bundle install`.
38
38
  group :rdoc do
39
- gem "rdoc", "6.10.0" unless RUBY_PLATFORM == "java" || ENV["CI"]
39
+ gem "rdoc", "7.0.3" unless RUBY_PLATFORM == "java" || ENV["CI"]
40
40
  end
@@ -15,6 +15,7 @@ Note that this document is broken into multiple sections, each of which describe
15
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
+ * [hashmap.c](#hashmapc)
18
19
  * [libgumbo](#libgumbo)
19
20
  * [libxml2](#libxml2)
20
21
  * [libxslt](#libxslt)
@@ -25,6 +26,7 @@ Note that this document is broken into multiple sections, each of which describe
25
26
  * [net.sourceforge.htmlunit:neko-htmlunit](#netsourceforgehtmlunitneko-htmlunit)
26
27
  * [nu.validator:jing](#nuvalidatorjing)
27
28
  * [org.nokogiri:nekodtd](#orgnokogirinekodtd)
29
+ * [org.xmlresolver:xmlresolver](#orgxmlresolverxmlresolver)
28
30
  * [xalan:serializer and xalan:xalan](#xalanserializer-and-xalanxalan)
29
31
  * [xerces:xercesImpl](#xercesxercesimpl)
30
32
  * [xml-apis:xml-apis](#xml-apisxml-apis)
@@ -98,6 +100,7 @@ The Java platform release distributes the following dependencies as compiled jar
98
100
  * [net.sourceforge.htmlunit:neko-htmlunit](#netsourceforgehtmlunitneko-htmlunit)
99
101
  * [nu.validator:jing](#nuvalidatorjing)
100
102
  * [org.nokogiri:nekodtd](#orgnokogirinekodtd)
103
+ * [org.xmlresolver:xmlresolver](#orgxmlresolverxmlresolver)
101
104
  * [xalan:serializer and xalan:xalan](#xalanserializer-and-xalanxalan)
102
105
  * [xerces:xercesImpl](#xercesxercesimpl)
103
106
  * [xml-apis:xml-apis](#xml-apisxml-apis)
@@ -112,6 +115,34 @@ This section contains a subsection for each potentially-distributed dependency,
112
115
  Please see previous sections to understand which of these potential dependencies is actually distributed in the gem file you're downloading and using.
113
116
 
114
117
 
118
+ ### hashmap.c
119
+
120
+ MIT
121
+
122
+ https://github.com/tidwall/hashmap.c/blob/master/LICENSE
123
+
124
+ The MIT License (MIT)
125
+
126
+ Copyright (c) 2020 Joshua J Baker
127
+
128
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
129
+ this software and associated documentation files (the "Software"), to deal in
130
+ the Software without restriction, including without limitation the rights to
131
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
132
+ the Software, and to permit persons to whom the Software is furnished to do so,
133
+ subject to the following conditions:
134
+
135
+ The above copyright notice and this permission notice shall be included in all
136
+ copies or substantial portions of the Software.
137
+
138
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
139
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
140
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
141
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
142
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
143
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
144
+
145
+
115
146
  ### libgumbo
116
147
 
117
148
  Apache 2.0
@@ -1661,6 +1692,191 @@ https://github.com/sparklemotion/nekodtd
1661
1692
  END OF TERMS AND CONDITIONS
1662
1693
 
1663
1694
 
1695
+ ### org.xmlresolver:xmlresolver
1696
+
1697
+ Apache 2.0
1698
+
1699
+ https://xmlresolver.org/
1700
+
1701
+ Apache License
1702
+ Version 2.0, January 2004
1703
+ http://www.apache.org/licenses/
1704
+
1705
+
1706
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1707
+
1708
+ 1. Definitions.
1709
+
1710
+ "License" shall mean the terms and conditions for use, reproduction,
1711
+ and distribution as defined by Sections 1 through 9 of this document.
1712
+
1713
+ "Licensor" shall mean the copyright owner or entity authorized by
1714
+ the copyright owner that is granting the License.
1715
+
1716
+ "Legal Entity" shall mean the union of the acting entity and all
1717
+ other entities that control, are controlled by, or are under common
1718
+ control with that entity. For the purposes of this definition,
1719
+ "control" means (i) the power, direct or indirect, to cause the
1720
+ direction or management of such entity, whether by contract or
1721
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
1722
+ outstanding shares, or (iii) beneficial ownership of such entity.
1723
+
1724
+ "You" (or "Your") shall mean an individual or Legal Entity
1725
+ exercising permissions granted by this License.
1726
+
1727
+ "Source" form shall mean the preferred form for making modifications,
1728
+ including but not limited to software source code, documentation
1729
+ source, and configuration files.
1730
+
1731
+ "Object" form shall mean any form resulting from mechanical
1732
+ transformation or translation of a Source form, including but
1733
+ not limited to compiled object code, generated documentation,
1734
+ and conversions to other media types.
1735
+
1736
+ "Work" shall mean the work of authorship, whether in Source or
1737
+ Object form, made available under the License, as indicated by a
1738
+ copyright notice that is included in or attached to the work
1739
+ (an example is provided in the Appendix below).
1740
+
1741
+ "Derivative Works" shall mean any work, whether in Source or Object
1742
+ form, that is based on (or derived from) the Work and for which the
1743
+ editorial revisions, annotations, elaborations, or other modifications
1744
+ represent, as a whole, an original work of authorship. For the purposes
1745
+ of this License, Derivative Works shall not include works that remain
1746
+ separable from, or merely link (or bind by name) to the interfaces of,
1747
+ the Work and Derivative Works thereof.
1748
+
1749
+ "Contribution" shall mean any work of authorship, including
1750
+ the original version of the Work and any modifications or additions
1751
+ to that Work or Derivative Works thereof, that is intentionally
1752
+ submitted to Licensor for inclusion in the Work by the copyright owner
1753
+ or by an individual or Legal Entity authorized to submit on behalf of
1754
+ the copyright owner. For the purposes of this definition, "submitted"
1755
+ means any form of electronic, verbal, or written communication sent
1756
+ to the Licensor or its representatives, including but not limited to
1757
+ communication on electronic mailing lists, source code control systems,
1758
+ and issue tracking systems that are managed by, or on behalf of, the
1759
+ Licensor for the purpose of discussing and improving the Work, but
1760
+ excluding communication that is conspicuously marked or otherwise
1761
+ designated in writing by the copyright owner as "Not a Contribution."
1762
+
1763
+ "Contributor" shall mean Licensor and any individual or Legal Entity
1764
+ on behalf of whom a Contribution has been received by Licensor and
1765
+ subsequently incorporated within the Work.
1766
+
1767
+ 2. Grant of Copyright License. Subject to the terms and conditions of
1768
+ this License, each Contributor hereby grants to You a perpetual,
1769
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1770
+ copyright license to reproduce, prepare Derivative Works of,
1771
+ publicly display, publicly perform, sublicense, and distribute the
1772
+ Work and such Derivative Works in Source or Object form.
1773
+
1774
+ 3. Grant of Patent License. Subject to the terms and conditions of
1775
+ this License, each Contributor hereby grants to You a perpetual,
1776
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1777
+ (except as stated in this section) patent license to make, have made,
1778
+ use, offer to sell, sell, import, and otherwise transfer the Work,
1779
+ where such license applies only to those patent claims licensable
1780
+ by such Contributor that are necessarily infringed by their
1781
+ Contribution(s) alone or by combination of their Contribution(s)
1782
+ with the Work to which such Contribution(s) was submitted. If You
1783
+ institute patent litigation against any entity (including a
1784
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
1785
+ or a Contribution incorporated within the Work constitutes direct
1786
+ or contributory patent infringement, then any patent licenses
1787
+ granted to You under this License for that Work shall terminate
1788
+ as of the date such litigation is filed.
1789
+
1790
+ 4. Redistribution. You may reproduce and distribute copies of the
1791
+ Work or Derivative Works thereof in any medium, with or without
1792
+ modifications, and in Source or Object form, provided that You
1793
+ meet the following conditions:
1794
+
1795
+ (a) You must give any other recipients of the Work or
1796
+ Derivative Works a copy of this License; and
1797
+
1798
+ (b) You must cause any modified files to carry prominent notices
1799
+ stating that You changed the files; and
1800
+
1801
+ (c) You must retain, in the Source form of any Derivative Works
1802
+ that You distribute, all copyright, patent, trademark, and
1803
+ attribution notices from the Source form of the Work,
1804
+ excluding those notices that do not pertain to any part of
1805
+ the Derivative Works; and
1806
+
1807
+ (d) If the Work includes a "NOTICE" text file as part of its
1808
+ distribution, then any Derivative Works that You distribute must
1809
+ include a readable copy of the attribution notices contained
1810
+ within such NOTICE file, excluding those notices that do not
1811
+ pertain to any part of the Derivative Works, in at least one
1812
+ of the following places: within a NOTICE text file distributed
1813
+ as part of the Derivative Works; within the Source form or
1814
+ documentation, if provided along with the Derivative Works; or,
1815
+ within a display generated by the Derivative Works, if and
1816
+ wherever such third-party notices normally appear. The contents
1817
+ of the NOTICE file are for informational purposes only and
1818
+ do not modify the License. You may add Your own attribution
1819
+ notices within Derivative Works that You distribute, alongside
1820
+ or as an addendum to the NOTICE text from the Work, provided
1821
+ that such additional attribution notices cannot be construed
1822
+ as modifying the License.
1823
+
1824
+ You may add Your own copyright statement to Your modifications and
1825
+ may provide additional or different license terms and conditions
1826
+ for use, reproduction, or distribution of Your modifications, or
1827
+ for any such Derivative Works as a whole, provided Your use,
1828
+ reproduction, and distribution of the Work otherwise complies with
1829
+ the conditions stated in this License.
1830
+
1831
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
1832
+ any Contribution intentionally submitted for inclusion in the Work
1833
+ by You to the Licensor shall be under the terms and conditions of
1834
+ this License, without any additional terms or conditions.
1835
+ Notwithstanding the above, nothing herein shall supersede or modify
1836
+ the terms of any separate license agreement you may have executed
1837
+ with Licensor regarding such Contributions.
1838
+
1839
+ 6. Trademarks. This License does not grant permission to use the trade
1840
+ names, trademarks, service marks, or product names of the Licensor,
1841
+ except as required for reasonable and customary use in describing the
1842
+ origin of the Work and reproducing the content of the NOTICE file.
1843
+
1844
+ 7. Disclaimer of Warranty. Unless required by applicable law or
1845
+ agreed to in writing, Licensor provides the Work (and each
1846
+ Contributor provides its Contributions) on an "AS IS" BASIS,
1847
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1848
+ implied, including, without limitation, any warranties or conditions
1849
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1850
+ PARTICULAR PURPOSE. You are solely responsible for determining the
1851
+ appropriateness of using or redistributing the Work and assume any
1852
+ risks associated with Your exercise of permissions under this License.
1853
+
1854
+ 8. Limitation of Liability. In no event and under no legal theory,
1855
+ whether in tort (including negligence), contract, or otherwise,
1856
+ unless required by applicable law (such as deliberate and grossly
1857
+ negligent acts) or agreed to in writing, shall any Contributor be
1858
+ liable to You for damages, including any direct, indirect, special,
1859
+ incidental, or consequential damages of any character arising as a
1860
+ result of this License or out of the use or inability to use the
1861
+ Work (including but not limited to damages for loss of goodwill,
1862
+ work stoppage, computer failure or malfunction, or any and all
1863
+ other commercial damages or losses), even if such Contributor
1864
+ has been advised of the possibility of such damages.
1865
+
1866
+ 9. Accepting Warranty or Additional Liability. While redistributing
1867
+ the Work or Derivative Works thereof, You may choose to offer,
1868
+ and charge a fee for, acceptance of support, warranty, indemnity,
1869
+ or other liability obligations and/or rights consistent with this
1870
+ License. However, in accepting such obligations, You may act only
1871
+ on Your own behalf and on Your sole responsibility, not on behalf
1872
+ of any other Contributor, and only if You agree to indemnify,
1873
+ defend, and hold each Contributor harmless for any liability
1874
+ incurred by, or claims asserted against, such Contributor by reason
1875
+ of your accepting any such warranty or additional liability.
1876
+
1877
+ END OF TERMS AND CONDITIONS
1878
+
1879
+
1664
1880
  ### xalan:serializer and xalan:xalan
1665
1881
 
1666
1882
  Apache 2.0
data/README.md CHANGED
@@ -114,8 +114,8 @@ You can help sponsor the maintainers of this software through one of these organ
114
114
 
115
115
  Requirements:
116
116
 
117
- - Ruby >= 3.1
118
- - JRuby >= 9.4.0.0
117
+ - Ruby >= 3.2
118
+ - JRuby >= 10.0
119
119
 
120
120
  If you are compiling the native extension against a system version of libxml2:
121
121
 
@@ -135,7 +135,7 @@ Nokogiri ships pre-compiled, "native" gems for the following platforms:
135
135
  - `x86_64-linux-musl`, `aarch64-linux-musl`, and `arm-linux-musl`
136
136
  - Darwin/MacOS: `x86_64-darwin` and `arm64-darwin`
137
137
  - Windows: `x64-mingw-ucrt`
138
- - Java: any platform running JRuby 9.4 or higher
138
+ - Java: any platform running JRuby 10.0 or higher
139
139
 
140
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'`.
141
141
 
@@ -291,3 +291,18 @@ Some additional libraries may be distributed with your version of Nokogiri. Plea
291
291
  - Sergio Arbeo
292
292
  - Timothy Elliott
293
293
  - Nobuyoshi Nakada
294
+
295
+
296
+ ## Sponsors
297
+
298
+ These folks have generously sponsored Nokogiri's development. Thank you for your support!
299
+
300
+ <p class="sponsors">
301
+ <span style="white-space: nowrap;"><a href="https://sentry.io"><img src="https://nokogiri.org/images/sponsors/sentry-icon.png" alt="Sentry" height="44" style="vertical-align: middle;"></a>&nbsp;<b>Sentry</b></span>
302
+ &nbsp;&nbsp;&nbsp;&nbsp;
303
+ <span style="white-space: nowrap;"><a href="https://codecov.io"><img src="https://nokogiri.org/images/sponsors/codecov-icon.png" alt="Codecov" height="44" style="vertical-align: middle;"></a>&nbsp;<b>Codecov</b></span>
304
+ &nbsp;&nbsp;&nbsp;&nbsp;
305
+ <span style="white-space: nowrap;"><a href="https://gusto.com"><img src="https://nokogiri.org/images/sponsors/gusto-icon.png" alt="Gusto" height="44" style="vertical-align: middle;"></a>&nbsp;<b>Gusto</b></span>
306
+ &nbsp;&nbsp;&nbsp;&nbsp;
307
+ <span style="white-space: nowrap;"><a href="https://hasdata.com"><img src="https://nokogiri.org/images/sponsors/hasdata-icon.png" alt="HasData" height="44" style="vertical-align: middle;"></a>&nbsp;<b>HasData</b></span>
308
+ </p>
data/dependencies.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  libxml2:
3
- version: "2.13.8"
4
- sha256: "277294cb33119ab71b2bc81f2f445e9bc9435b893ad15bb2cd2b0e859a0ee84a"
5
- # sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.8.sha256sum
3
+ version: "2.13.9"
4
+ sha256: "a2c9ae7b770da34860050c309f903221c67830c86e4a7e760692b803df95143a"
5
+ # sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.9.sha256sum
6
6
 
7
7
  libxslt:
8
8
  version: "1.1.43"
@@ -15,28 +15,17 @@ zlib:
15
15
  # SHA-256 hash provided on http://zlib.net/
16
16
 
17
17
  libiconv:
18
- version: "1.17"
19
- sha256: "8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313"
20
- # signature verified by following this path:
21
- # - release announced at https://savannah.gnu.org/forum/forum.php?forum_id=10175
22
- # - which links to https://savannah.gnu.org/users/haible as the releaser
23
- # - which links to https://savannah.gnu.org/people/viewgpg.php?user_id=1871 as the gpg key
24
- #
25
- # So:
26
- # - wget -q -O - https://savannah.gnu.org/people/viewgpg.php?user_id=1871 | gpg --import
27
- # gpg: key F5BE8B267C6A406D: 1 signature not checked due to a missing key
18
+ # $ gpg --keyserver keyserver.ubuntu.com --recv 9001B85AF9E1B83DF1BDA942F5BE8B267C6A406D
28
19
  # gpg: key F5BE8B267C6A406D: public key "Bruno Haible (Open Source Development) <bruno@clisp.org>" imported
29
20
  # gpg: Total number processed: 1
30
21
  # gpg: imported: 1
31
- # gpg: marginals needed: 3 completes needed: 1 trust model: pgp
32
- # gpg: depth: 0 valid: 4 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 4u
33
- # gpg: next trustdb check due at 2024-05-09
34
- # - gpg --verify libiconv-1.17.tar.gz.sig ports/archives/libiconv-1.17.tar.gz
35
- # gpg: Signature made Sun 15 May 2022 11:26:42 AM EDT
22
+ # $ gpg --verify libiconv-1.18.tar.gz.sig ports/archives/libiconv-1.18.tar.gz
23
+ # gpg: Signature made Sun 15 Dec 2024 07:26:18 AM EST
36
24
  # gpg: using RSA key 9001B85AF9E1B83DF1BDA942F5BE8B267C6A406D
37
- # gpg: Good signature from "Bruno Haible (Open Source Development) <bruno@clisp.org>" [unknown]
38
- # gpg: WARNING: This key is not certified with a trusted signature!
39
- # gpg: There is no indication that the signature belongs to the owner.
25
+ # gpg: Good signature from "Bruno Haible (Open Source Development) <bruno@clisp.org>" [expired]
26
+ # gpg: Note: This key has expired!
40
27
  # Primary key fingerprint: 9001 B85A F9E1 B83D F1BD A942 F5BE 8B26 7C6A 406D
41
- #
42
- # And this sha256sum is calculated from that verified tarball.
28
+ # $ sha256sum ports/archives/libiconv-1.18.tar.gz
29
+ # 3b08f5f4f9b4eb82f151a7040bfd6fe6c6fb922efe4b1659c66ea933276965e8 ports/archives/libiconv-1.18.tar.gz
30
+ version: "1.18"
31
+ sha256: "3b08f5f4f9b4eb82f151a7040bfd6fe6c6fb922efe4b1659c66ea933276965e8"
@@ -619,7 +619,7 @@ end
619
619
  def needs_darwin_linker_hack
620
620
  config_cross_build? &&
621
621
  darwin? &&
622
- Gem::Requirement.new("~> 3.2").satisfied_by?(Gem::Version.new(RbConfig::CONFIG["ruby_version"].split("+").first))
622
+ Gem::Requirement.new(">= 3.2").satisfied_by?(Gem::Version.new(RbConfig::CONFIG["ruby_version"].split("+").first))
623
623
  end
624
624
 
625
625
  #
@@ -832,7 +832,7 @@ else
832
832
  cross_build_p,
833
833
  ) do |recipe|
834
834
  recipe.files = [{
835
- url: "https://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
835
+ url: "https://ftpmirror.gnu.org/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
836
836
  sha256: dependencies["libiconv"]["sha256"],
837
837
  }]
838
838
 
@@ -1125,6 +1125,7 @@ end
1125
1125
  have_func("xmlCtxtSetOptions") # introduced in libxml2 2.13.0
1126
1126
  have_func("xmlCtxtGetOptions") # introduced in libxml2 2.14.0
1127
1127
  have_func("xmlSwitchEncodingName") # introduced in libxml2 2.13.0
1128
+ have_func("xmlAddIDSafe") # introduced in libxml2 2.13.0
1128
1129
  have_func("rb_category_warning") # introduced in Ruby 3.0 but had trouble resolving this symbol in truffleruby
1129
1130
 
1130
1131
  other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k, v| [k, v].join(":") }.join(",")
data/ext/nokogiri/gumbo.c CHANGED
@@ -113,6 +113,71 @@ set_line(xmlNodePtr node, size_t line)
113
113
  }
114
114
  }
115
115
 
116
+ // This function is essentially xmlNewNsProp, but we skip the full list traversal to append by
117
+ // providing the last property in the linked list as a parameter.
118
+ static xmlAttrPtr
119
+ append_property(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value, xmlAttrPtr last_prop)
120
+ {
121
+ xmlAttrPtr cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
122
+ if (cur == NULL) {
123
+ return NULL;
124
+ }
125
+ memset(cur, 0, sizeof(xmlAttr));
126
+ cur->type = XML_ATTRIBUTE_NODE;
127
+ cur->parent = node;
128
+ xmlDocPtr doc = node->doc;
129
+ cur->doc = doc;
130
+ cur->ns = ns;
131
+
132
+ if ((doc != NULL) && (doc->dict != NULL)) {
133
+ cur->name = (xmlChar *) xmlDictLookup(doc->dict, name, -1);
134
+ } else {
135
+ cur->name = xmlStrdup(name);
136
+ }
137
+ if (cur->name == NULL) {
138
+ goto error;
139
+ }
140
+
141
+ if (value != NULL) {
142
+ cur->children = xmlNewDocText(doc, value);
143
+ if (cur->children == NULL) {
144
+ goto error;
145
+ }
146
+ cur->last = NULL;
147
+ xmlNodePtr tmp = cur->children;
148
+ while (tmp != NULL) {
149
+ tmp->parent = (xmlNodePtr) cur;
150
+ if (tmp->next == NULL) {
151
+ cur->last = tmp;
152
+ }
153
+ tmp = tmp->next;
154
+ }
155
+
156
+ if (doc != NULL) {
157
+ int res = xmlIsID(doc, node, cur);
158
+ if (res < 0) {
159
+ goto error;
160
+ }
161
+ if ((res == 1) && (xmlAddIDSafe(cur, value) < 0)) {
162
+ goto error;
163
+ }
164
+ }
165
+ }
166
+
167
+ if (node->properties == NULL) {
168
+ node->properties = cur;
169
+ } else {
170
+ last_prop->next = cur;
171
+ cur->prev = last_prop;
172
+ }
173
+
174
+ return cur;
175
+
176
+ error:
177
+ xmlFreeProp(cur);
178
+ return (NULL);
179
+ }
180
+
116
181
  // Construct an XML tree rooted at xml_output_node from the Gumbo tree rooted
117
182
  // at gumbo_node.
118
183
  static void
@@ -200,6 +265,7 @@ build_tree(
200
265
  xmlAddChild(xml_node, xml_child);
201
266
 
202
267
  // Add the attributes.
268
+ xmlAttrPtr last_prop = NULL;
203
269
  const GumboVector *attrs = &gumbo_child->v.element.attributes;
204
270
  for (size_t i = 0; i < attrs->length; i++) {
205
271
  const GumboAttribute *attr = attrs->data[i];
@@ -220,7 +286,9 @@ build_tree(
220
286
  default:
221
287
  ns = NULL;
222
288
  }
223
- xmlNewNsProp(xml_child, ns, (const xmlChar *)attr->name, (const xmlChar *)attr->value);
289
+
290
+ // We micromanage the attribute list for performance reasons.
291
+ last_prop = append_property(xml_child, ns, (const xmlChar *)attr->name, (const xmlChar *)attr->value, last_prop);
224
292
  }
225
293
 
226
294
  // Add children for this element.
@@ -373,12 +441,20 @@ parse_continue(VALUE parse_args)
373
441
  } else {
374
442
  doc = new_html_doc(NULL, NULL, NULL);
375
443
  }
376
- args->doc = doc; // Make sure doc gets cleaned up if an error is thrown.
444
+
445
+ // We're about to build the libxml2 tree structure from the Gumbo tree
446
+ // structure. If an exception is raised during tree building, control passes
447
+ // to `parse_cleanup()` which needs to free the newly allocated `xmlDoc`,
448
+ // `doc`. If the tree is successfully constructed, then
449
+ // `noko_xml_document_wrap()` will create a new Ruby object which will own
450
+ // `doc`. In that case, `parse_cleanup()` should not free `doc`.
451
+ args->doc = doc;
377
452
  build_tree(doc, (xmlNodePtr)doc, output->document);
453
+ args->doc = NULL;
378
454
  VALUE rdoc = noko_xml_document_wrap(args->klass, doc);
455
+
379
456
  rb_iv_set(rdoc, "@url", args->url_or_frag);
380
457
  rb_iv_set(rdoc, "@quirks_mode", INT2NUM(output->document->v.document.doc_type_quirks_mode));
381
- args->doc = NULL; // The Ruby runtime now owns doc so don't delete it.
382
458
  add_errors(output, rdoc, args->input, args->url_or_frag);
383
459
  return rdoc;
384
460
  }
@@ -512,6 +588,7 @@ error:
512
588
  continue;
513
589
  }
514
590
  VALUE element_name = rb_funcall(node, name, 0);
591
+ Check_Type(element_name, T_STRING);
515
592
  if (RSTRING_LEN(element_name) == 4
516
593
  && !st_strcasecmp(RSTRING_PTR(element_name), "form")
517
594
  && lookup_namespace(node, false) == GUMBO_NAMESPACE_HTML) {
@@ -568,7 +645,7 @@ error:
568
645
  .output = output,
569
646
  .input = tags,
570
647
  .url_or_frag = doc_fragment,
571
- .doc = (xmlDocPtr)extract_xml_node(doc),
648
+ .doc = NULL,
572
649
  };
573
650
  rb_ensure(fragment_continue, (VALUE)(&args), parse_cleanup, (VALUE)(&args));
574
651
  return Qnil;
@@ -580,9 +657,9 @@ fragment_continue(VALUE parse_args)
580
657
  ParseArgs *args = (ParseArgs *)parse_args;
581
658
  GumboOutput *output = args->output;
582
659
  VALUE doc_fragment = args->url_or_frag;
583
- xmlDocPtr xml_doc = args->doc;
660
+ VALUE doc = rb_funcall(doc_fragment, rb_intern_const("document"), 0);
661
+ xmlDocPtr xml_doc = (xmlDocPtr)extract_xml_node(doc);
584
662
 
585
- args->doc = NULL; // The Ruby runtime owns doc so make sure we don't delete it.
586
663
  xmlNodePtr xml_frag = extract_xml_node(doc_fragment);
587
664
  build_tree(xml_doc, xml_frag, output->root);
588
665
  rb_iv_set(doc_fragment, "@quirks_mode", INT2NUM(output->document->v.document.doc_type_quirks_mode));
@@ -18,8 +18,8 @@ rb_html_document_s_new(int argc, VALUE *argv, VALUE klass)
18
18
  htmlDocPtr doc;
19
19
 
20
20
  rb_scan_args(argc, argv, "0*", &rest);
21
- uri = rb_ary_entry(rest, (long)0);
22
- external_id = rb_ary_entry(rest, (long)1);
21
+ uri = rb_ary_entry(rest, (rb_len_t)0);
22
+ external_id = rb_ary_entry(rest, (rb_len_t)1);
23
23
 
24
24
  doc = htmlNewDoc(
25
25
  RTEST(uri) ? (const xmlChar *)StringValueCStr(uri) : NULL,
@@ -48,10 +48,17 @@ rb_html_document_s_read_io(VALUE klass, VALUE rb_io, VALUE rb_url, VALUE rb_enco
48
48
 
49
49
  xmlSetStructuredErrorFunc((void *)rb_error_list, noko__error_array_pusher);
50
50
 
51
- c_doc = htmlReadIO(noko_io_read, noko_io_close, (void *)rb_io, c_url, c_encoding, options);
51
+ noko_io_read_reset_exception();
52
+ c_doc = htmlReadIO(noko_io_read_protected, noko_io_close, (void *)rb_io, c_url, c_encoding, options);
53
+ VALUE rb_io_read_exception = noko_io_read_take_exception();
52
54
 
53
55
  xmlSetStructuredErrorFunc(NULL, NULL);
54
56
 
57
+ if (!NIL_P(rb_io_read_exception)) {
58
+ xmlFreeDoc(c_doc);
59
+ noko_io_read_raise_exception(rb_io_read_exception);
60
+ }
61
+
55
62
  /*
56
63
  * If EncodingFound has occurred in EncodingReader, make sure to do
57
64
  * a cleanup and propagate the error.
@@ -112,3 +112,15 @@ xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding)
112
112
  return (xmlSwitchToEncoding(ctxt, handler));
113
113
  }
114
114
  #endif
115
+
116
+ #ifndef HAVE_XMLADDIDSAFE
117
+ int
118
+ xmlAddIDSafe(xmlAttrPtr attr, const xmlChar *value)
119
+ {
120
+ xmlIDPtr id = xmlAddID(NULL, attr->doc, value, attr);
121
+ if (id) {
122
+ return 1;
123
+ }
124
+ return 0;
125
+ }
126
+ #endif