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.

Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE-DEPENDENCIES.md +12 -12
  3. data/LICENSE.md +1 -1
  4. data/README.md +20 -15
  5. data/ext/java/nokogiri/EncodingHandler.java +78 -59
  6. data/ext/java/nokogiri/HtmlDocument.java +137 -114
  7. data/ext/java/nokogiri/HtmlElementDescription.java +104 -87
  8. data/ext/java/nokogiri/HtmlEntityLookup.java +31 -26
  9. data/ext/java/nokogiri/HtmlSaxParserContext.java +220 -192
  10. data/ext/java/nokogiri/HtmlSaxPushParser.java +164 -139
  11. data/ext/java/nokogiri/NokogiriService.java +597 -526
  12. data/ext/java/nokogiri/XmlAttr.java +120 -96
  13. data/ext/java/nokogiri/XmlAttributeDecl.java +97 -76
  14. data/ext/java/nokogiri/XmlCdata.java +35 -26
  15. data/ext/java/nokogiri/XmlComment.java +48 -37
  16. data/ext/java/nokogiri/XmlDocument.java +642 -540
  17. data/ext/java/nokogiri/XmlDocumentFragment.java +127 -107
  18. data/ext/java/nokogiri/XmlDtd.java +450 -384
  19. data/ext/java/nokogiri/XmlElement.java +25 -18
  20. data/ext/java/nokogiri/XmlElementContent.java +345 -286
  21. data/ext/java/nokogiri/XmlElementDecl.java +126 -95
  22. data/ext/java/nokogiri/XmlEntityDecl.java +121 -97
  23. data/ext/java/nokogiri/XmlEntityReference.java +51 -42
  24. data/ext/java/nokogiri/XmlNamespace.java +177 -145
  25. data/ext/java/nokogiri/XmlNode.java +1843 -1588
  26. data/ext/java/nokogiri/XmlNodeSet.java +361 -299
  27. data/ext/java/nokogiri/XmlProcessingInstruction.java +49 -39
  28. data/ext/java/nokogiri/XmlReader.java +513 -418
  29. data/ext/java/nokogiri/XmlRelaxng.java +91 -78
  30. data/ext/java/nokogiri/XmlSaxParserContext.java +330 -285
  31. data/ext/java/nokogiri/XmlSaxPushParser.java +229 -190
  32. data/ext/java/nokogiri/XmlSchema.java +328 -263
  33. data/ext/java/nokogiri/XmlSyntaxError.java +113 -83
  34. data/ext/java/nokogiri/XmlText.java +57 -46
  35. data/ext/java/nokogiri/XmlXpathContext.java +240 -206
  36. data/ext/java/nokogiri/XsltStylesheet.java +282 -239
  37. data/ext/java/nokogiri/internals/ClosedStreamException.java +5 -2
  38. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +199 -168
  39. data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +17 -10
  40. data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +43 -16
  41. data/ext/java/nokogiri/internals/NokogiriDomParser.java +65 -50
  42. data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +107 -88
  43. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +25 -18
  44. data/ext/java/nokogiri/internals/NokogiriHandler.java +316 -254
  45. data/ext/java/nokogiri/internals/NokogiriHelpers.java +738 -622
  46. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +186 -143
  47. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +83 -68
  48. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +66 -49
  49. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +86 -69
  50. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +44 -29
  51. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +118 -101
  52. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -24
  53. data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +25 -17
  54. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +57 -42
  55. data/ext/java/nokogiri/internals/ParserContext.java +206 -179
  56. data/ext/java/nokogiri/internals/ReaderNode.java +478 -371
  57. data/ext/java/nokogiri/internals/SaveContextVisitor.java +822 -707
  58. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +28 -19
  59. data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +129 -123
  60. data/ext/java/nokogiri/internals/XmlDeclHandler.java +5 -4
  61. data/ext/java/nokogiri/internals/XmlDomParserContext.java +208 -177
  62. data/ext/java/nokogiri/internals/XmlSaxParser.java +24 -17
  63. data/ext/java/nokogiri/internals/c14n/AttrCompare.java +71 -68
  64. data/ext/java/nokogiri/internals/c14n/C14nHelper.java +137 -118
  65. data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +27 -21
  66. data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +74 -61
  67. data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +230 -205
  68. data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +572 -547
  69. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +17 -10
  70. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +17 -10
  71. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +323 -302
  72. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +232 -219
  73. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +22 -15
  74. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +23 -16
  75. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +23 -16
  76. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +22 -15
  77. data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +575 -545
  78. data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +141 -120
  79. data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +39 -38
  80. data/ext/java/nokogiri/internals/c14n/Constants.java +13 -10
  81. data/ext/java/nokogiri/internals/c14n/ElementProxy.java +279 -247
  82. data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +66 -53
  83. data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +44 -37
  84. data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +135 -120
  85. data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +59 -48
  86. data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +384 -334
  87. data/ext/java/nokogiri/internals/c14n/NodeFilter.java +25 -24
  88. data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +151 -140
  89. data/ext/java/nokogiri/internals/c14n/XMLUtils.java +456 -423
  90. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1466 -1500
  91. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +626 -570
  92. data/ext/nokogiri/depend +34 -474
  93. data/ext/nokogiri/extconf.rb +253 -183
  94. data/ext/nokogiri/html_document.c +10 -15
  95. data/ext/nokogiri/html_element_description.c +84 -71
  96. data/ext/nokogiri/html_entity_lookup.c +21 -16
  97. data/ext/nokogiri/html_sax_parser_context.c +66 -65
  98. data/ext/nokogiri/html_sax_push_parser.c +29 -27
  99. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  100. data/ext/nokogiri/nokogiri.c +171 -63
  101. data/ext/nokogiri/test_global_handlers.c +3 -4
  102. data/ext/nokogiri/xml_attr.c +15 -15
  103. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  104. data/ext/nokogiri/xml_cdata.c +13 -18
  105. data/ext/nokogiri/xml_comment.c +19 -26
  106. data/ext/nokogiri/xml_document.c +221 -164
  107. data/ext/nokogiri/xml_document_fragment.c +13 -15
  108. data/ext/nokogiri/xml_dtd.c +54 -48
  109. data/ext/nokogiri/xml_element_content.c +30 -27
  110. data/ext/nokogiri/xml_element_decl.c +22 -22
  111. data/ext/nokogiri/xml_encoding_handler.c +17 -11
  112. data/ext/nokogiri/xml_entity_decl.c +32 -30
  113. data/ext/nokogiri/xml_entity_reference.c +16 -18
  114. data/ext/nokogiri/xml_namespace.c +56 -49
  115. data/ext/nokogiri/xml_node.c +338 -286
  116. data/ext/nokogiri/xml_node_set.c +168 -156
  117. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  118. data/ext/nokogiri/xml_reader.c +191 -157
  119. data/ext/nokogiri/xml_relax_ng.c +29 -23
  120. data/ext/nokogiri/xml_sax_parser.c +117 -112
  121. data/ext/nokogiri/xml_sax_parser_context.c +100 -85
  122. data/ext/nokogiri/xml_sax_push_parser.c +34 -27
  123. data/ext/nokogiri/xml_schema.c +48 -42
  124. data/ext/nokogiri/xml_syntax_error.c +21 -23
  125. data/ext/nokogiri/xml_text.c +13 -17
  126. data/ext/nokogiri/xml_xpath_context.c +134 -127
  127. data/ext/nokogiri/xslt_stylesheet.c +157 -157
  128. data/lib/nokogiri.rb +1 -22
  129. data/lib/nokogiri/css/parser.rb +1 -1
  130. data/lib/nokogiri/extension.rb +26 -0
  131. data/lib/nokogiri/html/document_fragment.rb +15 -15
  132. data/lib/nokogiri/nokogiri.jar +0 -0
  133. data/lib/nokogiri/version/constant.rb +1 -1
  134. data/lib/nokogiri/version/info.rb +31 -8
  135. data/lib/nokogiri/xml/document.rb +31 -11
  136. data/lib/nokogiri/xml/node.rb +38 -42
  137. data/lib/nokogiri/xml/reader.rb +2 -9
  138. data/lib/nokogiri/xml/xpath.rb +1 -3
  139. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  140. metadata +7 -8
  141. data/ext/nokogiri/xml_io.c +0 -63
  142. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d85f8024902ba0c8e8000b2e697368ccd2b5f3cb24daa6d2696baf09ca8efeb
