nokogiri 1.5.10 → 1.10.4

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 (182) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-DEPENDENCIES.md +1614 -0
  3. data/LICENSE.md +9 -0
  4. data/README.md +198 -0
  5. data/bin/nokogiri +50 -10
  6. data/dependencies.yml +72 -0
  7. data/ext/nokogiri/extconf.rb +634 -92
  8. data/ext/nokogiri/html_document.c +8 -8
  9. data/ext/nokogiri/html_element_description.c +15 -15
  10. data/ext/nokogiri/html_entity_lookup.c +1 -1
  11. data/ext/nokogiri/html_sax_parser_context.c +4 -4
  12. data/ext/nokogiri/html_sax_push_parser.c +2 -2
  13. data/ext/nokogiri/nokogiri.c +20 -12
  14. data/ext/nokogiri/nokogiri.h +1 -44
  15. data/ext/nokogiri/xml_attr.c +34 -25
  16. data/ext/nokogiri/xml_cdata.c +12 -6
  17. data/ext/nokogiri/xml_comment.c +18 -3
  18. data/ext/nokogiri/xml_document.c +64 -32
  19. data/ext/nokogiri/xml_dtd.c +2 -2
  20. data/ext/nokogiri/xml_encoding_handler.c +3 -3
  21. data/ext/nokogiri/xml_entity_reference.c +1 -1
  22. data/ext/nokogiri/xml_io.c +11 -6
  23. data/ext/nokogiri/xml_namespace.c +50 -17
  24. data/ext/nokogiri/xml_namespace.h +3 -2
  25. data/ext/nokogiri/xml_node.c +459 -240
  26. data/ext/nokogiri/xml_node_set.c +166 -147
  27. data/ext/nokogiri/xml_node_set.h +2 -4
  28. data/ext/nokogiri/xml_processing_instruction.c +2 -2
  29. data/ext/nokogiri/xml_reader.c +6 -19
  30. data/ext/nokogiri/xml_sax_parser.c +11 -13
  31. data/ext/nokogiri/xml_sax_parser_context.c +41 -1
  32. data/ext/nokogiri/xml_sax_push_parser.c +56 -12
  33. data/ext/nokogiri/xml_schema.c +1 -1
  34. data/ext/nokogiri/xml_syntax_error.c +11 -5
  35. data/ext/nokogiri/xml_syntax_error.h +1 -1
  36. data/ext/nokogiri/xml_text.c +1 -1
  37. data/ext/nokogiri/xml_xpath_context.c +17 -38
  38. data/ext/nokogiri/xslt_stylesheet.c +10 -10
  39. data/lib/nokogiri/css/node.rb +0 -50
  40. data/lib/nokogiri/css/parser.rb +263 -233
  41. data/lib/nokogiri/css/parser.y +54 -40
  42. data/lib/nokogiri/css/tokenizer.rb +104 -103
  43. data/lib/nokogiri/css/tokenizer.rex +5 -5
  44. data/lib/nokogiri/css/xpath_visitor.rb +78 -19
  45. data/lib/nokogiri/decorators/slop.rb +12 -5
  46. data/lib/nokogiri/html/document.rb +102 -21
  47. data/lib/nokogiri/html/document_fragment.rb +11 -3
  48. data/lib/nokogiri/html/sax/parser.rb +12 -2
  49. data/lib/nokogiri/html/sax/push_parser.rb +22 -2
  50. data/lib/nokogiri/version.rb +40 -22
  51. data/lib/nokogiri/xml/builder.rb +34 -31
  52. data/lib/nokogiri/xml/document.rb +20 -14
  53. data/lib/nokogiri/xml/document_fragment.rb +50 -2
  54. data/lib/nokogiri/xml/dtd.rb +14 -4
  55. data/lib/nokogiri/xml/entity_reference.rb +18 -0
  56. data/lib/nokogiri/xml/node.rb +148 -203
  57. data/lib/nokogiri/xml/node_set.rb +139 -123
  58. data/lib/nokogiri/xml/parse_options.rb +22 -0
  59. data/lib/nokogiri/xml/sax/document.rb +1 -1
  60. data/lib/nokogiri/xml/sax/parser.rb +7 -8
  61. data/lib/nokogiri/xml/searchable.rb +230 -0
  62. data/lib/nokogiri/xml/syntax_error.rb +24 -1
  63. data/lib/nokogiri/xml.rb +3 -1
  64. data/lib/nokogiri.rb +40 -24
  65. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +78 -0
  66. data/patches/libxml2/0002-Remove-script-macro-support.patch +40 -0
  67. data/patches/libxml2/0003-Update-entities-to-remove-handling-of-ssi.patch +44 -0
  68. data/patches/libxslt/0001-Fix-security-framework-bypass.patch +120 -0
  69. data/ports/archives/libxml2-2.9.9.tar.gz +0 -0
  70. data/ports/archives/libxslt-1.1.33.tar.gz +0 -0
  71. metadata +252 -388
  72. data/.autotest +0 -26
  73. data/.gemtest +0 -0
  74. data/CHANGELOG.ja.rdoc +0 -785
  75. data/CHANGELOG.rdoc +0 -783
  76. data/C_CODING_STYLE.rdoc +0 -33
  77. data/Manifest.txt +0 -303
  78. data/README.ja.rdoc +0 -106
  79. data/README.rdoc +0 -175
  80. data/ROADMAP.md +0 -90
  81. data/Rakefile +0 -228
  82. data/STANDARD_RESPONSES.md +0 -47
  83. data/Y_U_NO_GEMSPEC.md +0 -155
  84. data/build_all +0 -105
  85. data/tasks/cross_compile.rb +0 -150
  86. data/tasks/nokogiri.org.rb +0 -24
  87. data/tasks/test.rb +0 -95
  88. data/test/css/test_nthiness.rb +0 -159
  89. data/test/css/test_parser.rb +0 -341
  90. data/test/css/test_tokenizer.rb +0 -198
  91. data/test/css/test_xpath_visitor.rb +0 -91
  92. data/test/decorators/test_slop.rb +0 -16
  93. data/test/files/2ch.html +0 -108
  94. data/test/files/address_book.rlx +0 -12
  95. data/test/files/address_book.xml +0 -10
  96. data/test/files/bar/bar.xsd +0 -4
  97. data/test/files/dont_hurt_em_why.xml +0 -422
  98. data/test/files/encoding.html +0 -82
  99. data/test/files/encoding.xhtml +0 -84
  100. data/test/files/exslt.xml +0 -8
  101. data/test/files/exslt.xslt +0 -35
  102. data/test/files/foo/foo.xsd +0 -4
  103. data/test/files/metacharset.html +0 -10
  104. data/test/files/noencoding.html +0 -47
  105. data/test/files/po.xml +0 -32
  106. data/test/files/po.xsd +0 -66
  107. data/test/files/shift_jis.html +0 -10
  108. data/test/files/shift_jis.xml +0 -5
  109. data/test/files/snuggles.xml +0 -3
  110. data/test/files/staff.dtd +0 -10
  111. data/test/files/staff.xml +0 -59
  112. data/test/files/staff.xslt +0 -32
  113. data/test/files/test_document_url/bar.xml +0 -2
  114. data/test/files/test_document_url/document.dtd +0 -4
  115. data/test/files/test_document_url/document.xml +0 -6
  116. data/test/files/tlm.html +0 -850
  117. data/test/files/to_be_xincluded.xml +0 -2
  118. data/test/files/valid_bar.xml +0 -2
  119. data/test/files/xinclude.xml +0 -4
  120. data/test/helper.rb +0 -154
  121. data/test/html/sax/test_parser.rb +0 -141
  122. data/test/html/sax/test_parser_context.rb +0 -46
  123. data/test/html/test_builder.rb +0 -164
  124. data/test/html/test_document.rb +0 -552
  125. data/test/html/test_document_encoding.rb +0 -138
  126. data/test/html/test_document_fragment.rb +0 -261
  127. data/test/html/test_element_description.rb +0 -105
  128. data/test/html/test_named_characters.rb +0 -14
  129. data/test/html/test_node.rb +0 -196
  130. data/test/html/test_node_encoding.rb +0 -27
  131. data/test/namespaces/test_additional_namespaces_in_builder_doc.rb +0 -14
  132. data/test/namespaces/test_namespaces_in_builder_doc.rb +0 -75
  133. data/test/namespaces/test_namespaces_in_created_doc.rb +0 -75
  134. data/test/namespaces/test_namespaces_in_parsed_doc.rb +0 -66
  135. data/test/test_convert_xpath.rb +0 -135
  136. data/test/test_css_cache.rb +0 -45
  137. data/test/test_encoding_handler.rb +0 -46
  138. data/test/test_memory_leak.rb +0 -156
  139. data/test/test_nokogiri.rb +0 -132
  140. data/test/test_reader.rb +0 -555
  141. data/test/test_soap4r_sax.rb +0 -52
  142. data/test/test_xslt_transforms.rb +0 -254
  143. data/test/xml/node/test_save_options.rb +0 -28
  144. data/test/xml/node/test_subclass.rb +0 -44
  145. data/test/xml/sax/test_parser.rb +0 -366
  146. data/test/xml/sax/test_parser_context.rb +0 -106
  147. data/test/xml/sax/test_push_parser.rb +0 -157
  148. data/test/xml/test_attr.rb +0 -64
  149. data/test/xml/test_attribute_decl.rb +0 -86
  150. data/test/xml/test_builder.rb +0 -306
  151. data/test/xml/test_c14n.rb +0 -151
  152. data/test/xml/test_cdata.rb +0 -48
  153. data/test/xml/test_comment.rb +0 -29
  154. data/test/xml/test_document.rb +0 -828
  155. data/test/xml/test_document_encoding.rb +0 -28
  156. data/test/xml/test_document_fragment.rb +0 -223
  157. data/test/xml/test_dtd.rb +0 -103
  158. data/test/xml/test_dtd_encoding.rb +0 -33
  159. data/test/xml/test_element_content.rb +0 -56
  160. data/test/xml/test_element_decl.rb +0 -73
  161. data/test/xml/test_entity_decl.rb +0 -122
  162. data/test/xml/test_entity_reference.rb +0 -245
  163. data/test/xml/test_namespace.rb +0 -95
  164. data/test/xml/test_node.rb +0 -1137
  165. data/test/xml/test_node_attributes.rb +0 -96
  166. data/test/xml/test_node_encoding.rb +0 -107
  167. data/test/xml/test_node_inheritance.rb +0 -32
  168. data/test/xml/test_node_reparenting.rb +0 -374
  169. data/test/xml/test_node_set.rb +0 -755
  170. data/test/xml/test_parse_options.rb +0 -64
  171. data/test/xml/test_processing_instruction.rb +0 -30
  172. data/test/xml/test_reader_encoding.rb +0 -142
  173. data/test/xml/test_relax_ng.rb +0 -60
  174. data/test/xml/test_schema.rb +0 -103
  175. data/test/xml/test_syntax_error.rb +0 -12
  176. data/test/xml/test_text.rb +0 -45
  177. data/test/xml/test_unparented_node.rb +0 -422
  178. data/test/xml/test_xinclude.rb +0 -83
  179. data/test/xml/test_xpath.rb +0 -295
  180. data/test/xslt/test_custom_functions.rb +0 -133
  181. data/test/xslt/test_exception_handling.rb +0 -37
  182. data/test_all +0 -81
