nokogiri 1.13.10-java → 1.14.0-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 (119) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +33 -0
  3. data/LICENSE-DEPENDENCIES.md +830 -509
  4. data/LICENSE.md +1 -1
  5. data/README.md +18 -11
  6. data/dependencies.yml +25 -7
  7. data/ext/java/nokogiri/Html4Document.java +2 -0
  8. data/ext/java/nokogiri/Html4ElementDescription.java +9 -9
  9. data/ext/java/nokogiri/Html4EntityLookup.java +14 -3
  10. data/ext/java/nokogiri/Html4SaxParserContext.java +2 -2
  11. data/ext/java/nokogiri/Html4SaxPushParser.java +3 -0
  12. data/ext/java/nokogiri/NokogiriService.java +1 -24
  13. data/ext/java/nokogiri/XmlAttr.java +1 -1
  14. data/ext/java/nokogiri/XmlAttributeDecl.java +2 -1
  15. data/ext/java/nokogiri/XmlCdata.java +2 -1
  16. data/ext/java/nokogiri/XmlComment.java +2 -1
  17. data/ext/java/nokogiri/XmlDocument.java +5 -6
  18. data/ext/java/nokogiri/XmlDocumentFragment.java +2 -1
  19. data/ext/java/nokogiri/XmlDtd.java +4 -3
  20. data/ext/java/nokogiri/XmlElement.java +1 -0
  21. data/ext/java/nokogiri/XmlElementContent.java +4 -1
  22. data/ext/java/nokogiri/XmlElementDecl.java +3 -1
  23. data/ext/java/nokogiri/XmlEntityDecl.java +2 -0
  24. data/ext/java/nokogiri/XmlEntityReference.java +1 -0
  25. data/ext/java/nokogiri/XmlNamespace.java +2 -0
  26. data/ext/java/nokogiri/XmlNode.java +39 -24
  27. data/ext/java/nokogiri/XmlNodeSet.java +10 -7
  28. data/ext/java/nokogiri/XmlProcessingInstruction.java +1 -0
  29. data/ext/java/nokogiri/XmlReader.java +4 -3
  30. data/ext/java/nokogiri/XmlRelaxng.java +1 -0
  31. data/ext/java/nokogiri/XmlSaxParserContext.java +1 -0
  32. data/ext/java/nokogiri/XmlSaxPushParser.java +3 -0
  33. data/ext/java/nokogiri/XmlSchema.java +4 -2
  34. data/ext/java/nokogiri/XmlSyntaxError.java +1 -0
  35. data/ext/java/nokogiri/XmlText.java +1 -0
  36. data/ext/java/nokogiri/XmlXpathContext.java +2 -0
  37. data/ext/java/nokogiri/XsltStylesheet.java +16 -13
  38. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +3 -2
  39. data/ext/java/nokogiri/internals/NokogiriHandler.java +2 -2
  40. data/ext/java/nokogiri/internals/NokogiriHelpers.java +4 -5
  41. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +3 -3
  42. data/ext/java/nokogiri/internals/ParserContext.java +2 -0
  43. data/ext/java/nokogiri/internals/ReaderNode.java +1 -1
  44. data/ext/java/nokogiri/internals/SaveContextVisitor.java +4 -2
  45. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +2 -2
  46. data/ext/java/nokogiri/internals/XmlDomParserContext.java +2 -1
  47. data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +1 -0
  48. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +5 -4
  49. data/ext/nokogiri/extconf.rb +80 -21
  50. data/ext/nokogiri/gumbo.c +19 -9
  51. data/ext/nokogiri/html4_document.c +1 -1
  52. data/ext/nokogiri/html4_entity_lookup.c +1 -1
  53. data/ext/nokogiri/html4_sax_parser_context.c +0 -5
  54. data/ext/nokogiri/nokogiri.c +33 -51
  55. data/ext/nokogiri/xml_attribute_decl.c +1 -1
  56. data/ext/nokogiri/xml_cdata.c +1 -1
  57. data/ext/nokogiri/xml_document.c +16 -11
  58. data/ext/nokogiri/xml_element_content.c +2 -2
  59. data/ext/nokogiri/xml_element_decl.c +1 -1
  60. data/ext/nokogiri/xml_encoding_handler.c +2 -2
  61. data/ext/nokogiri/xml_namespace.c +38 -8
  62. data/ext/nokogiri/xml_node.c +286 -26
  63. data/ext/nokogiri/xml_node_set.c +0 -2
  64. data/ext/nokogiri/xml_reader.c +40 -20
  65. data/ext/nokogiri/xml_relax_ng.c +0 -2
  66. data/ext/nokogiri/xml_sax_parser.c +22 -16
  67. data/ext/nokogiri/xml_sax_parser_context.c +0 -5
  68. data/ext/nokogiri/xml_sax_push_parser.c +0 -2
  69. data/ext/nokogiri/xml_schema.c +0 -2
  70. data/ext/nokogiri/xml_xpath_context.c +87 -83
  71. data/ext/nokogiri/xslt_stylesheet.c +14 -13
  72. data/gumbo-parser/Makefile +10 -0
  73. data/lib/nokogiri/css/node.rb +2 -2
  74. data/lib/nokogiri/css/xpath_visitor.rb +5 -3
  75. data/lib/nokogiri/css.rb +6 -0
  76. data/lib/nokogiri/encoding_handler.rb +57 -0
  77. data/lib/nokogiri/extension.rb +3 -2
  78. data/lib/nokogiri/html4/document.rb +2 -121
  79. data/lib/nokogiri/html4/element_description_defaults.rb +6 -12
  80. data/lib/nokogiri/html4/encoding_reader.rb +121 -0
  81. data/lib/nokogiri/html4.rb +1 -0
  82. data/lib/nokogiri/html5/document.rb +113 -36
  83. data/lib/nokogiri/html5/document_fragment.rb +9 -2
  84. data/lib/nokogiri/html5/node.rb +3 -5
  85. data/lib/nokogiri/html5.rb +127 -216
  86. data/lib/nokogiri/jruby/dependencies.rb +1 -19
  87. data/lib/{isorelax.jar → nokogiri/jruby/isorelax/isorelax/20030108/isorelax-20030108.jar} +0 -0
  88. data/lib/nokogiri/jruby/net/sf/saxon/Saxon-HE/9.6.0-4/Saxon-HE-9.6.0-4.jar +0 -0
  89. data/lib/nokogiri/jruby/net/sourceforge/htmlunit/neko-htmlunit/2.63.0/neko-htmlunit-2.63.0.jar +0 -0
  90. data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
  91. data/lib/nokogiri/jruby/nu/validator/jing/20200702VNU/jing-20200702VNU.jar +0 -0
  92. data/lib/nokogiri/jruby/org/nokogiri/nekodtd/0.1.11.noko1/nekodtd-0.1.11.noko1.jar +0 -0
  93. data/lib/{serializer.jar → nokogiri/jruby/xalan/serializer/2.7.2/serializer-2.7.2.jar} +0 -0
  94. data/lib/{xalan.jar → nokogiri/jruby/xalan/xalan/2.7.2/xalan-2.7.2.jar} +0 -0
  95. data/lib/{xercesImpl.jar → nokogiri/jruby/xerces/xercesImpl/2.12.2/xercesImpl-2.12.2.jar} +0 -0
  96. data/lib/{xml-apis.jar → nokogiri/jruby/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar} +0 -0
  97. data/lib/nokogiri/nokogiri.jar +0 -0
  98. data/lib/nokogiri/version/constant.rb +1 -1
  99. data/lib/nokogiri/version/info.rb +11 -10
  100. data/lib/nokogiri/xml/attr.rb +49 -0
  101. data/lib/nokogiri/xml/builder.rb +1 -1
  102. data/lib/nokogiri/xml/document.rb +102 -54
  103. data/lib/nokogiri/xml/document_fragment.rb +49 -6
  104. data/lib/nokogiri/xml/namespace.rb +42 -0
  105. data/lib/nokogiri/xml/node/save_options.rb +6 -4
  106. data/lib/nokogiri/xml/node.rb +190 -35
  107. data/lib/nokogiri/xml/node_set.rb +87 -9
  108. data/lib/nokogiri/xml/parse_options.rb +129 -50
  109. data/lib/nokogiri/xml/pp/node.rb +6 -4
  110. data/lib/nokogiri/xml/processing_instruction.rb +2 -1
  111. data/lib/nokogiri/xml/sax/parser.rb +2 -3
  112. data/lib/nokogiri/xslt.rb +1 -1
  113. data/lib/nokogiri.rb +3 -11
  114. data/lib/xsd/xmlparser/nokogiri.rb +3 -1
  115. metadata +60 -272
  116. data/ext/java/nokogiri/EncodingHandler.java +0 -111
  117. data/lib/jing.jar +0 -0
  118. data/lib/nekodtd.jar +0 -0
  119. data/lib/nekohtml.jar +0 -0
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright 2008 -- 2021 by Mike Dalessio, Aaron Patterson, Yoko Harada, Akinori MUSHA, John Shahid, Karol Bucek, Sam Ruby, Craig Barnes, Stephen Checkoway, Lars Kanis, Sergio Arbeo, Timothy Elliott, Nobuyoshi Nakada, Charles Nutter, Patrick Mahoney.
3
+ Copyright 2008 -- 2023 by Mike Dalessio, Aaron Patterson, Yoko Harada, Akinori MUSHA, John Shahid, Karol Bucek, Sam Ruby, Craig Barnes, Stephen Checkoway, 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
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Nokogiri
4
4
 