4
- data.tar.gz: a34653303414cf3670c64ba5e820d804efa566575b6e6fd0372c587da253e96f
3
+ metadata.gz: 75a1889d20a751b02826603d140392a8bb3137d6ce09ad364c1ccfd06e7dec2f
4
+ data.tar.gz: 521afe80b0af7bbe5f89403a2cc6f7ab83fed28569a44050544d0cdad49405da
5
5
  SHA512:
6
- metadata.gz: d402f90c16cfbecb8746b9afa8b918735c083b1d6363a86d313911a3329fc936ac9fc2ac12122d2fe21c49d212ba95d7b09d2309dd69ea713afb16e7e5f79814
7
- data.tar.gz: ec647fdf9fe11f57374ed845cd5cafded912b3ec239cf72cf7a08621772166bb5c9386b271e5513925f0d6ee63d0877629d0c83b721a66fa872df3500c548c69
6
+ metadata.gz: 66b70c2138f49332061ac25d16dc625510cab71b1d959e95ae5989d9e102177f5b209d202be6eff0a5d51a9a0c0f9918fe0ff1719443d758f4c06434e86f1064
7
+ data.tar.gz: d3a2cd2d6ca996aebd8a04dc2d3e2d3090b2ad0c4aa46054def4985e6d35a40aa9e3ba47440b5488c7bc8e08eed73b72c44781accf439f9381289d2d66ca0285
@@ -7,22 +7,22 @@ Note that this document is broken into multiple sections, each of which describe
7
7
  <!-- toc -->