data/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License
2
+
3
+ Copyright 2008 -- 2018 by Aaron Patterson, Mike Dalessio, Charles Nutter, Sergio Arbeo, Patrick Mahoney, Yoko Harada, Akinori MUSHA, John Shahid, Lars Kanis
4
+
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
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,198 @@
1
+ # Nokogiri
2
+
3
+ ## Description
4
+
5
+ Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among
6
+ Nokogiri's many features is the ability to search documents via XPath
7
+ or CSS3 selectors.
8
+
9
+
10
+ ## Links
11
+
12
+ * https://nokogiri.org
13
+ * [Installation Help](https://nokogiri.org/tutorials/installing_nokogiri.html)
14
+ * [Tutorials](https://nokogiri.org)
15
+ * [Cheat Sheet](https://github.com/sparklemotion/nokogiri/wiki/Cheat-sheet)
16
+ * [GitHub](https://github.com/sparklemotion/nokogiri)
17
+ * [Mailing List](https://groups.google.com/group/nokogiri-talk)
18
+ * [Chat/Gitter](https://gitter.im/sparklemotion/nokogiri)
19
+
20
+
21
+ ## Status
22
+
23
+ [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/nokogiri/jobs/ruby-2.4-system/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/nokogiri)
24
+ [![Appveyor CI](https://ci.appveyor.com/api/projects/status/xj2pqwvlxwuwgr06/branch/master?svg=true)](https://ci.appveyor.com/project/flavorjones/nokogiri/branch/master)
25
+ [![Code Climate](https://codeclimate.com/github/sparklemotion/nokogiri.svg)](https://codeclimate.com/github/sparklemotion/nokogiri)
26
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/59c67b0e8976027a45ad/test_coverage)](https://codeclimate.com/github/sparklemotion/nokogiri/test_coverage)
27
+
28
+ [![Gem Version](https://badge.fury.io/rb/nokogiri.svg)](https://rubygems.org/gems/nokogiri)
29
+ [![SemVer compatibility](https://api.dependabot.com/badges/compatibility_score?dependency-name=nokogiri&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=nokogiri&package-manager=bundler&version-scheme=semver)
30
+ [![Tidelift dependencies](https://tidelift.com/badges/github/sparklemotion/nokogiri)](https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme)
31
+
32
+
33
+ ## Features
34
+
35
+ * XML/HTML DOM parser which handles broken HTML
36
+ * XML/HTML SAX parser
37
+ * XML/HTML Push parser
38
+ * XPath 1.0 support for document searching
39
+ * CSS3 selector support for document searching
40
+ * XML/HTML builder
41
+ * XSLT transformer
42
+
43
+ Nokogiri parses and searches XML/HTML using native libraries (either C
44
+ or Java, depending on your Ruby), which means it's fast and
45
+ standards-compliant.
46
+
47
+
48
+ ## Installation
49
+
50
+ If this doesn't work:
51
+
52
+ ```
53
+ gem install nokogiri
54
+ ```
55
+
56
+ then please start troubleshooting here:
57
+
58
+ > https://nokogiri.org/tutorials/installing_nokogiri.html
59
+
60
+ There are currently 1,237 Stack Overflow questions about Nokogiri
61
+ installation. The vast majority of them are out of date and therefore
62
+ incorrect. __Please do not use Stack Overflow.__
63
+
64
+ Instead, [tell us](https://nokogiri.org/tutorials/getting_help.html)
65
+ when the above instructions don't work for you. This allows us to both
66
+ help you directly and improve the documentation.
67
+
68
+
69
+ ### Binary packages
70
+
71
+ Binary packages are available for some distributions.
72
+
73
+ * Debian: https://packages.debian.org/sid/ruby-nokogiri
74
+ * SuSE: https://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/
75
+ * Fedora: http://s390.koji.fedoraproject.org/koji/packageinfo?packageID=6756
76
+
77
+
78
+ ## Support
79
+
80
+ 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).
81
+
82
+ * The Nokogiri mailing list is active: https://groups.google.com/group/nokogiri-talk
83
+ * The Nokogiri bug tracker is here: https://github.com/sparklemotion/nokogiri/issues
84
+ * Before filing a bug report, please read our submission guidelines: http://nokogiri.org/tutorials/getting_help.html
85
+ * The IRC channel is `#nokogiri` on freenode.
86
+ * The project's GitHub wiki has an excellent community-maintained [Cheat Sheet](https://github.com/sparklemotion/nokogiri/wiki/Cheat-sheet) which might be useful.
87
+
88
+ 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.
89
+
90
+ [tidelift]: https://tidelift.com/subscription/pkg/rubygems-nokogiri?utm_source=rubygems-nokogiri&utm_medium=referral&utm_campaign=readme
91
+
92
+
93
+ ## Security and Vulnerability Reporting
94
+
95
+ Please report vulnerabilities at https://hackerone.com/nokogiri
96
+
97
+ Full information and description of our security policy is in [`SECURITY.md`](SECURITY.md)
98
+
99
+
100
+ ## Synopsis
101
+
102
+ Nokogiri is a large library, but here is example usage for parsing and examining a document:
103
+
104
+ ```ruby
105
+ #! /usr/bin/env ruby
106
+
107
+ require 'nokogiri'
108
+ require 'open-uri'
109
+
110
+ # Fetch and parse HTML document
111
+ doc = Nokogiri::HTML(open('https://nokogiri.org/tutorials/installing_nokogiri.html'))
112
+
113
+ puts "### Search for nodes by css"
114
+ doc.css('nav ul.menu li a', 'article h2').each do |link|
115
+ puts link.content
116
+ end
117
+
118
+ puts "### Search for nodes by xpath"
119
+ doc.xpath('//nav//ul//li/a', '//article//h2').each do |link|
120
+ puts link.content
121
+ end
122
+
123
+ puts "### Or mix and match."
124
+ doc.search('nav ul.menu li a', '//article//h2').each do |link|
125
+ puts link.content
126
+ end
127
+ ```
128
+
129
+
130
+ ## Requirements
131
+
132
+ * Ruby 2.3.0 or higher, including any development packages necessary
133
+ to compile native extensions.
134
+
135
+ * In Nokogiri 1.6.0 and later libxml2 and libxslt are bundled with the
136
+ gem, but if you want to use the system versions:
137
+
138
+ * First, check out [the long list](http://www.xmlsoft.org/news.html)
139
+ of fixes and changes between releases before deciding to use any
140
+ version older than is bundled with Nokogiri.
141
+
142
+ * At install time, set the environment variable
143
+ `NOKOGIRI_USE_SYSTEM_LIBRARIES` or else use the
144
+ `--use-system-libraries` argument. (See
145
+ https://nokogiri.org/tutorials/installing_nokogiri.html#install-with-system-libraries
146
+ for specifics.)
147
+
148
+ * libxml2 >=2.6.21 with iconv support
149
+ (libxml2-dev/-devel is also required)
150
+
151
+ * libxslt, built with and supported by the given libxml2
152
+ (libxslt-dev/-devel is also required)
153
+
154
+
155
+ ## Encoding
156
+
157
+ Strings are always stored as UTF-8 internally. Methods that return
158
+ text values will always return UTF-8 encoded strings. Methods that
159
+ return a string containing markup (like `to_xml`, `to_html` and
160
+ `inner_html`) will return a string encoded like the source document.
161
+
162
+ __WARNING__
163
+
164
+ Some documents declare one encoding, but actually use a different
165
+ one. In these cases, which encoding should the parser choose?
166
+
167
+ Data is just a stream of bytes. Humans add meaning to that stream. Any
168
+ particular set of bytes could be valid characters in multiple
169
+ encodings, so detecting encoding with 100% accuracy is not
170
+ possible. `libxml2` does its best, but it can't be right all the time.
171
+
172
+ If you want Nokogiri to handle the document encoding properly, your
173
+ best bet is to explicitly set the encoding. Here is an example of
174
+ explicitly setting the encoding to EUC-JP on the parser:
175
+
176
+ ```ruby
177
+ doc = Nokogiri.XML('<foo><bar /></foo>', nil, 'EUC-JP')
178
+ ```
179
+
180
+
181
+ ## Development
182
+
183
+ ```bash
184
+ bundle install
185
+ bundle exec rake compile test
186
+ ```
187
+
188
+
189
+ ## Code of Conduct
190
+
191
+ We've adopted the Contributor Covenant code of conduct, which you can read in full in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
192
+
193
+
194
+ ## License
195
+
196
+ This project is licensed under the terms of the MIT license.
197
+
198
+ See this license at [`LICENSE.md`](LICENSE.md).
data/bin/nokogiri CHANGED
@@ -1,30 +1,61 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'optparse'
3
3
  require 'open-uri'
4
- require 'irb'
5
4
  require 'uri'
6
5
  require 'rubygems'
7
6
  require 'nokogiri'
7
+ autoload :IRB, 'irb'
8
8
 
9
9
  parse_class = Nokogiri
10
10
  encoding = nil
11
11
 
12
+ # This module provides some tunables with the nokogiri CLI for use in
13
+ # your ~/.nokogirirc.
14
+ module Nokogiri::CLI
15
+ class << self
16
+ # Specify the console engine, defaulted to IRB.
17
+ #
18
+ # call-seq:
19
+ # require 'pry'
20
+ # Nokogiri::CLI.console = Pry
21
+ attr_writer :console
22
+
23
+ def console
24
+ case @console
25
+ when Symbol
26
+ Kernel.const_get(@console)
27
+ else
28
+ @console
29
+ end
30
+ end
31
+
32
+ attr_accessor :rcfile
33
+ end
34
+
35
+ self.rcfile = File.expand_path('~/.nokogirirc')
36
+ self.console = :IRB
37
+ end
38
+
12
39
  opts = OptionParser.new do |opts|
13
40
  opts.banner = "Nokogiri: an HTML, XML, SAX, and Reader parser"
14
41
  opts.define_head "Usage: nokogiri <uri|path> [options]"
15
42
  opts.separator ""
16
43
  opts.separator "Examples:"
17
- opts.separator " nokogiri http://www.ruby-lang.org/"
44
+ opts.separator " nokogiri https://www.ruby-lang.org/"
18
45
  opts.separator " nokogiri ./public/index.html"
19
- opts.separator " curl -s http://nokogiri.org | nokogiri -e'p $_.css(\"h1\").length'"
46
+ opts.separator " curl -s http://www.nokogiri.org | nokogiri -e'p $_.css(\"h1\").length'"
20
47
  opts.separator ""
21
48
  opts.separator "Options:"
22
49
 
23
- opts.on("--type [TYPE]", [:xml, :html]) do |v|
50
+ opts.on("--type type", "Parse as type: xml or html (default: auto)", [:xml, :html]) do |v|
24
51
  parse_class = {:xml => Nokogiri::XML, :html => Nokogiri::HTML}[v]
25
52
  end
26
53
 
27
- opts.on("-E", "--encoding encoding", "Read as encoding (default #{encoding})") do |v|
54
+ opts.on("-C file", "Specifies initialization file to load (default #{Nokogiri::CLI.rcfile})") do |v|
55
+ Nokogiri::CLI.rcfile = v
56
+ end
57
+
58
+ opts.on("-E", "--encoding encoding", "Read as encoding (default: #{encoding || 'none'})") do |v|
28
59
  encoding = v
29
60
  end
30
61
 
@@ -48,15 +79,24 @@ opts = OptionParser.new do |opts|
48
79
  end
49
80
  opts.parse!
50
81
 
51
- uri = ARGV.shift
82
+ url = ARGV.shift
52
83
 
53
- if uri.to_s.strip.empty? && $stdin.tty?
84
+ if url.to_s.strip.empty? && $stdin.tty?
54
85
  puts opts
55
86
  exit 1
56
87
  end
57
88
 
58
- if $stdin.tty?
59
- @doc = parse_class.parse(open(uri).read, nil, encoding)
89
+ if File.file?(Nokogiri::CLI.rcfile)
90
+ load Nokogiri::CLI.rcfile
91
+ end
92
+
93
+ if url || $stdin.tty?
94
+ case uri = (URI(url) rescue url)
95
+ when URI::HTTP
96
+ @doc = parse_class.parse(uri.read, url, encoding)
97
+ else
98
+ @doc = parse_class.parse(open(url).read, nil, encoding)
99
+ end
60
100
  else
61
101
  @doc = parse_class.parse($stdin, nil, encoding)
62
102
  end
@@ -72,7 +112,7 @@ else
72
112
  eval @script, binding, '<main>'
73
113
  else
74
114
  puts "Your document is stored in @doc..."
75
- IRB.start
115
+ Nokogiri::CLI.console.start
76
116
  end
77
117
  end
78
118
 
data/dependencies.yml ADDED
@@ -0,0 +1,72 @@
1
+ libxml2:
2
+ version: "2.9.9"
3
+ sha256: "94fb70890143e3c6549f265cee93ec064c80a84c42ad0f23e85ee1fd6540a871"
4
+ # manually verified checksum:
5
+ #
6
+ # $ gpg --verify libxml2-2.9.9.tar.gz.asc ports/archives/libxml2-2.9.9.tar.gz
7
+ # gpg: Signature made Thu 03 Jan 2019 01:14:47 PM EST
8
+ # gpg: using RSA key 15588B26596BEA5D
9
+ # gpg: Good signature from "Daniel Veillard (Red Hat work email) <veillard@redhat.com>" [unknown]
10
+ # gpg: aka "Daniel Veillard <Daniel.Veillard@w3.org>" [unknown]
11
+ # gpg: WARNING: This key is not certified with a trusted signature!
12
+ # gpg: There is no indication that the signature belongs to the owner.
13
+ # Primary key fingerprint: C744 15BA 7C9C 7F78 F02E 1DC3 4606 B8A5 DE95 BC1F
14
+ # Subkey fingerprint: DB46 681B B91A DCEA 170F A2D4 1558 8B26 596B EA5D
15
+ #
16
+ # using this pgp signature:
17
+ #
18
+ # -----BEGIN PGP SIGNATURE-----
19
+ #
20
+ # iQEbBAABAgAGBQJcLlEXAAoJEBVYiyZZa+pd1B8H93xeCYNBLx+eX0xe3qS3ReS/
21
+ # YstjkXKUkmDQYwqQ/9Knmv1P6NX64hQL5E1pZX5sXp36giwXXJ5tCK72VRzektzU
22
+ # Kpo+M1/QA9feZQs1GmyKaXYzNwTSJnsdKA9nWqTHZ3bzfdhFSZ0czo94vgY/cz5z
23
+ # 9P3FIgeldj1vi8p2rjXbArMFQyaxHnve9LdxI8hbudNSeUw/FEV6mjtXrlZ7MXqn
24
+ # hmAkah2JwktOStF5tIlddCRqZeUPUX5flBxT95gfskXXlGEhaoGMXcC3izqqJyV2
25
+ # sx5nY7fnXdkwfYsgRUXYWmDmbs8DnFjXH9lux9O4OWglLonaRoAqFPcOzE3aCw==
26
+ # =4qWg
27
+ # -----END PGP SIGNATURE-----
28
+ #
29
+
30
+ libxslt:
31
+ version: "1.1.33"
32
+ sha256: "8e36605144409df979cab43d835002f63988f3dc94d5d3537c12796db90e38c8"
33
+ # manually verified checksum:
34
+ #
35
+ # $ gpg --verify libxslt-1.1.33.tar.gz.asc ports/archives/libxslt-1.1.33.tar.gz
36
+ # gpg: Signature made Thu 03 Jan 2019 01:30:49 PM EST
37
+ # gpg: using RSA key 15588B26596BEA5D
38
+ # gpg: Good signature from "Daniel Veillard (Red Hat work email) <veillard@redhat.com>" [unknown]
39
+ # gpg: aka "Daniel Veillard <Daniel.Veillard@w3.org>" [unknown]
40
+ # gpg: WARNING: This key is not certified with a trusted signature!
41
+ # gpg: There is no indication that the signature belongs to the owner.
42
+ # Primary key fingerprint: C744 15BA 7C9C 7F78 F02E 1DC3 4606 B8A5 DE95 BC1F
43
+ # Subkey fingerprint: DB46 681B B91A DCEA 170F A2D4 1558 8B26 596B EA5D
44
+ #
45
+ # using this pgp signature:
46
+ #
47
+ # -----BEGIN PGP SIGNATURE-----
48
+ #
49
+ # iQEcBAABAgAGBQJcLlTZAAoJEBVYiyZZa+pd9NkIAIf6ei2iSpR/0QOyS71esDq8
50
+ # 407PcUXd/yUjDANm4Uvm7kKK+SbbfBxFIPva4g984Noe1zYMfjK3u3iNs6jykySf
51
+ # mN5eo2wNCxsZnqjbnsLgQvn5VCQpPInTddTuGUxgqJyvnR7p785L1oA2EStSPMP4
52
+ # BGZ9dZGlbreK35WzgrhUi0VN5egJW2fpMsw7rTPvfwK+90gXL0DEm8v3WlA7fCDL
53
+ # QsvuPm7jPOXxdt5bYrVP8wpNMTJIGqV6jxh7Vvl6kiGLldUjCyoCh0AGXLror0Gs
54
+ # sAMlRKJNodpcCYkIWxzjLt74sUciKNrPLHZlXJcclZMONen1GWnVDcv83Tt9n6w=
55
+ # =iAm8
56
+ # -----END PGP SIGNATURE-----
57
+ #
58
+
59
+ zlib:
60
+ version: "1.2.11"
61
+ sha256: "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
62
+ # SHA-256 hash provided on http://zlib.net/
63
+
64
+ libiconv:
65
+ version: "1.15"
66
+ sha256: "ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178"
67
+ # gpg: Signature made Fri Feb 3 00:38:12 2017 CET
68
+ # gpg: using RSA key 4F494A942E4616C2
69
+ # gpg: Good signature from "Bruno Haible (Open Source Development) <bruno@clisp.org>" [unknown]
70
+ # gpg: WARNING: This key is not certified with a trusted signature!
71
+ # gpg: There is no indication that the signature belongs to the owner.
72
+ # Primary key fingerprint: 68D9 4D8A AEEA D48A E7DC 5B90 4F49 4A94 2E46 16C2