nokogiri 1.11.1-java → 1.11.6-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/LICENSE-DEPENDENCIES.md +12 -12
- data/LICENSE.md +1 -1
- data/README.md +21 -16
- data/dependencies.yml +12 -12
- data/ext/java/nokogiri/EncodingHandler.java +76 -89
- data/ext/java/nokogiri/HtmlDocument.java +135 -144
- data/ext/java/nokogiri/HtmlElementDescription.java +102 -117
- data/ext/java/nokogiri/HtmlEntityLookup.java +33 -60
- data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -222
- data/ext/java/nokogiri/HtmlSaxPushParser.java +162 -169
- data/ext/java/nokogiri/NokogiriService.java +595 -556
- data/ext/java/nokogiri/XmlAttr.java +118 -126
- data/ext/java/nokogiri/XmlAttributeDecl.java +95 -106
- data/ext/java/nokogiri/XmlCdata.java +35 -58
- data/ext/java/nokogiri/XmlComment.java +46 -67
- data/ext/java/nokogiri/XmlDocument.java +645 -572
- data/ext/java/nokogiri/XmlDocumentFragment.java +125 -137
- data/ext/java/nokogiri/XmlDtd.java +448 -414
- data/ext/java/nokogiri/XmlElement.java +23 -48
- data/ext/java/nokogiri/XmlElementContent.java +343 -316
- data/ext/java/nokogiri/XmlElementDecl.java +124 -125
- data/ext/java/nokogiri/XmlEntityDecl.java +119 -127
- data/ext/java/nokogiri/XmlEntityReference.java +49 -72
- data/ext/java/nokogiri/XmlNamespace.java +175 -175
- data/ext/java/nokogiri/XmlNode.java +1843 -1620
- data/ext/java/nokogiri/XmlNodeSet.java +361 -331
- data/ext/java/nokogiri/XmlProcessingInstruction.java +47 -69
- data/ext/java/nokogiri/XmlReader.java +513 -450
- data/ext/java/nokogiri/XmlRelaxng.java +85 -104
- data/ext/java/nokogiri/XmlSaxParserContext.java +328 -315
- data/ext/java/nokogiri/XmlSaxPushParser.java +227 -220
- data/ext/java/nokogiri/XmlSchema.java +328 -295
- data/ext/java/nokogiri/XmlSyntaxError.java +113 -115
- data/ext/java/nokogiri/XmlText.java +55 -76
- data/ext/java/nokogiri/XmlXpathContext.java +240 -238
- data/ext/java/nokogiri/XsltStylesheet.java +280 -269
- data/ext/java/nokogiri/internals/ClosedStreamException.java +5 -2
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +201 -202
- data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +17 -10
- data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +43 -16
- data/ext/java/nokogiri/internals/NokogiriDomParser.java +63 -80
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +107 -88
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +27 -52
- data/ext/java/nokogiri/internals/NokogiriHandler.java +316 -286
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +736 -652
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +184 -173
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +81 -98
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +64 -79
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +84 -99
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +48 -65
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +116 -131
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -56
- data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +23 -46
- data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +55 -72
- data/ext/java/nokogiri/internals/ParserContext.java +206 -211
- data/ext/java/nokogiri/internals/ReaderNode.java +478 -403
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +822 -739
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +31 -54
- data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +129 -123
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +3 -34
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +206 -207
- data/ext/java/nokogiri/internals/XmlSaxParser.java +22 -47
- data/ext/java/nokogiri/internals/c14n/AttrCompare.java +71 -68
- data/ext/java/nokogiri/internals/c14n/C14nHelper.java +137 -118
- data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +27 -21
- data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +74 -61
- data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +230 -205
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +572 -547
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +17 -10
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +17 -10
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +323 -302
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +232 -219
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +22 -15
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +23 -16
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +23 -16
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +22 -15
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +575 -545
- data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +141 -120
- data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +39 -38
- data/ext/java/nokogiri/internals/c14n/Constants.java +13 -10
- data/ext/java/nokogiri/internals/c14n/ElementProxy.java +279 -247
- data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +66 -53
- data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +44 -37
- data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +135 -120
- data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +59 -48
- data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +384 -334
- data/ext/java/nokogiri/internals/c14n/NodeFilter.java +25 -24
- data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +151 -140
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +456 -423
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1466 -1500
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +626 -574
- data/ext/nokogiri/depend +34 -474
- data/ext/nokogiri/extconf.rb +253 -183
- data/ext/nokogiri/html_document.c +10 -15
- data/ext/nokogiri/html_element_description.c +84 -71
- data/ext/nokogiri/html_entity_lookup.c +21 -16
- data/ext/nokogiri/html_sax_parser_context.c +66 -65
- data/ext/nokogiri/html_sax_push_parser.c +29 -27
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +190 -63
- data/ext/nokogiri/test_global_handlers.c +3 -4
- data/ext/nokogiri/xml_attr.c +15 -15
- data/ext/nokogiri/xml_attribute_decl.c +18 -18
- data/ext/nokogiri/xml_cdata.c +13 -18
- data/ext/nokogiri/xml_comment.c +19 -26
- data/ext/nokogiri/xml_document.c +246 -188
- data/ext/nokogiri/xml_document_fragment.c +13 -15
- data/ext/nokogiri/xml_dtd.c +54 -48
- data/ext/nokogiri/xml_element_content.c +30 -27
- data/ext/nokogiri/xml_element_decl.c +22 -22
- data/ext/nokogiri/xml_encoding_handler.c +17 -11
- data/ext/nokogiri/xml_entity_decl.c +32 -30
- data/ext/nokogiri/xml_entity_reference.c +16 -18
- data/ext/nokogiri/xml_namespace.c +56 -49
- data/ext/nokogiri/xml_node.c +385 -326
- data/ext/nokogiri/xml_node_set.c +168 -156
- data/ext/nokogiri/xml_processing_instruction.c +17 -19
- data/ext/nokogiri/xml_reader.c +191 -157
- data/ext/nokogiri/xml_relax_ng.c +29 -23
- data/ext/nokogiri/xml_sax_parser.c +117 -112
- data/ext/nokogiri/xml_sax_parser_context.c +100 -85
- data/ext/nokogiri/xml_sax_push_parser.c +34 -27
- data/ext/nokogiri/xml_schema.c +48 -42
- data/ext/nokogiri/xml_syntax_error.c +21 -23
- data/ext/nokogiri/xml_text.c +13 -17
- data/ext/nokogiri/xml_xpath_context.c +134 -127
- data/ext/nokogiri/xslt_stylesheet.c +157 -157
- data/lib/nokogiri.rb +1 -22
- data/lib/nokogiri/css/parser.rb +1 -1
- data/lib/nokogiri/extension.rb +26 -0
- data/lib/nokogiri/html/document_fragment.rb +15 -15
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +32 -8
- data/lib/nokogiri/xml/document.rb +74 -28
- data/lib/nokogiri/xml/node.rb +39 -42
- data/lib/nokogiri/xml/reader.rb +2 -9
- data/lib/nokogiri/xml/xpath.rb +1 -3
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
- metadata +7 -8
- data/ext/nokogiri/xml_io.c +0 -63
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7566c9ba7c4bfc525562b8f80e7da42f28780dd7ffa7fb2904e2cea4c6c5d7d
|
4
|
+
data.tar.gz: 570824e9e3a95884c947544fd59205a916f580f8c4ecfd36e92ceebe7b84e3af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2dfd6bec1a38767f3aa2ed4ef45d110d32e72f357a8ff2b6c1cde04b6300f30d136a81b67d429b2991aed4c5687e341577ea3e76be625addaabf68cabdfcdfa
|
7
|
+
data.tar.gz: 618f739f628a5df78c18415ecb0f1fee22b4aa0c5292b349eb7e5e561bd0929b863b5b937c21e4f724b050d54942f469d584374b5a0e0b5c5eda4908bb8413f9
|
data/LICENSE-DEPENDENCIES.md
CHANGED
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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 --
|
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
@@ -27,7 +27,7 @@ Some guiding principles Nokogiri tries to follow:
|
|
27
27
|
## Status
|
28
28
|
|
29
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)
|
30
|
-
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/xj2pqwvlxwuwgr06/branch/
|
30
|
+
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/xj2pqwvlxwuwgr06/branch/main?svg=true)](https://ci.appveyor.com/project/flavorjones/nokogiri/branch/main)
|
31
31
|
[![Code Climate](https://codeclimate.com/github/sparklemotion/nokogiri.svg)](https://codeclimate.com/github/sparklemotion/nokogiri)
|
32
32
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/59c67b0e8976027a45ad/test_coverage)](https://codeclimate.com/github/sparklemotion/nokogiri/test_coverage)
|
33
33
|
|
@@ -36,31 +36,39 @@ Some guiding principles Nokogiri tries to follow:
|
|
36
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)
|
37
37
|
|
38
38
|
|
39
|
-
## Support and
|
39
|
+
## Support, Getting Help, and Reporting Issues
|
40
40
|
|
41
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
|
+
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.
|
44
|
+
|
45
|
+
[tidelift]: https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme
|
46
|
+
|
43
47
|
### Reading
|
44
48
|
|
45
|
-
Your first stops for
|
49
|
+
Your first stops for learning more about Nokogiri should be:
|
46
50
|
|
47
|
-
-
|
51
|
+
- [API Documentation](https://nokogiri.org/rdoc/index.html)
|
52
|
+
- [Tutorials](https://nokogiri.org/tutorials/toc.html)
|
48
53
|
- An excellent community-maintained [Cheat Sheet](https://github.com/sparklemotion/nokogiri/wiki/Cheat-sheet)
|
49
54
|
|
50
55
|
|
51
|
-
###
|
56
|
+
### Ask For Help
|
52
57
|
|
53
|
-
|
58
|
+
There are a few ways to ask exploratory questions:
|
54
59
|
|
55
|
-
- The Discord chat
|
56
|
-
- The Gitter chat channel is https://gitter.im/sparklemotion/nokogiri
|
57
|
-
- The IRC chat channel is `#nokogiri` on freenode.
|
60
|
+
- The Ruby Discord chat server is active at https://discord.gg/UyQnKrT
|
58
61
|
- The Nokogiri mailing list is active at https://groups.google.com/group/nokogiri-talk
|
59
|
-
-
|
62
|
+
- Open an issue using the "Help Request" template at https://github.com/sparklemotion/nokogiri/issues
|
60
63
|
|
61
|
-
|
64
|
+
Please do not mail the maintainers at their personal addresses.
|
62
65
|
|
63
|
-
|
66
|
+
|
67
|
+
### Report A Bug
|
68
|
+
|
69
|
+
The Nokogiri bug tracker is at https://github.com/sparklemotion/nokogiri/issues
|
70
|
+
|
71
|
+
Please use the "Bug Report" or "Installation Difficulties" templates.
|
64
72
|
|
65
73
|
|
66
74
|
### Security and Vulnerability Reporting
|
@@ -235,10 +243,7 @@ See [`LICENSE-DEPENDENCIES.md`](LICENSE-DEPENDENCIES.md) for more information on
|
|
235
243
|
|
236
244
|
## Contributing
|
237
245
|
|
238
|
-
|
239
|
-
bundle install
|
240
|
-
bundle exec rake compile test
|
241
|
-
```
|
246
|
+
See [`CONTRIBUTING.md`](CONTRIBUTING.md) for an intro guide to developing Nokogiri.
|
242
247
|
|
243
248
|
|
244
249
|
## Code of Conduct
|
data/dependencies.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
libxml2:
|
2
|
-
version: "2.9.
|
3
|
-
sha256: "
|
2
|
+
version: "2.9.12"
|
3
|
+
sha256: "c8d6681e38c56f172892c85ddc0852e1fd4b53b4209e7f4ebf17f7e2eae71d92"
|
4
4
|
# manually verified checksum:
|
5
5
|
#
|
6
|
-
# $ gpg --verify libxml2-2.9.
|
7
|
-
# gpg: Signature made
|
6
|
+
# $ gpg --verify libxml2-2.9.12.tar.gz.asc ports/archives/libxml2-2.9.12.tar.gz
|
7
|
+
# gpg: Signature made Thu 13 May 2021 02:59:16 PM EDT
|
8
8
|
# gpg: using RSA key DB46681BB91ADCEA170FA2D415588B26596BEA5D
|
9
9
|
# gpg: Good signature from "Daniel Veillard (Red Hat work email) <veillard@redhat.com>" [unknown]
|
10
10
|
# gpg: aka "Daniel Veillard <Daniel.Veillard@w3.org>" [unknown]
|
@@ -17,14 +17,14 @@ libxml2:
|
|
17
17
|
#
|
18
18
|
# -----BEGIN PGP SIGNATURE-----
|
19
19
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# =
|
20
|
+
# iQEzBAABCAAdFiEE20ZoG7ka3OoXD6LUFViLJllr6l0FAmCddwQACgkQFViLJllr
|
21
|
+
# 6l11LQgAioRTdfmcC+uK/7+6HPtF/3c5zkX6j8VGYuvFBwZ0jayqMRBAl++fcpjE
|
22
|
+
# JUU/JKebSZ/KCYjzyeOWK/i3Gq77iqm3UbZFB85rqu4a5P3gmj/4STWVyAx0KU3z
|
23
|
+
# G3jKqDhJOt7c0acXb5lh2DngfDa1dn/VGcQcIXsqplNxNr4ET7MnSJjZ3nlxYfW2
|
24
|
+
# E5vWBdPCMUeXDBl6MjYvw9XnGGBLUAaEJWoFToG6jKmVf4GAd9nza20jj5dtbcJq
|
25
|
+
# QEOaSDKDr+f9h2NS8haOhJ9vOpy52PdeGzaFlbRkXarGXuAr8kITgATVs8FAqcgv
|
26
|
+
# MoVhmrO5r2hJf0dCM9fZoYqzpMfmNA==
|
27
|
+
# =KfJ9
|
28
28
|
# -----END PGP SIGNATURE-----
|
29
29
|
#
|
30
30
|
|
@@ -1,35 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* (The MIT License)
|
3
|
-
*
|
4
|
-
* Copyright (c) 2008 - 2011:
|
5
|
-
*
|
6
|
-
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
-
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
-
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
-
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
-
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
-
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
-
*
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
-
* a copy of this software and associated documentation files (the
|
15
|
-
* 'Software'), to deal in the Software without restriction, including
|
16
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
-
* the following conditions:
|
20
|
-
*
|
21
|
-
* The above copyright notice and this permission notice shall be
|
22
|
-
* included in all copies or substantial portions of the Software.
|
23
|
-
*
|
24
|
-
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
-
*/
|
32
|
-
|
33
1
|
package nokogiri;
|
34
2
|
|
35
3
|
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
@@ -52,73 +20,92 @@ import org.jruby.runtime.builtin.IRubyObject;
|
|
52
20
|
*
|
53
21
|
* @author Patrick Mahoney <pat@polycrstal.org>
|
54
22
|
*/
|
55
|
-
@JRubyClass(name="Nokogiri::EncodingHandler")
|
56
|
-
public class EncodingHandler extends RubyObject
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
23
|
+
@JRubyClass(name = "Nokogiri::EncodingHandler")
|
24
|
+
public class EncodingHandler extends RubyObject
|
25
|
+
{
|
26
|
+
protected static HashMap<String, String> map = new HashMap<String, String>();
|
27
|
+
static
|
28
|
+
{
|
29
|
+
addInitial();
|
30
|
+
}
|
61
31
|
|
62
|
-
|
32
|
+
protected String name;
|
63
33
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
super(ruby, klass);
|
70
|
-
name = value;
|
71
|
-
}
|
34
|
+
protected static void
|
35
|
+
addInitial()
|
36
|
+
{
|
37
|
+
map.put("UTF-8", "UTF-8");
|
38
|
+
}
|
72
39
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
String value = map.get(key);
|
80
|
-
if (value == null)
|
81
|
-
return ruby.getNil();
|
40
|
+
public
|
41
|
+
EncodingHandler(Ruby ruby, RubyClass klass, String value)
|
42
|
+
{
|
43
|
+
super(ruby, klass);
|
44
|
+
name = value;
|
45
|
+
}
|
82
46
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
47
|
+
@JRubyMethod(name = "[]", meta = true)
|
48
|
+
public static IRubyObject
|
49
|
+
get(ThreadContext context,
|
50
|
+
IRubyObject _klass,
|
51
|
+
IRubyObject keyObj)
|
52
|
+
{
|
53
|
+
Ruby ruby = context.getRuntime();
|
54
|
+
String key = keyObj.toString();
|
55
|
+
String value = map.get(key);
|
56
|
+
if (value == null) {
|
57
|
+
return ruby.getNil();
|
87
58
|
}
|
88
59
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
String value = map.remove(key);
|
95
|
-
if (value == null)
|
96
|
-
return context.getRuntime().getNil();
|
97
|
-
return context.getRuntime().newString(value);
|
98
|
-
}
|
60
|
+
return new EncodingHandler(
|
61
|
+
ruby,
|
62
|
+
getNokogiriClass(ruby, "Nokogiri::EncodingHandler"),
|
63
|
+
value);
|
64
|
+
}
|
99
65
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
66
|
+
@JRubyMethod(meta = true)
|
67
|
+
public static IRubyObject
|
68
|
+
delete (ThreadContext context,
|
69
|
+
IRubyObject _klass,
|
70
|
+
IRubyObject keyObj)
|
71
|
+
{
|
72
|
+
String key = keyObj.toString();
|
73
|
+
String value = map.remove(key);
|
74
|
+
if (value == null) {
|
75
|
+
return context.getRuntime().getNil();
|
106
76
|
}
|
77
|
+
return context.getRuntime().newString(value);
|
78
|
+
}
|
107
79
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
80
|
+
@JRubyMethod(name = "clear_aliases!", meta = true)
|
81
|
+
public static IRubyObject
|
82
|
+
clear_aliases(ThreadContext context,
|
83
|
+
IRubyObject _klass)
|
84
|
+
{
|
85
|
+
map.clear();
|
86
|
+
addInitial();
|
87
|
+
return context.getRuntime().getNil();
|
88
|
+
}
|
116
89
|
|
117
|
-
|
90
|
+
@JRubyMethod(meta = true)
|
91
|
+
public static IRubyObject
|
92
|
+
alias(ThreadContext context,
|
93
|
+
IRubyObject _klass,
|
94
|
+
IRubyObject orig,
|
95
|
+
IRubyObject alias)
|
96
|
+
{
|
97
|
+
String value = map.get(orig.toString());
|
98
|
+
if (value != null) {
|
99
|
+
map.put(alias.toString(), value);
|
118
100
|
}
|
119
101
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
102
|
+
return context.getRuntime().getNil();
|
103
|
+
}
|
104
|
+
|
105
|
+
@JRubyMethod
|
106
|
+
public IRubyObject
|
107
|
+
name(ThreadContext context)
|
108
|
+
{
|
109
|
+
return context.getRuntime().newString(name);
|
110
|
+
}
|
124
111
|
}
|
@@ -1,35 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* (The MIT License)
|
3
|
-
*
|
4
|
-
* Copyright (c) 2008 - 2012:
|
5
|
-
*
|
6
|
-
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
-
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
-
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
-
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
-
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
-
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
-
*
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
-
* a copy of this software and associated documentation files (the
|
15
|
-
* 'Software'), to deal in the Software without restriction, including
|
16
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
-
* the following conditions:
|
20
|
-
*
|
21
|
-
* The above copyright notice and this permission notice shall be
|
22
|
-
* included in all copies or substantial portions of the Software.
|
23
|
-
*
|
24
|
-
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
-
*/
|
32
|
-
|
33
1
|
package nokogiri;
|
34
2
|
|
35
3
|
import org.jruby.Ruby;
|
@@ -55,124 +23,147 @@ import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
|
55
23
|
* @author sergio
|
56
24
|
* @author Yoko Harada <yokolet@gmail.com>
|
57
25
|
*/
|
58
|
-
@JRubyClass(name="Nokogiri::HTML::Document", parent="Nokogiri::XML::Document")
|
59
|
-
public class HtmlDocument extends XmlDocument
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
26
|
+
@JRubyClass(name = "Nokogiri::HTML::Document", parent = "Nokogiri::XML::Document")
|
27
|
+
public class HtmlDocument extends XmlDocument
|
28
|
+
{
|
29
|
+
private static final String DEFAULT_CONTENT_TYPE = "html";
|
30
|
+
private static final String DEFAULT_PUBLIC_ID = "-//W3C//DTD HTML 4.01//EN";
|
31
|
+
private static final String DEFAULT_SYTEM_ID = "http://www.w3.org/TR/html4/strict.dtd";
|
32
|
+
|
33
|
+
private String parsed_encoding = null;
|
34
|
+
|
35
|
+
public
|
36
|
+
HtmlDocument(Ruby ruby, RubyClass klazz)
|
37
|
+
{
|
38
|
+
super(ruby, klazz);
|
39
|
+
}
|
40
|
+
|
41
|
+
public
|
42
|
+
HtmlDocument(Ruby runtime, Document document)
|
43
|
+
{
|
44
|
+
this(runtime, getNokogiriClass(runtime, "Nokogiri::XML::Document"), document);
|
45
|
+
}
|
46
|
+
|
47
|
+
public
|
48
|
+
HtmlDocument(Ruby ruby, RubyClass klazz, Document doc)
|
49
|
+
{
|
50
|
+
super(ruby, klazz, doc);
|
51
|
+
}
|
52
|
+
|
53
|
+
@JRubyMethod(name = "new", meta = true, rest = true, required = 0)
|
54
|
+
public static IRubyObject
|
55
|
+
rbNew(ThreadContext context, IRubyObject klazz, IRubyObject[] args)
|
56
|
+
{
|
57
|
+
final Ruby runtime = context.runtime;
|
58
|
+
HtmlDocument htmlDocument;
|
59
|
+
try {
|
60
|
+
Document docNode = createNewDocument(runtime);
|
61
|
+
htmlDocument = (HtmlDocument) NokogiriService.HTML_DOCUMENT_ALLOCATOR.allocate(runtime, (RubyClass) klazz);
|
62
|
+
htmlDocument.setDocumentNode(context.runtime, docNode);
|
63
|
+
} catch (Exception ex) {
|
64
|
+
throw asRuntimeError(runtime, "couldn't create document: ", ex);
|
68
65
|
}
|
69
66
|
|
70
|
-
|
71
|
-
|
67
|
+
Helpers.invoke(context, htmlDocument, "initialize", args);
|
68
|
+
|
69
|
+
return htmlDocument;
|
70
|
+
}
|
71
|
+
|
72
|
+
public IRubyObject
|
73
|
+
getInternalSubset(ThreadContext context)
|
74
|
+
{
|
75
|
+
IRubyObject internalSubset = super.getInternalSubset(context);
|
76
|
+
|
77
|
+
// html documents are expected to have a default internal subset
|
78
|
+
// the default values are the same ones used when the following
|
79
|
+
// feature is turned on
|
80
|
+
// "http://cyberneko.org/html/features/insert-doctype"
|
81
|
+
// the reason we don't turn it on, is because it overrides the document's
|
82
|
+
// declared doctype declaration.
|
83
|
+
|
84
|
+
if (internalSubset.isNil()) {
|
85
|
+
internalSubset = XmlDtd.newEmpty(context.getRuntime(),
|
86
|
+
getDocument(),
|
87
|
+
context.getRuntime().newString(DEFAULT_CONTENT_TYPE),
|
88
|
+
context.getRuntime().newString(DEFAULT_PUBLIC_ID),
|
89
|
+
context.getRuntime().newString(DEFAULT_SYTEM_ID));
|
90
|
+
setInternalSubset(internalSubset);
|
72
91
|
}
|
73
92
|
|
74
|
-
|
75
|
-
|
93
|
+
return internalSubset;
|
94
|
+
}
|
95
|
+
|
96
|
+
@Override
|
97
|
+
void
|
98
|
+
init(Ruby runtime, Document document)
|
99
|
+
{
|
100
|
+
stabilizeTextContent(document);
|
101
|
+
document.normalize();
|
102
|
+
setInstanceVariable("@decorators", runtime.getNil());
|
103
|
+
if (document.getDocumentElement() != null) {
|
104
|
+
stabilizeAttrs(document.getDocumentElement());
|
76
105
|
}
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
106
|
+
}
|
107
|
+
|
108
|
+
private static void
|
109
|
+
stabilizeAttrs(Node node)
|
110
|
+
{
|
111
|
+
if (node.hasAttributes()) {
|
112
|
+
NamedNodeMap nodeMap = node.getAttributes();
|
113
|
+
for (int i = 0; i < nodeMap.getLength(); i++) {
|
114
|
+
Node n = nodeMap.item(i);
|
115
|
+
if (n instanceof Attr) {
|
116
|
+
stabilizeAttr((Attr) n);
|
88
117
|
}
|
89
|
-
|
90
|
-
Helpers.invoke(context, htmlDocument, "initialize", args);
|
91
|
-
|
92
|
-
return htmlDocument;
|
118
|
+
}
|
93
119
|
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
// html documents are expected to have a default internal subset
|
99
|
-
// the default values are the same ones used when the following
|
100
|
-
// feature is turned on
|
101
|
-
// "http://cyberneko.org/html/features/insert-doctype"
|
102
|
-
// the reason we don't turn it on, is because it overrides the document's
|
103
|
-
// declared doctype declaration.
|
104
|
-
|
105
|
-
if (internalSubset.isNil()) {
|
106
|
-
internalSubset = XmlDtd.newEmpty(context.getRuntime(),
|
107
|
-
getDocument(),
|
108
|
-
context.getRuntime().newString(DEFAULT_CONTENT_TYPE),
|
109
|
-
context.getRuntime().newString(DEFAULT_PUBLIC_ID),
|
110
|
-
context.getRuntime().newString(DEFAULT_SYTEM_ID));
|
111
|
-
setInternalSubset(internalSubset);
|
112
|
-
}
|
113
|
-
|
114
|
-
return internalSubset;
|
115
|
-
}
|
116
|
-
|
117
|
-
@Override
|
118
|
-
void init(Ruby runtime, Document document) {
|
119
|
-
stabilizeTextContent(document);
|
120
|
-
document.normalize();
|
121
|
-
setInstanceVariable("@decorators", runtime.getNil());
|
122
|
-
if (document.getDocumentElement() != null) {
|
123
|
-
stabilizeAttrs(document.getDocumentElement());
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
private static void stabilizeAttrs(Node node) {
|
128
|
-
if (node.hasAttributes()) {
|
129
|
-
NamedNodeMap nodeMap = node.getAttributes();
|
130
|
-
for (int i=0; i<nodeMap.getLength(); i++) {
|
131
|
-
Node n = nodeMap.item(i);
|
132
|
-
if (n instanceof Attr) {
|
133
|
-
stabilizeAttr((Attr) n);
|
134
|
-
}
|
135
|
-
}
|
136
|
-
}
|
137
|
-
NodeList children = node.getChildNodes();
|
138
|
-
for (int i=0; i<children.getLength(); i++) {
|
139
|
-
stabilizeAttrs(children.item(i));
|
140
|
-
}
|
141
|
-
}
|
142
|
-
|
143
|
-
public void setParsedEncoding(String encoding) {
|
144
|
-
parsed_encoding = encoding;
|
145
|
-
}
|
146
|
-
|
147
|
-
public String getPraedEncoding() {
|
148
|
-
return parsed_encoding;
|
149
|
-
}
|
150
|
-
|
151
|
-
/*
|
152
|
-
* call-seq:
|
153
|
-
* read_io(io, url, encoding, options)
|
154
|
-
*
|
155
|
-
* Read the HTML document from +io+ with given +url+, +encoding+,
|
156
|
-
* and +options+. See Nokogiri::HTML.parse
|
157
|
-
*/
|
158
|
-
@JRubyMethod(meta = true, required = 4)
|
159
|
-
public static IRubyObject read_io(ThreadContext context, IRubyObject klass, IRubyObject[] args) {
|
160
|
-
HtmlDomParserContext ctx = new HtmlDomParserContext(context.runtime, args[2], args[3]);
|
161
|
-
ctx.setIOInputSource(context, args[0], args[1]);
|
162
|
-
return ctx.parse(context, (RubyClass) klass, args[1]);
|
163
|
-
}
|
164
|
-
|
165
|
-
/*
|
166
|
-
* call-seq:
|
167
|
-
* read_memory(string, url, encoding, options)
|
168
|
-
*
|
169
|
-
* Read the HTML document contained in +string+ with given +url+, +encoding+,
|
170
|
-
* and +options+. See Nokogiri::HTML.parse
|
171
|
-
*/
|
172
|
-
@JRubyMethod(meta = true, required = 4)
|
173
|
-
public static IRubyObject read_memory(ThreadContext context, IRubyObject klass, IRubyObject[] args) {
|
174
|
-
HtmlDomParserContext ctx = new HtmlDomParserContext(context.runtime, args[2], args[3]);
|
175
|
-
ctx.setStringInputSource(context, args[0], args[1]);
|
176
|
-
return ctx.parse(context, (RubyClass) klass, args[1]);
|
120
|
+
NodeList children = node.getChildNodes();
|
121
|
+
for (int i = 0; i < children.getLength(); i++) {
|
122
|
+
stabilizeAttrs(children.item(i));
|
177
123
|
}
|
124
|
+
}
|
125
|
+
|
126
|
+
public void
|
127
|
+
setParsedEncoding(String encoding)
|
128
|
+
{
|
129
|
+
parsed_encoding = encoding;
|
130
|
+
}
|
131
|
+
|
132
|
+
public String
|
133
|
+
getPraedEncoding()
|
134
|
+
{
|
135
|
+
return parsed_encoding;
|
136
|
+
}
|
137
|
+
|
138
|
+
/*
|
139
|
+
* call-seq:
|
140
|
+
* read_io(io, url, encoding, options)
|
141
|
+
*
|
142
|
+
* Read the HTML document from +io+ with given +url+, +encoding+,
|
143
|
+
* and +options+. See Nokogiri::HTML.parse
|
144
|
+
*/
|
145
|
+
@JRubyMethod(meta = true, required = 4)
|
146
|
+
public static IRubyObject
|
147
|
+
read_io(ThreadContext context, IRubyObject klass, IRubyObject[] args)
|
148
|
+
{
|
149
|
+
HtmlDomParserContext ctx = new HtmlDomParserContext(context.runtime, args[2], args[3]);
|
150
|
+
ctx.setIOInputSource(context, args[0], args[1]);
|
151
|
+
return ctx.parse(context, (RubyClass) klass, args[1]);
|
152
|
+
}
|
153
|
+
|
154
|
+
/*
|
155
|
+
* call-seq:
|
156
|
+
* read_memory(string, url, encoding, options)
|
157
|
+
*
|
158
|
+
* Read the HTML document contained in +string+ with given +url+, +encoding+,
|
159
|
+
* and +options+. See Nokogiri::HTML.parse
|
160
|
+
*/
|
161
|
+
@JRubyMethod(meta = true, required = 4)
|
162
|
+
public static IRubyObject
|
163
|
+
read_memory(ThreadContext context, IRubyObject klass, IRubyObject[] args)
|
164
|
+
{
|
165
|
+
HtmlDomParserContext ctx = new HtmlDomParserContext(context.runtime, args[2], args[3]);
|
166
|
+
ctx.setStringInputSource(context, args[0], args[1]);
|
167
|
+
return ctx.parse(context, (RubyClass) klass, args[1]);
|
168
|
+
}
|
178
169
|
}
|