8
8
 
9
9
  - [Default platform release ("ruby")](#default-platform-release-ruby)
10
- - [Native LinuxⓇ platform releases ("x86_64-linux" and "arm64-linux")](#native-linux-platform-releases-x86_64-linux-and-arm64-linux)
10
+ - [Native LinuxⓇ platform releases ("x86_64-linux" and "arm64-linux")](#native-linux%E2%93%A1-platform-releases-x86_64-linux-and-arm64-linux)
11
11
  - [Native Darwin (macOSⓇ) platform releases ("x86_64-darwin" and "arm64-darwin")](#native-darwin-macos%E2%93%A1-platform-releases-x86_64-darwin-and-arm64-darwin)
12
12
  - [Native WindowsⓇ platform releases ("x86-mingw32" and "x64-mingw32")](#native-windows%E2%93%A1-platform-releases-x86-mingw32-and-x64-mingw32)
13
13
  - [JavaⓇ (JRuby) platform release ("java")](#java%E2%93%A1-jruby-platform-release-java)
14
14
  - [Appendix: Dependencies' License Texts](#appendix-dependencies-license-texts)
15
- * [libxml2](#libxml2)
16
- * [libxslt](#libxslt)
17
- * [zlib](#zlib)
18
- * [libiconv](#libiconv)
19
- * [isorelax](#isorelax)
20
- * [jing](#jing)
21
- * [nekodtd](#nekodtd)
22
- * [nekohtml](#nekohtml)
23
- * [xalan](#xalan)
24
- * [xerces](#xerces)
25
- * [xml-apis](#xml-apis)
15
+ * [libxml2](#libxml2)
16
+ * [libxslt](#libxslt)
17
+ * [zlib](#zlib)
18
+ * [libiconv](#libiconv)
19
+ * [isorelax](#isorelax)
20
+ * [jing](#jing)
21
+ * [nekodtd](#nekodtd)
22
+ * [nekohtml](#nekohtml)
23
+ * [xalan](#xalan)
24
+ * [xerces](#xerces)
25
+ * [xml-apis](#xml-apis)
26
26
 
27
27
  <!-- tocstop -->
28
28
 
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright 2008 -- 2018 by Aaron Patterson, Mike Dalessio, Charles Nutter, Sergio Arbeo, Patrick Mahoney, Yoko Harada, Akinori MUSHA, John Shahid, Lars Kanis
3
+ Copyright 2008 -- 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/master?svg=true)](https://ci.appveyor.com/project/flavorjones/nokogiri/branch/master)
30
+ [![Appveyor CI](https://ci.appveyor.com/api/projects/status/xj2pqwvlxwuwgr06/branch/main?svg=true)](https://ci.appveyor.com/project/flavorjones/nokogiri/branch/main)
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 Help
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 API documentation should be:
49
+ Your first stops for learning more about Nokogiri should be:
46
50
 
47
- - RDocs: https://nokogiri.org/rdoc/index.html
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
- ### Questions
56
+ ### Ask For Help
52
57
 
53
- If you'd like to talk to a human:
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
- - The Nokogiri bug tracker is at https://github.com/sparklemotion/nokogiri/issues
62
+ - Open an issue using the "Help Request" template at https://github.com/sparklemotion/nokogiri/issues
60
63
 
61
- Consider subscribing to [Tidelift][tidelift] which provides license assurances and timely security notifications for your open source dependencies, including Nokogiri. [Tidelift][tidelift] subscriptions also help the Nokogiri maintainers fund our [automated testing](https://ci.nokogiri.org) which in turn allows us to ship releases, bugfixes, and security updates more often.
64
+ Please do not mail the maintainers at their personal addresses.
62
65
 
63
- [tidelift]: https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme
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
- ```bash
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
- protected static HashMap<String,String> map = new HashMap<String,String>();
58
- static {
59
- addInitial();
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
- protected String name;
64
+ protected String name;
63
65
 
64
- protected static void addInitial() {
65
- map.put("UTF-8", "UTF-8");
66
- }
66
+ protected static void
67
+ addInitial()
68
+ {
69
+ map.put("UTF-8", "UTF-8");
70
+ }
67
71
 
68
- public EncodingHandler(Ruby ruby, RubyClass klass, String value) {
69
- super(ruby, klass);
70
- name = value;
71
- }
72
+ public
73
+ EncodingHandler(Ruby ruby, RubyClass klass, String value)
74
+ {
75
+ super(ruby, klass);
76
+ name = value;
77
+ }
72
78
 
73
- @JRubyMethod(name="[]", meta=true)
74
- public static IRubyObject get(ThreadContext context,
75
- IRubyObject _klass,
76
- IRubyObject keyObj) {
77
- Ruby ruby = context.getRuntime();
78
- String key = keyObj.toString();
79
- String value = map.get(key);
80
- if (value == null)
81
- return ruby.getNil();
82
-
83
- return new EncodingHandler(
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
- @JRubyMethod(meta=true)
90
- public static IRubyObject delete(ThreadContext context,
91
- IRubyObject _klass,
92
- IRubyObject keyObj) {
93
- String key = keyObj.toString();
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
- @JRubyMethod(name="clear_aliases!", meta=true)
101
- public static IRubyObject clear_aliases(ThreadContext context,
102
- IRubyObject _klass) {
103
- map.clear();
104
- addInitial();
105
- return context.getRuntime().getNil();
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
- @JRubyMethod(meta=true)
109
- public static IRubyObject alias(ThreadContext context,
110
- IRubyObject _klass,
111
- IRubyObject orig,
112
- IRubyObject alias) {
113
- String value = map.get(orig.toString());
114
- if (value != null)
115
- map.put(alias.toString(), value);
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
- return context.getRuntime().getNil();
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
- @JRubyMethod
121
- public IRubyObject name(ThreadContext context) {
122
- return context.getRuntime().newString(name);
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
- private static final String DEFAULT_CONTENT_TYPE = "html";
61
- private static final String DEFAULT_PUBLIC_ID = "-//W3C//DTD HTML 4.01//EN";
62
- private static final String DEFAULT_SYTEM_ID = "http://www.w3.org/TR/html4/strict.dtd";
63
-
64
- private String parsed_encoding = null;
65
-
66
- public HtmlDocument(Ruby ruby, RubyClass klazz) {
67
- super(ruby, klazz);
68
- }
69
-
70
- public HtmlDocument(Ruby runtime, Document document) {
71
- this(runtime, getNokogiriClass(runtime, "Nokogiri::XML::Document"), document);
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
- public HtmlDocument(Ruby ruby, RubyClass klazz, Document doc) {
75
- super(ruby, klazz, doc);
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
- @JRubyMethod(name="new", meta = true, rest = true, required=0)
79
- public static IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject[] args) {
80
- final Ruby runtime = context.runtime;
81
- HtmlDocument htmlDocument;
82
- try {
83
- Document docNode = createNewDocument(runtime);
84
- htmlDocument = (HtmlDocument) NokogiriService.HTML_DOCUMENT_ALLOCATOR.allocate(runtime, (RubyClass) klazz);
85
- htmlDocument.setDocumentNode(context.runtime, docNode);
86
- } catch (Exception ex) {
87
- throw asRuntimeError(runtime, "couldn't create document: ", ex);
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
- public IRubyObject getInternalSubset(ThreadContext context) {
96
- IRubyObject internalSubset = super.getInternalSubset(context);
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);
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
- @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]);
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
  }