nokogiri 1.10.8-java → 1.11.0.rc3-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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -22
  3. data/ext/java/nokogiri/HtmlDocument.java +34 -46
  4. data/ext/java/nokogiri/HtmlSaxParserContext.java +87 -57
  5. data/ext/java/nokogiri/NokogiriService.java +1 -1
  6. data/ext/java/nokogiri/XmlAttr.java +13 -20
  7. data/ext/java/nokogiri/XmlAttributeDecl.java +11 -12
  8. data/ext/java/nokogiri/XmlCdata.java +3 -4
  9. data/ext/java/nokogiri/XmlComment.java +1 -1
  10. data/ext/java/nokogiri/XmlDocument.java +148 -175
  11. data/ext/java/nokogiri/XmlDocumentFragment.java +13 -31
  12. data/ext/java/nokogiri/XmlDtd.java +5 -8
  13. data/ext/java/nokogiri/XmlElement.java +1 -20
  14. data/ext/java/nokogiri/XmlElementDecl.java +23 -28
  15. data/ext/java/nokogiri/XmlEntityDecl.java +23 -27
  16. data/ext/java/nokogiri/XmlEntityReference.java +2 -2
  17. data/ext/java/nokogiri/XmlNamespace.java +72 -89
  18. data/ext/java/nokogiri/XmlNode.java +300 -401
  19. data/ext/java/nokogiri/XmlNodeSet.java +72 -77
  20. data/ext/java/nokogiri/XmlReader.java +10 -11
  21. data/ext/java/nokogiri/XmlSaxParserContext.java +7 -7
  22. data/ext/java/nokogiri/XmlSchema.java +3 -3
  23. data/ext/java/nokogiri/XmlText.java +12 -9
  24. data/ext/java/nokogiri/XmlXpathContext.java +7 -7
  25. data/ext/java/nokogiri/XsltStylesheet.java +7 -15
  26. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +4 -10
  27. data/ext/java/nokogiri/internals/NokogiriHelpers.java +71 -135
  28. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +90 -58
  29. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +5 -4
  30. data/ext/java/nokogiri/internals/ParserContext.java +27 -73
  31. data/ext/java/nokogiri/internals/ReaderNode.java +2 -4
  32. data/ext/java/nokogiri/internals/XmlDomParserContext.java +17 -32
  33. data/ext/nokogiri/extconf.rb +50 -37
  34. data/ext/nokogiri/nokogiri.c +12 -6
  35. data/ext/nokogiri/nokogiri.h +13 -0
  36. data/ext/nokogiri/xml_document.c +16 -2
  37. data/ext/nokogiri/xml_io.c +8 -6
  38. data/ext/nokogiri/xml_node.c +20 -0
  39. data/ext/nokogiri/xml_reader.c +6 -17
  40. data/ext/nokogiri/xml_schema.c +29 -0
  41. data/ext/nokogiri/xslt_stylesheet.c +0 -4
  42. data/lib/nokogiri.rb +3 -20
  43. data/lib/nokogiri/css.rb +1 -0
  44. data/lib/nokogiri/css/node.rb +1 -0
  45. data/lib/nokogiri/css/parser.rb +61 -60
  46. data/lib/nokogiri/css/parser_extras.rb +39 -36
  47. data/lib/nokogiri/css/syntax_error.rb +1 -0
  48. data/lib/nokogiri/css/tokenizer.rb +1 -0
  49. data/lib/nokogiri/css/xpath_visitor.rb +3 -1
  50. data/lib/nokogiri/decorators/slop.rb +1 -0
  51. data/lib/nokogiri/html.rb +1 -0
  52. data/lib/nokogiri/html/builder.rb +1 -0
  53. data/lib/nokogiri/html/document.rb +1 -0
  54. data/lib/nokogiri/html/document_fragment.rb +1 -0
  55. data/lib/nokogiri/html/element_description.rb +1 -0
  56. data/lib/nokogiri/html/element_description_defaults.rb +1 -0
  57. data/lib/nokogiri/html/entity_lookup.rb +1 -0
  58. data/lib/nokogiri/html/sax/parser.rb +1 -0
  59. data/lib/nokogiri/html/sax/parser_context.rb +1 -0
  60. data/lib/nokogiri/html/sax/push_parser.rb +1 -0
  61. data/lib/nokogiri/jruby/dependencies.rb +20 -0
  62. data/lib/nokogiri/nokogiri.jar +0 -0
  63. data/lib/nokogiri/syntax_error.rb +1 -0
  64. data/lib/nokogiri/version.rb +86 -45
  65. data/lib/nokogiri/xml.rb +1 -0
  66. data/lib/nokogiri/xml/attr.rb +1 -0
  67. data/lib/nokogiri/xml/attribute_decl.rb +1 -0
  68. data/lib/nokogiri/xml/builder.rb +3 -2
  69. data/lib/nokogiri/xml/cdata.rb +1 -0
  70. data/lib/nokogiri/xml/character_data.rb +1 -0
  71. data/lib/nokogiri/xml/document.rb +3 -8
  72. data/lib/nokogiri/xml/document_fragment.rb +1 -0
  73. data/lib/nokogiri/xml/dtd.rb +1 -0
  74. data/lib/nokogiri/xml/element_content.rb +1 -0
  75. data/lib/nokogiri/xml/element_decl.rb +1 -0
  76. data/lib/nokogiri/xml/entity_decl.rb +1 -0
  77. data/lib/nokogiri/xml/entity_reference.rb +1 -0
  78. data/lib/nokogiri/xml/namespace.rb +1 -0
  79. data/lib/nokogiri/xml/node.rb +539 -224
  80. data/lib/nokogiri/xml/node/save_options.rb +1 -0
  81. data/lib/nokogiri/xml/node_set.rb +1 -0
  82. data/lib/nokogiri/xml/notation.rb +1 -0
  83. data/lib/nokogiri/xml/parse_options.rb +4 -3
  84. data/lib/nokogiri/xml/pp.rb +1 -0
  85. data/lib/nokogiri/xml/pp/character_data.rb +1 -0
  86. data/lib/nokogiri/xml/pp/node.rb +1 -0
  87. data/lib/nokogiri/xml/processing_instruction.rb +1 -0
  88. data/lib/nokogiri/xml/reader.rb +7 -3
  89. data/lib/nokogiri/xml/relax_ng.rb +1 -0
  90. data/lib/nokogiri/xml/sax.rb +1 -0
  91. data/lib/nokogiri/xml/sax/document.rb +1 -0
  92. data/lib/nokogiri/xml/sax/parser.rb +1 -0
  93. data/lib/nokogiri/xml/sax/parser_context.rb +1 -0
  94. data/lib/nokogiri/xml/sax/push_parser.rb +1 -0
  95. data/lib/nokogiri/xml/schema.rb +1 -0
  96. data/lib/nokogiri/xml/searchable.rb +22 -15
  97. data/lib/nokogiri/xml/syntax_error.rb +1 -0
  98. data/lib/nokogiri/xml/text.rb +1 -0
  99. data/lib/nokogiri/xml/xpath.rb +1 -0
  100. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -0
  101. data/lib/nokogiri/xml/xpath_context.rb +1 -0
  102. data/lib/nokogiri/xslt.rb +1 -0
  103. data/lib/nokogiri/xslt/stylesheet.rb +1 -0
  104. data/lib/xsd/xmlparser/nokogiri.rb +1 -0
  105. metadata +53 -34
  106. data/ext/java/nokogiri/internals/NokogiriEncodingReaderWrapper.java +0 -107
  107. data/ext/java/nokogiri/internals/UncloseableInputStream.java +0 -102
