nokogiri 1.10.8-x86-mingw32 → 1.11.0.rc3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +24 -22
- data/ext/nokogiri/extconf.rb +50 -37
- data/ext/nokogiri/nokogiri.c +12 -6
- data/ext/nokogiri/nokogiri.h +13 -0
- data/ext/nokogiri/xml_document.c +16 -2
- data/ext/nokogiri/xml_io.c +8 -6
- data/ext/nokogiri/xml_node.c +20 -0
- data/ext/nokogiri/xml_reader.c +6 -17
- data/ext/nokogiri/xml_schema.c +29 -0
- data/ext/nokogiri/xslt_stylesheet.c +0 -4
- data/lib/nokogiri.rb +3 -20
- data/lib/nokogiri/2.4/nokogiri.so +0 -0
- data/lib/nokogiri/2.5/nokogiri.so +0 -0
- data/lib/nokogiri/2.6/nokogiri.so +0 -0
- data/lib/nokogiri/{2.3 → 2.7}/nokogiri.so +0 -0
- data/lib/nokogiri/css.rb +1 -0
- data/lib/nokogiri/css/node.rb +1 -0
- data/lib/nokogiri/css/parser.rb +61 -60
- data/lib/nokogiri/css/parser_extras.rb +39 -36
- data/lib/nokogiri/css/syntax_error.rb +1 -0
- data/lib/nokogiri/css/tokenizer.rb +1 -0
- data/lib/nokogiri/css/xpath_visitor.rb +3 -1
- data/lib/nokogiri/decorators/slop.rb +1 -0
- data/lib/nokogiri/html.rb +1 -0
- data/lib/nokogiri/html/builder.rb +1 -0
- data/lib/nokogiri/html/document.rb +1 -0
- data/lib/nokogiri/html/document_fragment.rb +1 -0
- data/lib/nokogiri/html/element_description.rb +1 -0
- data/lib/nokogiri/html/element_description_defaults.rb +1 -0
- data/lib/nokogiri/html/entity_lookup.rb +1 -0
- data/lib/nokogiri/html/sax/parser.rb +1 -0
- data/lib/nokogiri/html/sax/parser_context.rb +1 -0
- data/lib/nokogiri/html/sax/push_parser.rb +1 -0
- data/lib/nokogiri/jruby/dependencies.rb +20 -0
- data/lib/nokogiri/syntax_error.rb +1 -0
- data/lib/nokogiri/version.rb +86 -45
- data/lib/nokogiri/xml.rb +1 -0
- data/lib/nokogiri/xml/attr.rb +1 -0
- data/lib/nokogiri/xml/attribute_decl.rb +1 -0
- data/lib/nokogiri/xml/builder.rb +3 -2
- data/lib/nokogiri/xml/cdata.rb +1 -0
- data/lib/nokogiri/xml/character_data.rb +1 -0
- data/lib/nokogiri/xml/document.rb +3 -8
- data/lib/nokogiri/xml/document_fragment.rb +1 -0
- data/lib/nokogiri/xml/dtd.rb +1 -0
- data/lib/nokogiri/xml/element_content.rb +1 -0
- data/lib/nokogiri/xml/element_decl.rb +1 -0
- data/lib/nokogiri/xml/entity_decl.rb +1 -0
- data/lib/nokogiri/xml/entity_reference.rb +1 -0
- data/lib/nokogiri/xml/namespace.rb +1 -0
- data/lib/nokogiri/xml/node.rb +539 -224
- data/lib/nokogiri/xml/node/save_options.rb +1 -0
- data/lib/nokogiri/xml/node_set.rb +1 -0
- data/lib/nokogiri/xml/notation.rb +1 -0
- data/lib/nokogiri/xml/parse_options.rb +4 -3
- data/lib/nokogiri/xml/pp.rb +1 -0
- data/lib/nokogiri/xml/pp/character_data.rb +1 -0
- data/lib/nokogiri/xml/pp/node.rb +1 -0
- data/lib/nokogiri/xml/processing_instruction.rb +1 -0
- data/lib/nokogiri/xml/reader.rb +7 -3
- data/lib/nokogiri/xml/relax_ng.rb +1 -0
- data/lib/nokogiri/xml/sax.rb +1 -0
- data/lib/nokogiri/xml/sax/document.rb +1 -0
- data/lib/nokogiri/xml/sax/parser.rb +1 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +1 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +1 -0
- data/lib/nokogiri/xml/schema.rb +1 -0
- data/lib/nokogiri/xml/searchable.rb +22 -15
- data/lib/nokogiri/xml/syntax_error.rb +1 -0
- data/lib/nokogiri/xml/text.rb +1 -0
- data/lib/nokogiri/xml/xpath.rb +1 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -0
- data/lib/nokogiri/xml/xpath_context.rb +1 -0
- data/lib/nokogiri/xslt.rb +1 -0
- data/lib/nokogiri/xslt/stylesheet.rb +1 -0
- data/lib/xsd/xmlparser/nokogiri.rb +1 -0
- metadata +46 -40
@@ -1,63 +1,66 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "thread"
|
2
3
|
|
3
4
|
module Nokogiri
|
4
5
|
module CSS
|
5
6
|
class Parser < Racc::Parser
|
6
|
-
|
7
|
-
|
8
|
-
@
|
7
|
+
CACHE_SWITCH_NAME = :nokogiri_css_parser_cache_is_off
|
8
|
+
|
9
|
+
@cache = {}
|
10
|
+
@mutex = Mutex.new
|
9
11
|
|
10
12
|
class << self
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
# Return a thread-local boolean indicating whether the CSS-to-XPath cache is active. (Default is `true`.)
|
14
|
+
def cache_on?
|
15
|
+
!Thread.current[CACHE_SWITCH_NAME]
|
16
|
+
end
|
17
|
+
|
18
|
+
# Set a thread-local boolean to turn cacheing on and off. Truthy values turn the cache on, falsey values turn the cache off.
|
19
|
+
def set_cache(value)
|
20
|
+
Thread.current[CACHE_SWITCH_NAME] = !value
|
21
|
+
end
|
15
22
|
|
16
23
|
# Get the css selector in +string+ from the cache
|
17
|
-
def []
|
18
|
-
return unless
|
24
|
+
def [](string)
|
25
|
+
return unless cache_on?
|
19
26
|
@mutex.synchronize { @cache[string] }
|
20
27
|
end
|
21
28
|
|
22
29
|
# Set the css selector in +string+ in the cache to +value+
|
23
|
-
def []=
|
24
|
-
return value unless
|
30
|
+
def []=(string, value)
|
31
|
+
return value unless cache_on?
|
25
32
|
@mutex.synchronize { @cache[string] = value }
|
26
33
|
end
|
27
34
|
|
28
35
|
# Clear the cache
|
29
|
-
def clear_cache
|
30
|
-
@mutex.synchronize
|
36
|
+
def clear_cache(create_new_object = false)
|
37
|
+
@mutex.synchronize do
|
38
|
+
if create_new_object
|
39
|
+
@cache = {}
|
40
|
+
else
|
41
|
+
@cache.clear
|
42
|
+
end
|
43
|
+
end
|
31
44
|
end
|
32
45
|
|
33
46
|
# Execute +block+ without cache
|
34
|
-
def without_cache
|
35
|
-
|
36
|
-
|
47
|
+
def without_cache(&block)
|
48
|
+
original_cache_setting = cache_on?
|
49
|
+
set_cache false
|
37
50
|
block.call
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
###
|
42
|
-
# Parse this CSS selector in +selector+. Returns an AST.
|
43
|
-
def parse selector
|
44
|
-
@warned ||= false
|
45
|
-
unless @warned
|
46
|
-
$stderr.puts('Nokogiri::CSS::Parser.parse is deprecated, call Nokogiri::CSS.parse(), this will be removed August 1st or version 1.4.0 (whichever is first)')
|
47
|
-
@warned = true
|
48
|
-
end
|
49
|
-
new.parse selector
|
51
|
+
ensure
|
52
|
+
set_cache original_cache_setting
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
53
56
|
# Create a new CSS parser with respect to +namespaces+
|
54
|
-
def initialize
|
55
|
-
@tokenizer
|
57
|
+
def initialize(namespaces = {})
|
58
|
+
@tokenizer = Tokenizer.new
|
56
59
|
@namespaces = namespaces
|
57
60
|
super()
|
58
61
|
end
|
59
62
|
|
60
|
-
def parse
|
63
|
+
def parse(string)
|
61
64
|
@tokenizer.scan_setup string
|
62
65
|
do_parse
|
63
66
|
end
|
@@ -67,14 +70,14 @@ module Nokogiri
|
|
67
70
|
end
|
68
71
|
|
69
72
|
# Get the xpath for +string+ using +options+
|
70
|
-
def xpath_for
|
73
|
+
def xpath_for(string, options = {})
|
71
74
|
key = "#{string}#{options[:ns]}#{options[:prefix]}"
|
72
75
|
v = self.class[key]
|
73
76
|
return v if v
|
74
77
|
|
75
78
|
args = [
|
76
|
-
options[:prefix] ||
|
77
|
-
options[:visitor] || XPathVisitor.new
|
79
|
+
options[:prefix] || "//",
|
80
|
+
options[:visitor] || XPathVisitor.new,
|
78
81
|
]
|
79
82
|
self.class[key] = parse(string).map { |ast|
|
80
83
|
ast.to_xpath(*args)
|
@@ -82,7 +85,7 @@ module Nokogiri
|
|
82
85
|
end
|
83
86
|
|
84
87
|
# On CSS parser error, raise an exception
|
85
|
-
def on_error
|
88
|
+
def on_error(error_token_id, error_value, value_stack)
|
86
89
|
after = value_stack.compact.last
|
87
90
|
raise SyntaxError.new("unexpected '#{error_value}' after '#{after}'")
|
88
91
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Nokogiri
|
2
3
|
module CSS
|
3
4
|
class XPathVisitor # :nodoc:
|
@@ -51,7 +52,8 @@ module Nokogiri
|
|
51
52
|
when /^comment\(/
|
52
53
|
"comment()"
|
53
54
|
when /^has\(/
|
54
|
-
|
55
|
+
is_direct = node.value[1].value[0].nil? # e.g. "has(> a)", "has(~ a)", "has(+ a)"
|
56
|
+
".#{"//" if !is_direct}#{node.value[1].accept(self)}"
|
55
57
|
else
|
56
58
|
args = ['.'] + node.value[1..-1]
|
57
59
|
"#{node.value.first}#{args.join(', ')})"
|
data/lib/nokogiri/html.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The line below caused a problem on non-GAE rack environment.
|
3
|
+
# unless defined?(JRuby::Rack::VERSION) || defined?(AppEngine::ApiProxy)
|
4
|
+
#
|
5
|
+
# However, simply cutting defined?(JRuby::Rack::VERSION) off resulted in
|
6
|
+
# an unable-to-load-nokogiri problem. Thus, now, Nokogiri checks the presense
|
7
|
+
# of appengine-rack.jar in $LOAD_PATH. If Nokogiri is on GAE, Nokogiri
|
8
|
+
# should skip loading xml jars. This is because those are in WEB-INF/lib and
|
9
|
+
# already set in the classpath.
|
10
|
+
unless $LOAD_PATH.to_s.include?("appengine-rack")
|
11
|
+
require 'stringio'
|
12
|
+
require 'isorelax.jar'
|
13
|
+
require 'jing.jar'
|
14
|
+
require 'nekohtml.jar'
|
15
|
+
require 'nekodtd.jar'
|
16
|
+
require 'xercesImpl.jar'
|
17
|
+
require 'serializer.jar'
|
18
|
+
require 'xalan.jar'
|
19
|
+
require 'xml-apis.jar'
|
20
|
+
end
|
data/lib/nokogiri/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Nokogiri
|
2
3
|
# The version of Nokogiri you are using
|
3
|
-
VERSION = "1.
|
4
|
+
VERSION = "1.11.0.rc3"
|
4
5
|
|
5
6
|
class VersionInfo # :nodoc:
|
6
7
|
def jruby?
|
@@ -11,19 +12,30 @@ module Nokogiri
|
|
11
12
|
defined?(RUBY_ENGINE) ? RUBY_ENGINE : "mri"
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
-
|
15
|
+
def loaded_libxml_version
|
16
|
+
Gem::Version.new(LIBXML_LOADED_VERSION.
|
16
17
|
scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first.
|
17
18
|
collect(&:to_i).
|
18
|
-
join(".")
|
19
|
+
join("."))
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
-
|
22
|
+
def compiled_libxml_version
|
23
|
+
Gem::Version.new LIBXML_COMPILED_VERSION
|
24
|
+
end
|
25
|
+
|
26
|
+
def loaded_libxslt_version
|
27
|
+
Gem::Version.new(LIBXSLT_LOADED_VERSION.
|
28
|
+
scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first.
|
29
|
+
collect(&:to_i).
|
30
|
+
join("."))
|
31
|
+
end
|
32
|
+
|
33
|
+
def compiled_libxslt_version
|
34
|
+
Gem::Version.new LIBXSLT_COMPILED_VERSION
|
23
35
|
end
|
24
36
|
|
25
37
|
def libxml2?
|
26
|
-
defined?(
|
38
|
+
defined?(LIBXML_COMPILED_VERSION)
|
27
39
|
end
|
28
40
|
|
29
41
|
def libxml2_using_system?
|
@@ -35,47 +47,63 @@ module Nokogiri
|
|
35
47
|
end
|
36
48
|
|
37
49
|
def warnings
|
38
|
-
|
50
|
+
warnings = []
|
39
51
|
|
40
|
-
if
|
41
|
-
|
42
|
-
|
43
|
-
|
52
|
+
if libxml2?
|
53
|
+
if compiled_libxml_version != loaded_libxml_version
|
54
|
+
warnings << "Nokogiri was built against libxml version #{compiled_libxml_version}, but has dynamically loaded #{loaded_libxml_version}"
|
55
|
+
end
|
56
|
+
|
57
|
+
if compiled_libxslt_version != loaded_libxslt_version
|
58
|
+
warnings << "Nokogiri was built against libxslt version #{compiled_libxslt_version}, but has dynamically loaded #{loaded_libxslt_version}"
|
59
|
+
end
|
44
60
|
end
|
61
|
+
|
62
|
+
warnings
|
45
63
|
end
|
46
64
|
|
47
65
|
def to_hash
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
66
|
+
{}.tap do |vi|
|
67
|
+
vi["warnings"] = []
|
68
|
+
vi["nokogiri"] = Nokogiri::VERSION
|
69
|
+
vi["ruby"] = {}.tap do |ruby|
|
70
|
+
ruby["version"] = ::RUBY_VERSION
|
71
|
+
ruby["platform"] = ::RUBY_PLATFORM
|
72
|
+
ruby["gem_platform"] = ::Gem::Platform.local.to_s
|
73
|
+
ruby["description"] = ::RUBY_DESCRIPTION
|
74
|
+
ruby["engine"] = engine
|
75
|
+
ruby["jruby"] = jruby? if jruby?
|
76
|
+
end
|
57
77
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
78
|
+
if libxml2?
|
79
|
+
vi["libxml"] = {}.tap do |libxml|
|
80
|
+
if libxml2_using_packaged?
|
81
|
+
libxml["source"] = "packaged"
|
82
|
+
libxml["patches"] = NOKOGIRI_LIBXML2_PATCHES
|
83
|
+
else
|
84
|
+
libxml["source"] = "system"
|
85
|
+
end
|
86
|
+
libxml["compiled"] = compiled_libxml_version.to_s
|
87
|
+
libxml["loaded"] = loaded_libxml_version.to_s
|
88
|
+
end
|
89
|
+
|
90
|
+
vi["libxslt"] = {}.tap do |libxslt|
|
91
|
+
if libxml2_using_packaged?
|
92
|
+
libxslt["source"] = "packaged"
|
93
|
+
libxslt["patches"] = NOKOGIRI_LIBXSLT_PATCHES
|
94
|
+
else
|
95
|
+
libxslt["source"] = "system"
|
96
|
+
end
|
97
|
+
libxslt["compiled"] = compiled_libxslt_version.to_s
|
98
|
+
libxslt["loaded"] = loaded_libxslt_version.to_s
|
99
|
+
end
|
100
|
+
|
101
|
+
vi["warnings"] = warnings
|
102
|
+
elsif jruby?
|
103
|
+
vi["xerces"] = Nokogiri::XERCES_VERSION
|
104
|
+
vi["nekohtml"] = Nokogiri::NEKO_VERSION
|
69
105
|
end
|
70
|
-
hash_info["libxml"]["compiled"] = compiled_parser_version
|
71
|
-
hash_info["libxml"]["loaded"] = loaded_parser_version
|
72
|
-
hash_info["warnings"] = warnings
|
73
|
-
elsif jruby?
|
74
|
-
hash_info["xerces"] = Nokogiri::XERCES_VERSION
|
75
|
-
hash_info["nekohtml"] = Nokogiri::NEKO_VERSION
|
76
106
|
end
|
77
|
-
|
78
|
-
hash_info
|
79
107
|
end
|
80
108
|
|
81
109
|
def to_markdown
|
@@ -96,14 +124,27 @@ module Nokogiri
|
|
96
124
|
def self.instance; @@instance; end
|
97
125
|
end
|
98
126
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
VersionInfo.instance.libxml2?
|
127
|
+
def self.uses_libxml?(requirement = nil) # :nodoc:
|
128
|
+
return false unless VersionInfo.instance.libxml2?
|
129
|
+
return true unless requirement
|
130
|
+
return Gem::Requirement.new(requirement).satisfied_by?(VersionInfo.instance.loaded_libxml_version)
|
104
131
|
end
|
105
132
|
|
106
133
|
def self.jruby? # :nodoc:
|
107
134
|
VersionInfo.instance.jruby?
|
108
135
|
end
|
136
|
+
|
137
|
+
# Ensure constants used in this file are loaded - see #1896
|
138
|
+
if Nokogiri.jruby?
|
139
|
+
require "nokogiri/jruby/dependencies"
|
140
|
+
end
|
141
|
+
begin
|
142
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
143
|
+
require "nokogiri/#{$1}/nokogiri"
|
144
|
+
rescue LoadError
|
145
|
+
require "nokogiri/nokogiri"
|
146
|
+
end
|
147
|
+
|
148
|
+
# More complete version information about libxml
|
149
|
+
VERSION_INFO = VersionInfo.instance.to_hash
|
109
150
|
end
|
data/lib/nokogiri/xml.rb
CHANGED
data/lib/nokogiri/xml/attr.rb
CHANGED
data/lib/nokogiri/xml/builder.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Nokogiri
|
2
3
|
module XML
|
3
4
|
###
|
@@ -244,8 +245,8 @@ module Nokogiri
|
|
244
245
|
#
|
245
246
|
# For example:
|
246
247
|
#
|
247
|
-
# doc = Nokogiri::XML(
|
248
|
-
# Nokogiri::XML::Builder.with(doc.
|
248
|
+
# doc = Nokogiri::XML(File.read('somedoc.xml'))
|
249
|
+
# Nokogiri::XML::Builder.with(doc.at_css('some_tag')) do |xml|
|
249
250
|
# # ... Use normal builder methods here ...
|
250
251
|
# xml.awesome # add the "awesome" tag below "some_tag"
|
251
252
|
# end
|