nokogiri 1.10.8-x64-mingw32 → 1.11.0.rc3-x64-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.

Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -22
  3. data/ext/nokogiri/extconf.rb +50 -37
  4. data/ext/nokogiri/nokogiri.c +12 -6
  5. data/ext/nokogiri/nokogiri.h +13 -0
  6. data/ext/nokogiri/xml_document.c +16 -2
  7. data/ext/nokogiri/xml_io.c +8 -6
  8. data/ext/nokogiri/xml_node.c +20 -0
  9. data/ext/nokogiri/xml_reader.c +6 -17
  10. data/ext/nokogiri/xml_schema.c +29 -0
  11. data/ext/nokogiri/xslt_stylesheet.c +0 -4
  12. data/lib/nokogiri.rb +3 -20
  13. data/lib/nokogiri/2.4/nokogiri.so +0 -0
  14. data/lib/nokogiri/2.5/nokogiri.so +0 -0
  15. data/lib/nokogiri/2.6/nokogiri.so +0 -0
  16. data/lib/nokogiri/{2.3 → 2.7}/nokogiri.so +0 -0
  17. data/lib/nokogiri/css.rb +1 -0
  18. data/lib/nokogiri/css/node.rb +1 -0
  19. data/lib/nokogiri/css/parser.rb +61 -60
  20. data/lib/nokogiri/css/parser_extras.rb +39 -36
  21. data/lib/nokogiri/css/syntax_error.rb +1 -0
  22. data/lib/nokogiri/css/tokenizer.rb +1 -0
  23. data/lib/nokogiri/css/xpath_visitor.rb +3 -1
  24. data/lib/nokogiri/decorators/slop.rb +1 -0
  25. data/lib/nokogiri/html.rb +1 -0
  26. data/lib/nokogiri/html/builder.rb +1 -0
  27. data/lib/nokogiri/html/document.rb +1 -0
  28. data/lib/nokogiri/html/document_fragment.rb +1 -0
  29. data/lib/nokogiri/html/element_description.rb +1 -0
  30. data/lib/nokogiri/html/element_description_defaults.rb +1 -0
  31. data/lib/nokogiri/html/entity_lookup.rb +1 -0
  32. data/lib/nokogiri/html/sax/parser.rb +1 -0
  33. data/lib/nokogiri/html/sax/parser_context.rb +1 -0
  34. data/lib/nokogiri/html/sax/push_parser.rb +1 -0
  35. data/lib/nokogiri/jruby/dependencies.rb +20 -0
  36. data/lib/nokogiri/syntax_error.rb +1 -0
  37. data/lib/nokogiri/version.rb +86 -45
  38. data/lib/nokogiri/xml.rb +1 -0
  39. data/lib/nokogiri/xml/attr.rb +1 -0
  40. data/lib/nokogiri/xml/attribute_decl.rb +1 -0
  41. data/lib/nokogiri/xml/builder.rb +3 -2
  42. data/lib/nokogiri/xml/cdata.rb +1 -0
  43. data/lib/nokogiri/xml/character_data.rb +1 -0
  44. data/lib/nokogiri/xml/document.rb +3 -8
  45. data/lib/nokogiri/xml/document_fragment.rb +1 -0
  46. data/lib/nokogiri/xml/dtd.rb +1 -0
  47. data/lib/nokogiri/xml/element_content.rb +1 -0
  48. data/lib/nokogiri/xml/element_decl.rb +1 -0
  49. data/lib/nokogiri/xml/entity_decl.rb +1 -0
  50. data/lib/nokogiri/xml/entity_reference.rb +1 -0
  51. data/lib/nokogiri/xml/namespace.rb +1 -0
  52. data/lib/nokogiri/xml/node.rb +539 -224
  53. data/lib/nokogiri/xml/node/save_options.rb +1 -0
  54. data/lib/nokogiri/xml/node_set.rb +1 -0
  55. data/lib/nokogiri/xml/notation.rb +1 -0
  56. data/lib/nokogiri/xml/parse_options.rb +4 -3
  57. data/lib/nokogiri/xml/pp.rb +1 -0
  58. data/lib/nokogiri/xml/pp/character_data.rb +1 -0
  59. data/lib/nokogiri/xml/pp/node.rb +1 -0
  60. data/lib/nokogiri/xml/processing_instruction.rb +1 -0
  61. data/lib/nokogiri/xml/reader.rb +7 -3
  62. data/lib/nokogiri/xml/relax_ng.rb +1 -0
  63. data/lib/nokogiri/xml/sax.rb +1 -0
  64. data/lib/nokogiri/xml/sax/document.rb +1 -0
  65. data/lib/nokogiri/xml/sax/parser.rb +1 -0
  66. data/lib/nokogiri/xml/sax/parser_context.rb +1 -0
  67. data/lib/nokogiri/xml/sax/push_parser.rb +1 -0
  68. data/lib/nokogiri/xml/schema.rb +1 -0
  69. data/lib/nokogiri/xml/searchable.rb +22 -15
  70. data/lib/nokogiri/xml/syntax_error.rb +1 -0
  71. data/lib/nokogiri/xml/text.rb +1 -0
  72. data/lib/nokogiri/xml/xpath.rb +1 -0
  73. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -0
  74. data/lib/nokogiri/xml/xpath_context.rb +1 -0
  75. data/lib/nokogiri/xslt.rb +1 -0
  76. data/lib/nokogiri/xslt/stylesheet.rb +1 -0
  77. data/lib/xsd/xmlparser/nokogiri.rb +1 -0
  78. metadata +46 -40
