nokogiri 1.11.1-java → 1.11.2-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 +20 -15
- data/ext/java/nokogiri/EncodingHandler.java +78 -59
- data/ext/java/nokogiri/HtmlDocument.java +137 -114
- data/ext/java/nokogiri/HtmlElementDescription.java +104 -87
- data/ext/java/nokogiri/HtmlEntityLookup.java +31 -26
- data/ext/java/nokogiri/HtmlSaxParserContext.java +220 -192
- data/ext/java/nokogiri/HtmlSaxPushParser.java +164 -139
- data/ext/java/nokogiri/NokogiriService.java +597 -526
- data/ext/java/nokogiri/XmlAttr.java +120 -96
- data/ext/java/nokogiri/XmlAttributeDecl.java +97 -76
- data/ext/java/nokogiri/XmlCdata.java +35 -26
- data/ext/java/nokogiri/XmlComment.java +48 -37
- data/ext/java/nokogiri/XmlDocument.java +642 -540
- data/ext/java/nokogiri/XmlDocumentFragment.java +127 -107
- data/ext/java/nokogiri/XmlDtd.java +450 -384
- data/ext/java/nokogiri/XmlElement.java +25 -18
- data/ext/java/nokogiri/XmlElementContent.java +345 -286
- data/ext/java/nokogiri/XmlElementDecl.java +126 -95
- data/ext/java/nokogiri/XmlEntityDecl.java +121 -97
- data/ext/java/nokogiri/XmlEntityReference.java +51 -42
- data/ext/java/nokogiri/XmlNamespace.java +177 -145
- data/ext/java/nokogiri/XmlNode.java +1843 -1588
- data/ext/java/nokogiri/XmlNodeSet.java +361 -299
- data/ext/java/nokogiri/XmlProcessingInstruction.java +49 -39
- data/ext/java/nokogiri/XmlReader.java +513 -418
- data/ext/java/nokogiri/XmlRelaxng.java +91 -78
- data/ext/java/nokogiri/XmlSaxParserContext.java +330 -285
- data/ext/java/nokogiri/XmlSaxPushParser.java +229 -190
- data/ext/java/nokogiri/XmlSchema.java +328 -263
- data/ext/java/nokogiri/XmlSyntaxError.java +113 -83
- data/ext/java/nokogiri/XmlText.java +57 -46
- data/ext/java/nokogiri/XmlXpathContext.java +240 -206
- data/ext/java/nokogiri/XsltStylesheet.java +282 -239
- data/ext/java/nokogiri/internals/ClosedStreamException.java +5 -2
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +199 -168
- 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 +65 -50
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +107 -88
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +25 -18
- data/ext/java/nokogiri/internals/NokogiriHandler.java +316 -254
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +738 -622
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +186 -143
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +83 -68
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +66 -49
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +86 -69
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +44 -29
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +118 -101
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -24
- data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +25 -17
- data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +57 -42
- data/ext/java/nokogiri/internals/ParserContext.java +206 -179
- data/ext/java/nokogiri/internals/ReaderNode.java +478 -371
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +822 -707
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +28 -19
- data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +129 -123
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +5 -4
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +208 -177
- data/ext/java/nokogiri/internals/XmlSaxParser.java +24 -17
- 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 -570
- 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 +171 -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 +221 -164
- 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 +338 -286
- 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 +31 -8
- data/lib/nokogiri/xml/document.rb +31 -11
- data/lib/nokogiri/xml/node.rb +38 -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: 75a1889d20a751b02826603d140392a8bb3137d6ce09ad364c1ccfd06e7dec2f
|
4
|
+
data.tar.gz: 521afe80b0af7bbe5f89403a2cc6f7ab83fed28569a44050544d0cdad49405da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66b70c2138f49332061ac25d16dc625510cab71b1d959e95ae5989d9e102177f5b209d202be6eff0a5d51a9a0c0f9918fe0ff1719443d758f4c06434e86f1064
|
7
|
+
data.tar.gz: d3a2cd2d6ca996aebd8a04dc2d3e2d3090b2ad0c4aa46054def4985e6d35a40aa9e3ba47440b5488c7bc8e08eed73b72c44781accf439f9381289d2d66ca0285
|
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 -- 2020 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
60
|
- 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
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
|
@@ -17,10 +17,10 @@
|
|
17
17
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
18
|
* permit persons to whom the Software is furnished to do so, subject to
|
19
19
|
* the following conditions:
|
20
|
-
*
|
20
|
+
*
|
21
21
|
* The above copyright notice and this permission notice shall be
|
22
22
|
* included in all copies or substantial portions of the Software.
|
23
|
-
*
|
23
|
+
*
|
24
24
|
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
25
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
26
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
@@ -52,73 +52,92 @@ import org.jruby.runtime.builtin.IRubyObject;
|
|
52
52
|
*
|
53
53
|
* @author Patrick Mahoney <pat@polycrstal.org>
|
54
54
|
*/
|
55
|
-
@JRubyClass(name="Nokogiri::EncodingHandler")
|
56
|
-
public class EncodingHandler extends RubyObject
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
@JRubyClass(name = "Nokogiri::EncodingHandler")
|
56
|
+
public class EncodingHandler extends RubyObject
|
57
|
+
{
|
58
|
+
protected static HashMap<String, String> map = new HashMap<String, String>();
|
59
|
+
static
|
60
|
+
{
|
61
|
+
addInitial();
|
62
|
+
}
|
61
63
|
|
62
|
-
|
64
|
+
protected String name;
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
protected static void
|
67
|
+
addInitial()
|
68
|
+
{
|
69
|
+
map.put("UTF-8", "UTF-8");
|
70
|
+
}
|
67
71
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
+
public
|
73
|
+
EncodingHandler(Ruby ruby, RubyClass klass, String value)
|
74
|
+
{
|
75
|
+
super(ruby, klass);
|
76
|
+
name = value;
|
77
|
+
}
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
ruby,
|
85
|
-
getNokogiriClass(ruby, "Nokogiri::EncodingHandler"),
|
86
|
-
value);
|
79
|
+
@JRubyMethod(name = "[]", meta = true)
|
80
|
+
public static IRubyObject
|
81
|
+
get(ThreadContext context,
|
82
|
+
IRubyObject _klass,
|
83
|
+
IRubyObject keyObj)
|
84
|
+
{
|
85
|
+
Ruby ruby = context.getRuntime();
|
86
|
+
String key = keyObj.toString();
|
87
|
+
String value = map.get(key);
|
88
|
+
if (value == null) {
|
89
|
+
return ruby.getNil();
|
87
90
|
}
|
88
91
|
|
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
|
-
}
|
92
|
+
return new EncodingHandler(
|
93
|
+
ruby,
|
94
|
+
getNokogiriClass(ruby, "Nokogiri::EncodingHandler"),
|
95
|
+
value);
|
96
|
+
}
|
99
97
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
98
|
+
@JRubyMethod(meta = true)
|
99
|
+
public static IRubyObject
|
100
|
+
delete (ThreadContext context,
|
101
|
+
IRubyObject _klass,
|
102
|
+
IRubyObject keyObj)
|
103
|
+
{
|
104
|
+
String key = keyObj.toString();
|
105
|
+
String value = map.remove(key);
|
106
|
+
if (value == null) {
|
107
|
+
return context.getRuntime().getNil();
|
106
108
|
}
|
109
|
+
return context.getRuntime().newString(value);
|
110
|
+
}
|
107
111
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
@JRubyMethod(name = "clear_aliases!", meta = true)
|
113
|
+
public static IRubyObject
|
114
|
+
clear_aliases(ThreadContext context,
|
115
|
+
IRubyObject _klass)
|
116
|
+
{
|
117
|
+
map.clear();
|
118
|
+
addInitial();
|
119
|
+
return context.getRuntime().getNil();
|
120
|
+
}
|
116
121
|
|
117
|
-
|
122
|
+
@JRubyMethod(meta = true)
|
123
|
+
public static IRubyObject
|
124
|
+
alias(ThreadContext context,
|
125
|
+
IRubyObject _klass,
|
126
|
+
IRubyObject orig,
|
127
|
+
IRubyObject alias)
|
128
|
+
{
|
129
|
+
String value = map.get(orig.toString());
|
130
|
+
if (value != null) {
|
131
|
+
map.put(alias.toString(), value);
|
118
132
|
}
|
119
133
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
134
|
+
return context.getRuntime().getNil();
|
135
|
+
}
|
136
|
+
|
137
|
+
@JRubyMethod
|
138
|
+
public IRubyObject
|
139
|
+
name(ThreadContext context)
|
140
|
+
{
|
141
|
+
return context.getRuntime().newString(name);
|
142
|
+
}
|
124
143
|
}
|
@@ -17,10 +17,10 @@
|
|
17
17
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
18
|
* permit persons to whom the Software is furnished to do so, subject to
|
19
19
|
* the following conditions:
|
20
|
-
*
|
20
|
+
*
|
21
21
|
* The above copyright notice and this permission notice shall be
|
22
22
|
* included in all copies or substantial portions of the Software.
|
23
|
-
*
|
23
|
+
*
|
24
24
|
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
25
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
26
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
@@ -55,124 +55,147 @@ import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
|
55
55
|
* @author sergio
|
56
56
|
* @author Yoko Harada <yokolet@gmail.com>
|
57
57
|
*/
|
58
|
-
@JRubyClass(name="Nokogiri::HTML::Document", parent="Nokogiri::XML::Document")
|
59
|
-
public class HtmlDocument extends XmlDocument
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
58
|
+
@JRubyClass(name = "Nokogiri::HTML::Document", parent = "Nokogiri::XML::Document")
|
59
|
+
public class HtmlDocument extends XmlDocument
|
60
|
+
{
|
61
|
+
private static final String DEFAULT_CONTENT_TYPE = "html";
|
62
|
+
private static final String DEFAULT_PUBLIC_ID = "-//W3C//DTD HTML 4.01//EN";
|
63
|
+
private static final String DEFAULT_SYTEM_ID = "http://www.w3.org/TR/html4/strict.dtd";
|
64
|
+
|
65
|
+
private String parsed_encoding = null;
|
66
|
+
|
67
|
+
public
|
68
|
+
HtmlDocument(Ruby ruby, RubyClass klazz)
|
69
|
+
{
|
70
|
+
super(ruby, klazz);
|
71
|
+
}
|
72
|
+
|
73
|
+
public
|
74
|
+
HtmlDocument(Ruby runtime, Document document)
|
75
|
+
{
|
76
|
+
this(runtime, getNokogiriClass(runtime, "Nokogiri::XML::Document"), document);
|
77
|
+
}
|
78
|
+
|
79
|
+
public
|
80
|
+
HtmlDocument(Ruby ruby, RubyClass klazz, Document doc)
|
81
|
+
{
|
82
|
+
super(ruby, klazz, doc);
|
83
|
+
}
|
84
|
+
|
85
|
+
@JRubyMethod(name = "new", meta = true, rest = true, required = 0)
|
86
|
+
public static IRubyObject
|
87
|
+
rbNew(ThreadContext context, IRubyObject klazz, IRubyObject[] args)
|
88
|
+
{
|
89
|
+
final Ruby runtime = context.runtime;
|
90
|
+
HtmlDocument htmlDocument;
|
91
|
+
try {
|
92
|
+
Document docNode = createNewDocument(runtime);
|
93
|
+
htmlDocument = (HtmlDocument) NokogiriService.HTML_DOCUMENT_ALLOCATOR.allocate(runtime, (RubyClass) klazz);
|
94
|
+
htmlDocument.setDocumentNode(context.runtime, docNode);
|
95
|
+
} catch (Exception ex) {
|
96
|
+
throw asRuntimeError(runtime, "couldn't create document: ", ex);
|
72
97
|
}
|
73
98
|
|
74
|
-
|
75
|
-
|
99
|
+
Helpers.invoke(context, htmlDocument, "initialize", args);
|
100
|
+
|
101
|
+
return htmlDocument;
|
102
|
+
}
|
103
|
+
|
104
|
+
public IRubyObject
|
105
|
+
getInternalSubset(ThreadContext context)
|
106
|
+
{
|
107
|
+
IRubyObject internalSubset = super.getInternalSubset(context);
|
108
|
+
|
109
|
+
// html documents are expected to have a default internal subset
|
110
|
+
// the default values are the same ones used when the following
|
111
|
+
// feature is turned on
|
112
|
+
// "http://cyberneko.org/html/features/insert-doctype"
|
113
|
+
// the reason we don't turn it on, is because it overrides the document's
|
114
|
+
// declared doctype declaration.
|
115
|
+
|
116
|
+
if (internalSubset.isNil()) {
|
117
|
+
internalSubset = XmlDtd.newEmpty(context.getRuntime(),
|
118
|
+
getDocument(),
|
119
|
+
context.getRuntime().newString(DEFAULT_CONTENT_TYPE),
|
120
|
+
context.getRuntime().newString(DEFAULT_PUBLIC_ID),
|
121
|
+
context.getRuntime().newString(DEFAULT_SYTEM_ID));
|
122
|
+
setInternalSubset(internalSubset);
|
76
123
|
}
|
77
124
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
Helpers.invoke(context, htmlDocument, "initialize", args);
|
91
|
-
|
92
|
-
return htmlDocument;
|
125
|
+
return internalSubset;
|
126
|
+
}
|
127
|
+
|
128
|
+
@Override
|
129
|
+
void
|
130
|
+
init(Ruby runtime, Document document)
|
131
|
+
{
|
132
|
+
stabilizeTextContent(document);
|
133
|
+
document.normalize();
|
134
|
+
setInstanceVariable("@decorators", runtime.getNil());
|
135
|
+
if (document.getDocumentElement() != null) {
|
136
|
+
stabilizeAttrs(document.getDocumentElement());
|
93
137
|
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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);
|
138
|
+
}
|
139
|
+
|
140
|
+
private static void
|
141
|
+
stabilizeAttrs(Node node)
|
142
|
+
{
|
143
|
+
if (node.hasAttributes()) {
|
144
|
+
NamedNodeMap nodeMap = node.getAttributes();
|
145
|
+
for (int i = 0; i < nodeMap.getLength(); i++) {
|
146
|
+
Node n = nodeMap.item(i);
|
147
|
+
if (n instanceof Attr) {
|
148
|
+
stabilizeAttr((Attr) n);
|
112
149
|
}
|
113
|
-
|
114
|
-
return internalSubset;
|
150
|
+
}
|
115
151
|
}
|
116
|
-
|
117
|
-
|
118
|
-
|
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]);
|
152
|
+
NodeList children = node.getChildNodes();
|
153
|
+
for (int i = 0; i < children.getLength(); i++) {
|
154
|
+
stabilizeAttrs(children.item(i));
|
177
155
|
}
|
156
|
+
}
|
157
|
+
|
158
|
+
public void
|
159
|
+
setParsedEncoding(String encoding)
|
160
|
+
{
|
161
|
+
parsed_encoding = encoding;
|
162
|
+
}
|
163
|
+
|
164
|
+
public String
|
165
|
+
getPraedEncoding()
|
166
|
+
{
|
167
|
+
return parsed_encoding;
|
168
|
+
}
|
169
|
+
|
170
|
+
/*
|
171
|
+
* call-seq:
|
172
|
+
* read_io(io, url, encoding, options)
|
173
|
+
*
|
174
|
+
* Read the HTML document from +io+ with given +url+, +encoding+,
|
175
|
+
* and +options+. See Nokogiri::HTML.parse
|
176
|
+
*/
|
177
|
+
@JRubyMethod(meta = true, required = 4)
|
178
|
+
public static IRubyObject
|
179
|
+
read_io(ThreadContext context, IRubyObject klass, IRubyObject[] args)
|
180
|
+
{
|
181
|
+
HtmlDomParserContext ctx = new HtmlDomParserContext(context.runtime, args[2], args[3]);
|
182
|
+
ctx.setIOInputSource(context, args[0], args[1]);
|
183
|
+
return ctx.parse(context, (RubyClass) klass, args[1]);
|
184
|
+
}
|
185
|
+
|
186
|
+
/*
|
187
|
+
* call-seq:
|
188
|
+
* read_memory(string, url, encoding, options)
|
189
|
+
*
|
190
|
+
* Read the HTML document contained in +string+ with given +url+, +encoding+,
|
191
|
+
* and +options+. See Nokogiri::HTML.parse
|
192
|
+
*/
|
193
|
+
@JRubyMethod(meta = true, required = 4)
|
194
|
+
public static IRubyObject
|
195
|
+
read_memory(ThreadContext context, IRubyObject klass, IRubyObject[] args)
|
196
|
+
{
|
197
|
+
HtmlDomParserContext ctx = new HtmlDomParserContext(context.runtime, args[2], args[3]);
|
198
|
+
ctx.setStringInputSource(context, args[0], args[1]);
|
199
|
+
return ctx.parse(context, (RubyClass) klass, args[1]);
|
200
|
+
}
|
178
201
|
}
|