@@ -1,107 +0,0 @@
1
- package nokogiri.internals;
2
-
3
- import java.io.InputStream;
4
-
5
- import org.jruby.Ruby;
6
- import org.jruby.RubyObject;
7
- import org.jruby.exceptions.RaiseException;
8
- import org.jruby.runtime.Helpers;
9
- import org.jruby.runtime.ThreadContext;
10
- import org.jruby.runtime.builtin.IRubyObject;
11
- import org.jruby.util.ByteList;
12
-
13
- /**
14
- * This class wraps the EncodingReader which act like a rewinding input stream,
15
- * it tries to read the first 1K of data to detect the encoding, but save
16
- * this data in a buffer for the subsequent read. Unfortunately, the EncodingReader
17
- * will behave as expected only if encoding was detected, otherwise, the read data
18
- * won't be stored and EncodingReader will fallback to read directory from the io stream.
19
- * this is kind of lame, since we need to have similar logic in both layers. The alternative
20
- * is to implement the encoding detection similar to the way C-Nokogiri does it; it starts
21
- * parsing assuming encoding is unknown and if encoding is detected it will throw an exception
22
- * causing parsing to stop, in which case we have to intercept the exception and set the encoding.
23
- * Also in this case we don't have to restart the parsing since html/document.rb does that for us.
24
- *
25
- * @author John Shahid <jvshahid@gmail.com>
26
- *
27
- */
28
- public class NokogiriEncodingReaderWrapper extends InputStream {
29
- private final ThreadContext context;
30
- private final IRubyObject encodingReader;
31
- private final Ruby ruby;
32
- private IRubyObject detectedEncoding;
33
- private final byte[] firstChunk = new byte[1024];
34
- private int firstChunkOff = 0;
35
- private int firstChunkLength = 0;
36
-
37
- public NokogiriEncodingReaderWrapper(ThreadContext context, RubyObject encodingReader) {
38
- this.context = context;
39
- this.encodingReader = encodingReader;
40
- this.ruby = context.getRuntime();
41
-
42
- if (!Helpers.invoke(context, encodingReader, "respond_to?", ruby.newSymbol("read")).isTrue()
43
- || encodingReader.getInstanceVariable("@io") == null) {
44
- throw ruby.newArgumentError("Argument doesn't respond to read or doesn't have instance variable @io");
45
- }
46
- }
47
-
48
- public boolean detectEncoding() {
49
- try {
50
- firstChunkLength = read(firstChunk);
51
- } catch (RaiseException e) {
52
- detectedEncoding = e.getException().getInstanceVariable("@found_encoding");
53
- return true;
54
- }
55
- detectedEncoding = context.nil;
56
- return false;
57
- }
58
-
59
- public IRubyObject getEncoding() {
60
- return detectedEncoding;
61
- }
62
-
63
- @Override
64
- public int read(byte b[]) {
65
- return read(b, 0, b.length);
66
- }
67
-
68
- @Override
69
- public int read(byte b[], int off, int len) {
70
- if (b == null) {
71
- throw new NullPointerException();
72
- } else if (off < 0 || len < 0 || len > b.length - off) {
73
- throw new IndexOutOfBoundsException();
74
- } else if (len == 0) {
75
- return 0;
76
- }
77
-
78
- int copyLength = Math.min(firstChunkLength - firstChunkOff, len);
79
- if (copyLength > 0) {
80
- System.arraycopy(firstChunk, firstChunkOff, b, off, copyLength);
81
- len -= copyLength;
82
- firstChunkOff += copyLength;
83
- }
84
-
85
- if (len <= 0)
86
- return copyLength;
87
-
88
- IRubyObject returnValue = encodingReader.callMethod(context, "read", ruby.newFixnum(len));
89
- if (returnValue.isNil())
90
- return -1;
91
-
92
- ByteList bytes = returnValue.asString().getByteList();
93
- int length = bytes.length();
94
- System.arraycopy(bytes.unsafeBytes(), bytes.getBegin(), b, off + copyLength, length);
95
- return length + copyLength;
96
- }
97
-
98
- @Override
99
- public int read() {
100
- byte[] bytes = new byte[1];
101
- int count = read(bytes, 0, 1);
102
- if (count < 1)
103
- return count;
104
- return bytes[0];
105
- }
106
-
107
- }
@@ -1,102 +0,0 @@
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
- package nokogiri.internals;
34
-
35
- import java.io.IOException;
36
- import java.io.InputStream;
37
-
38
- /**
39
- * Delegates all the methods to another InputStream except the
40
- * close() method, which is ignored. This is used to fix #495.
41
- *
42
- * @author John Shahid <jvshahid@gmail.com>
43
- */
44
- public class UncloseableInputStream extends InputStream {
45
- private final InputStream delegate;
46
-
47
- /**
48
- * Create a new uncloseable stream.
49
- *
50
- * @param delegate The InputStream to which all methods (except close)
51
- * will be delegated.
52
- */
53
- public UncloseableInputStream(InputStream delegate) {
54
- this.delegate = delegate;
55
- }
56
-
57
- @Override
58
- public int read() throws IOException {
59
- return delegate.read();
60
- }
61
-
62
- @Override
63
- public int read(byte []b) throws IOException {
64
- return delegate.read(b);
65
- }
66
-
67
- @Override
68
- public int read(byte []b, int offset, int len) throws IOException {
69
- return delegate.read(b, offset, len);
70
- }
71
-
72
- @Override
73
- public long skip(long n) throws IOException {
74
- return delegate.skip(n);
75
- }
76
-
77
- @Override
78
- public int available() throws IOException {
79
- return delegate.available();
80
- }
81
-
82
- @Override
83
- public void close() {
84
- // don't forward this to the InputStream we're delegating from
85
- // we don't want the InputStream of the RubyIO to be closed
86
- }
87
-
88
- @Override
89
- public void mark(int readlimit) {
90
- delegate.mark(readlimit);
91
- }
92
-
93
- @Override
94
- public void reset() throws IOException {
95
- delegate.reset();
96
- }
97
-
98
- @Override
99
- public boolean markSupported() {
100
- return delegate.markSupported();
101
- }
102
- }