@@ -1,63 +1,66 @@
1
- require 'thread'
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
- @cache_on = true
7
- @cache = {}
8
- @mutex = Mutex.new
7
+ CACHE_SWITCH_NAME = :nokogiri_css_parser_cache_is_off
8
+
9
+ @cache = {}
10
+ @mutex = Mutex.new
9
11
 
10
12
  class << self
11
- # Turn on CSS parse caching
12
- attr_accessor :cache_on
13
- alias :cache_on? :cache_on
14
- alias :set_cache :cache_on=
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 [] string
18
- return unless @cache_on
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 []= string, value
24
- return value unless @cache_on
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 { @cache = {} }
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 &block
35
- tmp = @cache_on
36
- @cache_on = false
47
+ def without_cache(&block)
48
+ original_cache_setting = cache_on?
49
+ set_cache false
37
50
  block.call
38
- @cache_on = tmp
39
- end
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 namespaces = {}
55
- @tokenizer = Tokenizer.new
57
+ def initialize(namespaces = {})
58
+ @tokenizer = Tokenizer.new
56
59
  @namespaces = namespaces
57
60
  super()
58
61
  end
59
62
 
60
- def parse string
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 string, options={}
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 error_token_id, error_value, value_stack
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
  require 'nokogiri/syntax_error'
2
3
  module Nokogiri
3
4
  module CSS
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #--
2
3
  # DO NOT MODIFY!!!!
3
4
  # This file is automatically generated by rex 1.0.7
@@ -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
- ".//#{node.value[1].accept(self)}"
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(', ')})"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module Decorators
3
4
  ###
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'nokogiri/html/entity_lookup'
2
3
  require 'nokogiri/html/document'
3
4
  require 'nokogiri/html/document_fragment'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  ###
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  class Document < Nokogiri::XML::Document
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  class DocumentFragment < Nokogiri::XML::DocumentFragment
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  class ElementDescription
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  class ElementDescription
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  class EntityDescription < Struct.new(:value, :name, :description); end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  ###
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  module SAX
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module HTML
3
4
  module SAX
@@ -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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  class SyntaxError < ::StandardError
3
4
  end
@@ -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.10.8"
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 loaded_parser_version
15
- LIBXML_PARSER_VERSION.
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 compiled_parser_version
22
- LIBXML_VERSION
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?(LIBXML_VERSION)
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
- return [] unless libxml2?
50
+ warnings = []
39
51
 
40
- if compiled_parser_version != loaded_parser_version
41
- ["Nokogiri was built against LibXML version #{compiled_parser_version}, but has dynamically loaded #{loaded_parser_version}"]
42
- else
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
- hash_info = {}
49
- hash_info["warnings"] = []
50
- hash_info["nokogiri"] = Nokogiri::VERSION
51
- hash_info["ruby"] = {}
52
- hash_info["ruby"]["version"] = ::RUBY_VERSION
53
- hash_info["ruby"]["platform"] = ::RUBY_PLATFORM
54
- hash_info["ruby"]["description"] = ::RUBY_DESCRIPTION
55
- hash_info["ruby"]["engine"] = engine
56
- hash_info["ruby"]["jruby"] = jruby? if jruby?
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
- if libxml2?
59
- hash_info["libxml"] = {}
60
- hash_info["libxml"]["binding"] = "extension"
61
- if libxml2_using_packaged?
62
- hash_info["libxml"]["source"] = "packaged"
63
- hash_info["libxml"]["libxml2_path"] = NOKOGIRI_LIBXML2_PATH
64
- hash_info["libxml"]["libxslt_path"] = NOKOGIRI_LIBXSLT_PATH
65
- hash_info["libxml"]["libxml2_patches"] = NOKOGIRI_LIBXML2_PATCHES
66
- hash_info["libxml"]["libxslt_patches"] = NOKOGIRI_LIBXSLT_PATCHES
67
- else
68
- hash_info["libxml"]["source"] = "system"
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
- # More complete version information about libxml
100
- VERSION_INFO = VersionInfo.instance.to_hash
101
-
102
- def self.uses_libxml? # :nodoc:
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'nokogiri/xml/pp'
2
3
  require 'nokogiri/xml/parse_options'
3
4
  require 'nokogiri/xml/sax'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module XML
3
4
  class Attr < Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module XML
3
4
  ###
@@ -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(open('somedoc.xml'))
248
- # Nokogiri::XML::Builder.with(doc.at('some_tag')) do |xml|
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