5
- Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a sensible, easy-to-understand API for [reading](https://nokogiri.org/tutorials/parsing_an_html_xml_document.html), writing, [modifying](https://nokogiri.org/tutorials/modifying_an_html_xml_document.html), and [querying](https://nokogiri.org/tutorials/searching_a_xml_html_document.html) documents. It is fast and standards-compliant by relying on native parsers like libxml2 (CRuby) and xerces (JRuby).
5
+ Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a sensible, easy-to-understand API for [reading](https://nokogiri.org/tutorials/parsing_an_html_xml_document.html), writing, [modifying](https://nokogiri.org/tutorials/modifying_an_html_xml_document.html), and [querying](https://nokogiri.org/tutorials/searching_a_xml_html_document.html) documents. It is fast and standards-compliant by relying on native parsers like libxml2, libgumbo, and xerces.
6
6
 
7
7
  ## Guiding Principles
8
8
 
@@ -40,10 +40,6 @@ Some guiding principles Nokogiri tries to follow:
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
-
47
43
  ### Reading
48
44
 
49
45
  Your first stops for learning more about Nokogiri should be:
@@ -57,7 +53,6 @@ Your first stops for learning more about Nokogiri should be:
57
53
 
58
54
  There are a few ways to ask exploratory questions:
59
55
 
60
- - The Ruby Discord chat server is active at https://discord.gg/UyQnKrT
61
56
  - The Nokogiri mailing list is active at https://groups.google.com/group/nokogiri-talk
62
57
  - Open an issue using the "Help Request" template at https://github.com/sparklemotion/nokogiri/issues
63
58
 
@@ -103,12 +98,21 @@ We bump `Major.Minor.Patch` versions following this guidance:
103
98
  - Updating packaged libraries for security-related reasons.
104
99
 
105
100
 
101
+ ### Sponsorship
102
+
103
+ You can help sponsor the maintainers of this software through one of these organizations:
104
+
105
+ - [github.com/sponsors/flavorjones](https://github.com/sponsors/flavorjones)
106
+ - [opencollective.com/nokogiri](https://opencollective.com/nokogiri)
107
+ - [tidelift.com/subscription/pkg/rubygems-nokogiri](https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme)
108
+
109
+
106
110
  ## Installation
107
111
 
108
112
  Requirements:
109
113
 
110
- - Ruby >= 2.6
111
- - JRuby >= 9.3.0.0
114
+ - Ruby >= 2.7
115
+ - JRuby >= 9.4.0.0
112
116
 
113
117
 
114
118
  ### Native Gems: Faster, more reliable installation
@@ -119,10 +123,13 @@ Requirements:
119
123
 
120
124
  Nokogiri ships pre-compiled, "native" gems for the following platforms:
121
125
 
122
- - Linux: `x86-linux` and `x86_64-linux` (req: `glibc >= 2.17`), including musl platforms like Alpine
126
+ - Linux:
127
+ - `x86-linux` and `x86_64-linux` (req: `glibc >= 2.17`)
128
+ - `aarch64-linux` and `arm-linux` (req: `glibc >= 2.29`)
129
+ - Note that musl platforms like Alpine **are** supported
123
130
  - Darwin/MacOS: `x86_64-darwin` and `arm64-darwin`
124
- - Windows: `x86-mingw32` and `x64-mingw32`
125
- - Java: any platform running JRuby 9.3 or higher
131
+ - Windows: `x86-mingw32`, `x64-mingw32`, and `x64-mingw-ucrt`
132
+ - Java: any platform running JRuby 9.4 or higher
126
133
 
127
134
  To determine whether your system supports one of these gems, look at the output of `bundle platform` or `ruby -e 'puts Gem::Platform.local.to_s'`.
128
135
 
data/dependencies.yml CHANGED
@@ -14,10 +14,28 @@ zlib:
14
14
  # SHA-256 hash provided on http://zlib.net/
15
15
 
16
16
  libiconv:
17
- version: "1.16"
18
- sha256: "e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04"
19
- # gpg: Signature made Fri 26 Apr 2019 03:36:38 PM EDT
20
- # gpg: using RSA key 4F494A942E4616C2
21
- # gpg: Good signature from "Bruno Haible (Open Source Development) <bruno@clisp.org>" [expired]
22
- # gpg: Note: This key has expired!
23
- # Primary key fingerprint: 68D9 4D8A AEEA D48A E7DC 5B90 4F49 4A94 2E46 16C2
17
+ version: "1.17"
18
+ sha256: "8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313"
19
+ # signature verified by following this path:
20
+ # - release announced at https://savannah.gnu.org/forum/forum.php?forum_id=10175
21
+ # - which links to https://savannah.gnu.org/users/haible as the releaser
22
+ # - which links to https://savannah.gnu.org/people/viewgpg.php?user_id=1871 as the gpg key
23
+ #
24
+ # So:
25
+ # - wget -q -O - https://savannah.gnu.org/people/viewgpg.php?user_id=1871 | gpg --import
26
+ # gpg: key F5BE8B267C6A406D: 1 signature not checked due to a missing key
27
+ # gpg: key F5BE8B267C6A406D: public key "Bruno Haible (Open Source Development) <bruno@clisp.org>" imported
28
+ # gpg: Total number processed: 1
29
+ # gpg: imported: 1
30
+ # gpg: marginals needed: 3 completes needed: 1 trust model: pgp
31
+ # gpg: depth: 0 valid: 4 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 4u
32
+ # gpg: next trustdb check due at 2024-05-09
33
+ # - gpg --verify libiconv-1.17.tar.gz.sig ports/archives/libiconv-1.17.tar.gz
34
+ # gpg: Signature made Sun 15 May 2022 11:26:42 AM EDT
35
+ # gpg: using RSA key 9001B85AF9E1B83DF1BDA942F5BE8B267C6A406D
36
+ # gpg: Good signature from "Bruno Haible (Open Source Development) <bruno@clisp.org>" [unknown]
37
+ # gpg: WARNING: This key is not certified with a trusted signature!
38
+ # gpg: There is no indication that the signature belongs to the owner.
39
+ # Primary key fingerprint: 9001 B85A F9E1 B83D F1BD A942 F5BE 8B26 7C6A 406D
40
+ #
41
+ # And this sha256sum is calculated from that verified tarball.
@@ -26,6 +26,8 @@ import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
26
26
  @JRubyClass(name = "Nokogiri::HTML4::Document", parent = "Nokogiri::XML::Document")
27
27
  public class Html4Document extends XmlDocument
28
28
  {
29
+ private static final long serialVersionUID = 1L;
30
+
29
31
  private static final String DEFAULT_CONTENT_TYPE = "html";
30
32
  private static final String DEFAULT_PUBLIC_ID = "-//W3C//DTD HTML 4.01//EN";
31
33
  private static final String DEFAULT_SYTEM_ID = "http://www.w3.org/TR/html4/strict.dtd";
@@ -6,7 +6,7 @@ import java.util.HashMap;
6
6
  import java.util.List;
7
7
  import java.util.Map;
8
8
 
9
- import org.cyberneko.html.HTMLElements;
9
+ import net.sourceforge.htmlunit.cyberneko.HTMLElements;
10
10
  import org.jruby.Ruby;
11
11
  import org.jruby.RubyClass;
12
12
  import org.jruby.RubyObject;
@@ -23,6 +23,8 @@ import org.jruby.runtime.builtin.IRubyObject;
23
23
  @JRubyClass(name = "Nokogiri::HTML4::ElementDescription")
24
24
  public class Html4ElementDescription extends RubyObject
25
25
  {
26
+ private static final long serialVersionUID = 1L;
27
+ private static final HTMLElements htmlElements_ = new HTMLElements();
26
28
 
27
29
  /**
28
30
  * Stores memoized hash of element -> list of valid subelements.
@@ -62,9 +64,8 @@ public class Html4ElementDescription extends RubyObject
62
64
  * the list of elements directly because it's protected.
63
65
  */
64
66
  for (short c = 0; c < HTMLElements.UNKNOWN; c++) {
65
- HTMLElements.Element maybe_sub =
66
- HTMLElements.getElement(c);
67
- if (maybe_sub.isParent(elem)) {
67
+ HTMLElements.Element maybe_sub = htmlElements_.getElement(c);
68
+ if (maybe_sub != null && maybe_sub.isParent(elem)) {
68
69
  subs.add(maybe_sub.name);
69
70
  }
70
71
  }
@@ -81,11 +82,10 @@ public class Html4ElementDescription extends RubyObject
81
82
  IRubyObject klazz, IRubyObject name)
82
83
  {
83
84
 
84
- // nekohtml will return an element even for invalid names, see
85
- // http://sourceforge.net/p/nekohtml/code/HEAD/tree/trunk/src/org/cyberneko/html/HTMLElements.java#l514
86
- // which breaks `test_fetch_nonexistent'
87
- HTMLElements.Element elem = HTMLElements.getElement(name.asJavaString(), HTMLElements.NO_SUCH_ELEMENT);
88
- if (elem == HTMLElements.NO_SUCH_ELEMENT) {
85
+ // nekohtml will return an element even for invalid names, which breaks `test_fetch_nonexistent'
86
+ // see getElement() in HTMLElements.java
87
+ HTMLElements.Element elem = htmlElements_.getElement(name.asJavaString(), htmlElements_.NO_SUCH_ELEMENT);
88
+ if (elem == htmlElements_.NO_SUCH_ELEMENT) {
89
89
  return context.nil;
90
90
  }
91
91
 
@@ -2,7 +2,7 @@ package nokogiri;
2
2
 
3
3
  import static org.jruby.runtime.Helpers.invoke;
4
4
 
5
- import org.cyberneko.html.HTMLEntities;
5
+ import net.sourceforge.htmlunit.cyberneko.HTMLEntitiesParser;
6
6
  import org.jruby.Ruby;
7
7
  import org.jruby.RubyClass;
8
8
  import org.jruby.RubyObject;
@@ -19,6 +19,7 @@ import org.jruby.runtime.builtin.IRubyObject;
19
19
  @JRubyClass(name = "Nokogiri::HTML4::EntityLookup")
20
20
  public class Html4EntityLookup extends RubyObject
21
21
  {
22
+ private static final long serialVersionUID = 1L;
22
23
 
23
24
  public
24
25
  Html4EntityLookup(Ruby runtime, RubyClass rubyClass)
@@ -37,8 +38,18 @@ public class Html4EntityLookup extends RubyObject
37
38
  {
38
39
  Ruby ruby = context.getRuntime();
39
40
  String name = key.toString();
40
- int val = HTMLEntities.get(name);
41
- if (val == -1) { return ruby.getNil(); }
41
+
42
+ HTMLEntitiesParser parser = new HTMLEntitiesParser();
43
+ for (int j = 0 ; j < name.length() ; j++) {
44
+ if (!parser.parse(name.charAt(j))) {
45
+ break;
46
+ }
47
+ }
48
+ String match = parser.getMatch();
49
+
50
+ if (match == null) { return ruby.getNil(); }
51
+
52
+ int val = match.charAt(0);
42
53
 
43
54
  IRubyObject edClass =
44
55
  ruby.getClassFromPath("Nokogiri::HTML4::EntityDescription");
@@ -9,7 +9,7 @@ import java.util.regex.Matcher;
9
9
  import java.util.regex.Pattern;
10
10
 
11
11
  import org.apache.xerces.parsers.AbstractSAXParser;
12
- import org.cyberneko.html.parsers.SAXParser;
12
+ import net.sourceforge.htmlunit.cyberneko.parsers.SAXParser;
13
13
  import org.jruby.Ruby;
14
14
  import org.jruby.RubyClass;
15
15
  import org.jruby.RubyFixnum;
@@ -30,10 +30,10 @@ import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
30
30
  * @author Patrick Mahoney <pat@polycrystal.org>
31
31
  * @author Yoko Harada <yokolet@gmail.com>
32
32
  */
33
-
34
33
  @JRubyClass(name = "Nokogiri::HTML4::SAX::ParserContext", parent = "Nokogiri::XML::SAX::ParserContext")
35
34
  public class Html4SaxParserContext extends XmlSaxParserContext
36
35
  {
36
+ private static final long serialVersionUID = 1L;
37
37
 
38
38
  static Html4SaxParserContext
39
39
  newInstance(final Ruby runtime, final RubyClass klazz)
@@ -30,6 +30,8 @@ import static org.jruby.runtime.Helpers.invoke;
30
30
  @JRubyClass(name = "Nokogiri::HTML4::SAX::PushParser")
31
31
  public class Html4SaxPushParser extends RubyObject
32
32
  {
33
+ private static final long serialVersionUID = 1L;
34
+
33
35
  ParserContext.Options options;
34
36
  IRubyObject saxParser;
35
37
 
@@ -45,6 +47,7 @@ public class Html4SaxPushParser extends RubyObject
45
47
  super(ruby, rubyClass);
46
48
  }
47
49
 
50
+ @SuppressWarnings("deprecation")
48
51
  @Override
49
52
  public void
50
53
  finalize()
@@ -29,6 +29,7 @@ public class NokogiriService implements BasicLibraryService
29
29
  return true;
30
30
  }
31
31
 
32
+ @SuppressWarnings("unchecked")
32
33
  public static Map<String, RubyClass>
33
34
  getNokogiriClassCache(Ruby ruby)
34
35
  {
@@ -39,7 +40,6 @@ public class NokogiriService implements BasicLibraryService
39
40
  populateNokogiriClassCahce(Ruby ruby)
40
41
  {
41
42
  Map<String, RubyClass> nokogiriClassCache = new HashMap<String, RubyClass>();
42
- nokogiriClassCache.put("Nokogiri::EncodingHandler", (RubyClass)ruby.getClassFromPath("Nokogiri::EncodingHandler"));
43
43
  nokogiriClassCache.put("Nokogiri::HTML4::Document", (RubyClass)ruby.getClassFromPath("Nokogiri::HTML4::Document"));
44
44
  nokogiriClassCache.put("Nokogiri::HTML4::ElementDescription",
45
45
  (RubyClass)ruby.getClassFromPath("Nokogiri::HTML4::ElementDescription"));
@@ -85,8 +85,6 @@ public class NokogiriService implements BasicLibraryService
85
85
  RubyModule htmlSaxModule = htmlModule.defineModuleUnder("SAX");
86
86
  RubyModule xsltModule = nokogiri.defineModuleUnder("XSLT");
87
87
 
88
- createJavaLibraryVersionConstants(ruby, nokogiri);
89
- createNokogiriModule(ruby, nokogiri);
90
88
  createSyntaxErrors(ruby, nokogiri, xmlModule);
91
89
  RubyClass xmlNode = createXmlModule(ruby, xmlModule);
92
90
  createHtmlModule(ruby, htmlModule);
@@ -96,20 +94,6 @@ public class NokogiriService implements BasicLibraryService
96
94
  nokogiri.setInternalVariable("cache", populateNokogiriClassCahce(ruby));
97
95
  }
98
96
 
99
- private void
100
- createJavaLibraryVersionConstants(Ruby ruby, RubyModule nokogiri)
101
- {
102
- nokogiri.defineConstant("XERCES_VERSION", ruby.newString(org.apache.xerces.impl.Version.getVersion()));
103
- nokogiri.defineConstant("NEKO_VERSION", ruby.newString(org.cyberneko.html.Version.getVersion()));
104
- }
105
-
106
- private void
107
- createNokogiriModule(Ruby ruby, RubyModule nokogiri)
108
- {
109
- RubyClass encHandler = nokogiri.defineClassUnder("EncodingHandler", ruby.getObject(), ENCODING_HANDLER_ALLOCATOR);
110
- encHandler.defineAnnotatedMethods(EncodingHandler.class);
111
- }
112
-
113
97
  private void
114
98
  createSyntaxErrors(Ruby ruby, RubyModule nokogiri, RubyModule xmlModule)
115
99
  {
@@ -246,13 +230,6 @@ public class NokogiriService implements BasicLibraryService
246
230
  xsltModule.defineAnnotatedMethod(XsltStylesheet.class, "register");
247
231
  }
248
232
 
249
- private static ObjectAllocator ENCODING_HANDLER_ALLOCATOR = new ObjectAllocator()
250
- {
251
- public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
252
- return new EncodingHandler(runtime, klazz, "");
253
- }
254
- };
255
-
256
233
  public static final ObjectAllocator HTML_DOCUMENT_ALLOCATOR = new ObjectAllocator()
257
234
  {
258
235
  private Html4Document htmlDocument = null;
@@ -22,10 +22,10 @@ import org.w3c.dom.Node;
22
22
  * @author sergio
23
23
  * @author Yoko Harada <yokolet@gmail.com>
24
24
  */
25
-
26
25
  @JRubyClass(name = "Nokogiri::XML::Attr", parent = "Nokogiri::XML::Node")
27
26
  public class XmlAttr extends XmlNode
28
27
  {
28
+ private static final long serialVersionUID = 1L;
29
29
 
30
30
  public static final String[] HTML_BOOLEAN_ATTRS = {
31
31
  "checked", "compact", "declare", "defer", "disabled", "ismap",
@@ -20,6 +20,7 @@ import org.w3c.dom.Node;
20
20
  @JRubyClass(name = "Nokogiri::XML::AttributeDecl", parent = "Nokogiri::XML::Node")
21
21
  public class XmlAttributeDecl extends XmlNode
22
22
  {
23
+ private static final long serialVersionUID = 1L;
23
24
 
24
25
  public
25
26
  XmlAttributeDecl(Ruby ruby, RubyClass klass)
@@ -105,7 +106,7 @@ public class XmlAttributeDecl extends XmlNode
105
106
  // removed enclosing parens
106
107
  String valueStr = atype.substring(1, atype.length() - 1);
107
108
  String[] values = valueStr.split("\\|");
108
- RubyArray enumVals = RubyArray.newArray(context.runtime, values.length);
109
+ RubyArray<?> enumVals = RubyArray.newArray(context.runtime, values.length);
109
110
  for (int i = 0; i < values.length; i++) {
110
111
  enumVals.append(context.runtime.newString(values[i]));
111
112
  }
@@ -19,10 +19,11 @@ import org.w3c.dom.Node;
19
19
  * @author sergio
20
20
  * @author Yoko Harada <yokolet@gmail.com>
21
21
  */
22
-
23
22
  @JRubyClass(name = "Nokogiri::XML::CDATA", parent = "Nokogiri::XML::Text")
24
23
  public class XmlCdata extends XmlText
25
24
  {
25
+ private static final long serialVersionUID = 1L;
26
+
26
27
  public
27
28
  XmlCdata(Ruby ruby, RubyClass rubyClass)
28
29
  {
@@ -18,10 +18,11 @@ import org.w3c.dom.Node;
18
18
  * @author sergio
19
19
  * @author Yoko Harada <yokolet@gmail.com>
20
20
  */
21
-
22
21
  @JRubyClass(name = "Nokogiri::XML::Comment", parent = "Nokogiri::XML::CharacterData")
23
22
  public class XmlComment extends XmlNode
24
23
  {
24
+ private static final long serialVersionUID = 1L;
25
+
25
26
  public
26
27
  XmlComment(Ruby ruby, RubyClass rubyClass, Node node)
27
28
  {
@@ -51,10 +51,11 @@ import nokogiri.internals.c14n.Canonicalizer;
51
51
  * @author Yoko Harada <yokolet@gmail.com>
52
52
  * @author John Shahid <jvshahid@gmail.com>
53
53
  */
54
-
55
54
  @JRubyClass(name = "Nokogiri::XML::Document", parent = "Nokogiri::XML::Node")
56
55
  public class XmlDocument extends XmlNode
57
56
  {
57
+ private static final long serialVersionUID = 1L;
58
+
58
59
  private NokogiriNamespaceCache nsCache;
59
60
 
60
61
  /* UserData keys for storing extra info in the document node. */
@@ -600,7 +601,7 @@ public class XmlDocument extends XmlNode
600
601
  public static IRubyObject
601
602
  wrap(ThreadContext context, IRubyObject klass, IRubyObject arg)
602
603
  {
603
- XmlDocument xmlDocument = new XmlDocument(context.runtime, (RubyClass) klass, (Document) arg.toJava(Document.class));
604
+ XmlDocument xmlDocument = new XmlDocument(context.runtime, (RubyClass) klass, arg.toJava(Document.class));
604
605
  Helpers.invoke(context, xmlDocument, "initialize");
605
606
  return xmlDocument;
606
607
  }
@@ -680,11 +681,9 @@ public class XmlDocument extends XmlNode
680
681
  result = canonicalizer.canonicalizeSubtree(startingNode.getNode(), inclusive_namespace, filter);
681
682
  }
682
683
  return RubyString.newString(context.runtime, new ByteList(result, UTF8Encoding.INSTANCE));
683
- } catch (CanonicalizationException e) {
684
- // TODO Auto-generated catch block
685
- e.printStackTrace();
684
+ } catch (Exception e) {
685
+ throw context.getRuntime().newRuntimeError(e.getMessage());
686
686
  }
687
- return context.nil;
688
687
  }
689
688
 
690
689
  private XmlNode
@@ -34,6 +34,7 @@ import org.w3c.dom.NamedNodeMap;
34
34
  @JRubyClass(name = "Nokogiri::XML::DocumentFragment", parent = "Nokogiri::XML::Node")
35
35
  public class XmlDocumentFragment extends XmlNode
36
36
  {
37
+ private static final long serialVersionUID = 1L;
37
38
 
38
39
  public
39
40
  XmlDocumentFragment(Ruby ruby)
@@ -122,7 +123,7 @@ public class XmlDocumentFragment extends XmlNode
122
123
  if (isNamespaceDefined(qName, nodeMap)) {
123
124
  CharSequence namespaceDecl = getNamespaceDecl(getPrefix(qName), nodeMap);
124
125
  if (namespaceDecl != null) {
125
- if (rewriteTable == null) { rewriteTable = new HashMap(8, 1); }
126
+ if (rewriteTable == null) { rewriteTable = new HashMap<CharSequence, CharSequence>(8, 1); }
126
127
  StringBuilder str = new StringBuilder(qName.length() + namespaceDecl.length() + 3);
127
128
  String key = str.append('<').append(qName).append('>').toString();
128
129
  str.setCharAt(key.length() - 1, ' '); // (last) '>' -> ' '
@@ -34,10 +34,11 @@ import nokogiri.internals.SaveContextVisitor;
34
34
  * @author Patrick Mahoney <pat@polycrystal.org>
35
35
  * @author Yoko Harada <yokolet@gmail.com>
36
36
  */
37
-
38
37
  @JRubyClass(name = "Nokogiri::XML::DTD", parent = "Nokogiri::XML::Node")
39
38
  public class XmlDtd extends XmlNode
40
39
  {
40
+ private static final long serialVersionUID = 1L;
41
+
41
42
  /** cache of children, Nokogiri::XML::NodeSet */
42
43
  protected IRubyObject children = null;
43
44
 
@@ -331,7 +332,7 @@ public class XmlDtd extends XmlNode
331
332
  public IRubyObject
332
333
  validate(ThreadContext context, IRubyObject doc)
333
334
  {
334
- RubyArray errors = RubyArray.newArray(context.getRuntime());
335
+ RubyArray<?> errors = RubyArray.newArray(context.getRuntime());
335
336
  if (doc instanceof XmlDocument) {
336
337
  errors = (RubyArray)((XmlDocument)doc).getInstanceVariable("@errors");
337
338
  }
@@ -416,7 +417,7 @@ public class XmlDtd extends XmlNode
416
417
  children = XmlNodeSet.newNodeSet(runtime, extractDecls(context, node.getFirstChild()));
417
418
 
418
419
  // add attribute decls as attributes to the matching element decl
419
- RubyArray keys = attributes.keys();
420
+ RubyArray<?> keys = attributes.keys();
420
421
  for (int i = 0; i < keys.getLength(); ++i) {
421
422
  IRubyObject akey = keys.entry(i);
422
423
  IRubyObject val;
@@ -19,6 +19,7 @@ import nokogiri.internals.SaveContextVisitor;
19
19
  @JRubyClass(name = "Nokogiri::XML::Element", parent = "Nokogiri::XML::Node")
20
20
  public class XmlElement extends XmlNode
21
21
  {
22
+ private static final long serialVersionUID = 1L;
22
23
 
23
24
  public
24
25
  XmlElement(Ruby runtime, RubyClass klazz)
@@ -26,6 +26,8 @@ import org.w3c.dom.Node;
26
26
  @JRubyClass(name = "Nokogiri::XML::ElementContent")
27
27
  public class XmlElementContent extends RubyObject
28
28
  {
29
+ private static final long serialVersionUID = 1L;
30
+
29
31
  protected String element_name = null;
30
32
 
31
33
  protected String name;
@@ -145,8 +147,9 @@ public class XmlElementContent extends RubyObject
145
147
  case SEQ:
146
148
  case OR:
147
149
  applyGroup(runtime, klass, doc, iter);
150
+ break;
148
151
  default:
149
- // noop
152
+ break;
150
153
  }
151
154
  }
152
155
 
@@ -22,7 +22,9 @@ import org.w3c.dom.Node;
22
22
  @JRubyClass(name = "Nokogiri::XML::ElementDecl", parent = "Nokogiri::XML::Node")
23
23
  public class XmlElementDecl extends XmlNode
24
24
  {
25
- RubyArray attrDecls;
25
+ private static final long serialVersionUID = 1L;
26
+
27
+ RubyArray<?> attrDecls;
26
28
  IRubyObject contentModel;
27
29
 
28
30
  public
@@ -20,6 +20,8 @@ import org.w3c.dom.Node;
20
20
  @JRubyClass(name = "Nokogiri::XML::EntityDecl", parent = "Nokogiri::XML::Node")
21
21
  public class XmlEntityDecl extends XmlNode
22
22
  {
23
+ private static final long serialVersionUID = 1L;
24
+
23
25
  public static final int INTERNAL_GENERAL = 1;
24
26
  public static final int EXTERNAL_GENERAL_PARSED = 2;
25
27
  public static final int EXTERNAL_GENERAL_UNPARSED = 3;
@@ -23,6 +23,7 @@ import org.w3c.dom.Node;
23
23
  @JRubyClass(name = "Nokogiri::XML::EntityReference", parent = "Nokogiri::XML::Node")
24
24
  public class XmlEntityReference extends XmlNode
25
25
  {
26
+ private static final long serialVersionUID = 1L;
26
27
 
27
28
  public
28
29
  XmlEntityReference(Ruby ruby, RubyClass klazz)
@@ -25,6 +25,8 @@ import org.w3c.dom.Node;
25
25
  @JRubyClass(name = "Nokogiri::XML::Namespace")
26
26
  public class XmlNamespace extends RubyObject
27
27
  {
28
+ private static final long serialVersionUID = 1L;
29
+
28
30
  private Attr attr;
29
31
  private transient IRubyObject prefixRuby;
30
32
  private transient IRubyObject hrefRuby;