nokogiri 1.5.11 → 1.6.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

data/CHANGELOG.rdoc CHANGED
@@ -1,23 +1,13 @@
1
- === 1.5.11 / 2013-12-14
1
+ === 1.6.0.rc1 / 2013-04-14
2
2
 
3
- * Bugfixes
4
-
5
- * (JRuby) Fix out of memory bug when certain invalid documents are parsed.
6
- * (JRuby) Fix regression of billion-laughs vulnerability. #586
7
-
8
- === 1.5.10 / 2013-06-07
9
-
10
- * Bugfixes
11
-
12
- * (JRuby) Fix "null document" error when parsing an empty IO in jruby 1.7.3. #883
13
- * (JRuby) Fix schema validation when XSD has DOCTYPE set to DTD. #861 (Thanks, Patrick Cheng!)
14
- * (MRI) Fix segfault when there is no default subelement for an HTML node. #917
15
-
16
-
17
- * Notes
3
+ * Features
18
4
 
19
- * Use rb_ary_entry instead of RARRAY_PTR (you know, for Rubinius). #877 (Thanks, Dirkjan Bussink!)
20
- * Fix TypeError when running tests. #900 (Thanks, Cédric Boutillier!)
5
+ * (MRI) Source code for libxml 2.8.0 and libxslt 1.2.26 is packaged
6
+ with the gem. These libraries are compiled at gem install time
7
+ unless the environment variable NOKOGIRI_USE_SYSTEM_LIBRARIES is
8
+ set. VERSION_INFO (also `nokogiri -v`) exposes whether libxml was
9
+ compiled from packaged source, or the system library was used.
10
+ * (Windows) libxml upgraded to 2.8.0
21
11
 
22
12
 
23
13
  === 1.5.9 / 2013-03-21
@@ -72,7 +62,7 @@
72
62
  * XML::Node#[]= stringifies values. #729 (Thanks, Ben Langfeld.)
73
63
  * bin/nokogiri will process a document from $stdin
74
64
  * bin/nokogiri -e will execute a program from the command line
75
- * (JRuby) bin/nokogiri --version will print the Xerces and NekoHTML versions.
65
+ * bin/nokogiri --version will print the Xerces and NekoHTML versions when ran with JRuby.
76
66
 
77
67
 
78
68
  * Bugfixes
data/Rakefile CHANGED
@@ -32,22 +32,23 @@ HOE = Hoe.spec 'nokogiri' do
32
32
 
33
33
  self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
34
34
 
35
- self.licenses = ['MIT']
36
-
37
35
  self.clean_globs += [
38
36
  'nokogiri.gemspec',
39
37
  'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
40
- 'lib/nokogiri/{1.8,1.9,2.0}',
38
+ 'lib/nokogiri/{1.9,2.0}',
41
39
  # GENERATED_PARSER,
42
40
  # GENERATED_TOKENIZER
43
41
  ]
44
42
 
43
+ self.extra_deps += [
44
+ ["mini_portile", "~> 0.5.0"],
45
+ ]
46
+
45
47
  self.extra_dev_deps += [
46
48
  ["hoe-bundler", ">= 1.1"],
47
49
  ["hoe-debugging", ">= 1.0.3"],
48
50
  ["hoe-gemspec", ">= 1.0"],
49
51
  ["hoe-git", ">= 1.4"],
50
- ["mini_portile", ">= 0.2.2"],
51
52
  ["minitest", "~> 2.2.2"],
52
53
  ["rake", ">= 0.9"],
53
54
  ["rake-compiler", "~> 0.8.0"],
@@ -60,7 +61,7 @@ HOE = Hoe.spec 'nokogiri' do
60
61
  else
61
62
  self.spec_extras = {
62
63
  :extensions => ["ext/nokogiri/extconf.rb"],
63
- :required_ruby_version => '>= 1.8.7'
64
+ :required_ruby_version => '>= 1.9.2'
64
65
  }
65
66
  end
66
67
 
@@ -108,6 +109,21 @@ else
108
109
 
109
110
  HOE.spec.files.reject! { |f| f =~ %r{\.(java|jar)$} }
110
111
 
112
+ windows_p = RbConfig::CONFIG['target_os'] == 'mingw32' || RbConfig::CONFIG['target_os'] =~ /mswin/
113
+
114
+ unless windows_p || java?
115
+ task gem_build_path do
116
+ add_file_to_gem "dependencies.yml"
117
+
118
+ dependencies = YAML.load_file("dependencies.yml")
119
+ %w[libxml2 libxslt].each do |lib|
120
+ version = dependencies[lib]
121
+ archive = File.join("ports", "archives", "#{lib}-#{version}.tar.gz")
122
+ add_file_to_gem archive
123
+ end
124
+ end
125
+ end
126
+
111
127
  Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
112
128
  ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
113
129
  ext.config_options << ENV['EXTOPTS']
@@ -196,7 +212,7 @@ end
196
212
 
197
213
  desc "build a windows gem without all the ceremony."
198
214
  task "gem:windows" => "gem" do
199
- cross_rubies = ["1.8.7-p358", "1.9.3-p194", "2.0.0-p0"]
215
+ cross_rubies = ["1.9.3-p194", "2.0.0-p0"]
200
216
  ruby_cc_version = cross_rubies.collect { |_| _.split("-").first }.join(":") # e.g., "1.8.7:1.9.2"
201
217
  rake_compiler_config_path = "#{ENV['HOME']}/.rake-compiler/config.yml"
202
218
 
data/build_all CHANGED
@@ -8,7 +8,7 @@
8
8
  # here's what I recommend for building all the gems:
9
9
  #
10
10
  # 1. set up a vagrant VM guest running ubuntu lucid 32-bit.
11
- # 2. install rvm, and install 1.8.7, 1.9.3 and jruby.
11
+ # 2. install rvm, and install 1.9.3, 2.0.0 and jruby.
12
12
  # 3. `sudo apt-get install mingw32`
13
13
  #
14
14
  # as you build, you may run into these problems:
data/dependencies.yml ADDED
@@ -0,0 +1,4 @@
1
+ libxml2: "2.8.0"
2
+ libxslt: "1.1.26"
3
+ zlib: "1.2.7"
4
+ libiconv: "1.13.1"
@@ -18,7 +18,9 @@ end
18
18
  $CFLAGS << " #{ENV["CFLAGS"]}"
19
19
  $LIBS << " #{ENV["LIBS"]}"
20
20
 
21
- if RbConfig::CONFIG['target_os'] == 'mingw32' || RbConfig::CONFIG['target_os'] =~ /mswin/
21
+ windows_p = RbConfig::CONFIG['target_os'] == 'mingw32' || RbConfig::CONFIG['target_os'] =~ /mswin/
22
+
23
+ if windows_p
22
24
  $CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
23
25
  elsif RbConfig::CONFIG['target_os'] =~ /solaris/
24
26
  $CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
@@ -36,59 +38,107 @@ if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
36
38
  $CFLAGS << " -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
37
39
  end
38
40
 
39
- if RbConfig::CONFIG['target_os'] =~ /mswin/
40
- lib_prefix = 'lib'
41
-
42
- # There's no default include/lib dir on Windows. Let's just add the Ruby ones
43
- # and resort on the search path specified by INCLUDE and LIB environment
44
- # variables
41
+ if windows_p
42
+ # I'm cross compiling!
45
43
  HEADER_DIRS = [INCLUDEDIR]
46
44
  LIB_DIRS = [LIBDIR]
47
45
  XML2_HEADER_DIRS = [File.join(INCLUDEDIR, "libxml2"), INCLUDEDIR]
48
46
 
49
47
  else
50
- lib_prefix = ''
51
-
52
- HEADER_DIRS = [
53
- # First search /opt/local for macports
54
- '/opt/local/include',
55
-
56
- # Then search /usr/local for people that installed from source
57
- '/usr/local/include',
58
-
59
- # Check the ruby install locations
60
- INCLUDEDIR,
61
-
62
- # Finally fall back to /usr
63
- '/usr/include',
64
- '/usr/include/libxml2',
65
- ]
66
-
67
- LIB_DIRS = [
68
- # First search /opt/local for macports
69
- '/opt/local/lib',
70
-
71
- # Then search /usr/local for people that installed from source
72
- '/usr/local/lib',
73
-
74
- # Check the ruby install locations
75
- LIBDIR,
76
-
77
- # Finally fall back to /usr
78
- '/usr/lib',
79
- ]
80
-
81
- XML2_HEADER_DIRS = [
82
- '/opt/local/include/libxml2',
83
- '/usr/local/include/libxml2',
84
- File.join(INCLUDEDIR, "libxml2")
85
- ] + HEADER_DIRS
86
-
87
- # If the user has homebrew installed, use the libxml2 inside homebrew
88
- brew_prefix = `brew --prefix libxml2 2> /dev/null`.chomp
89
- unless brew_prefix.empty?
90
- LIB_DIRS.unshift File.join(brew_prefix, 'lib')
91
- XML2_HEADER_DIRS.unshift File.join(brew_prefix, 'include/libxml2')
48
+ if ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES']
49
+ HEADER_DIRS = [
50
+ # First search /opt/local for macports
51
+ '/opt/local/include',
52
+
53
+ # Then search /usr/local for people that installed from source
54
+ '/usr/local/include',
55
+
56
+ # Check the ruby install locations
57
+ INCLUDEDIR,
58
+
59
+ # Finally fall back to /usr
60
+ '/usr/include',
61
+ '/usr/include/libxml2',
62
+ ]
63
+
64
+ LIB_DIRS = [
65
+ # First search /opt/local for macports
66
+ '/opt/local/lib',
67
+
68
+ # Then search /usr/local for people that installed from source
69
+ '/usr/local/lib',
70
+
71
+ # Check the ruby install locations
72
+ LIBDIR,
73
+
74
+ # Finally fall back to /usr
75
+ '/usr/lib',
76
+ ]
77
+
78
+ XML2_HEADER_DIRS = [
79
+ '/opt/local/include/libxml2',
80
+ '/usr/local/include/libxml2',
81
+ File.join(INCLUDEDIR, "libxml2")
82
+ ] + HEADER_DIRS
83
+
84
+ # If the user has homebrew installed, use the libxml2 inside homebrew
85
+ brew_prefix = `brew --prefix libxml2 2> /dev/null`.chomp
86
+ unless brew_prefix.empty?
87
+ LIB_DIRS.unshift File.join(brew_prefix, 'lib')
88
+ XML2_HEADER_DIRS.unshift File.join(brew_prefix, 'include/libxml2')
89
+ end
90
+
91
+ else
92
+ require 'mini_portile'
93
+ require 'yaml'
94
+
95
+ common_recipe = lambda do |recipe|
96
+ recipe.target = File.join(ROOT, "ports")
97
+ recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
98
+
99
+ checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
100
+ unless File.exist?(checkpoint)
101
+ recipe.cook
102
+ FileUtils.touch checkpoint
103
+ end
104
+ recipe.activate
105
+ end
106
+
107
+ dependencies = YAML.load_file(File.join(ROOT, "dependencies.yml"))
108
+
109
+ libxml2_recipe = MiniPortile.new("libxml2", dependencies["libxml2"]).tap do |recipe|
110
+ recipe.configure_options = [
111
+ "--enable-shared",
112
+ "--disable-static",
113
+ "--without-python",
114
+ "--without-readline",
115
+ "--with-c14n",
116
+ "--with-debug",
117
+ "--with-threads"
118
+ ]
119
+ common_recipe.call recipe
120
+ end
121
+
122
+ libxslt_recipe = MiniPortile.new("libxslt", dependencies["libxslt"]).tap do |recipe|
123
+ recipe.configure_options = [
124
+ "--enable-shared",
125
+ "--disable-static",
126
+ "--without-python",
127
+ "--without-crypto",
128
+ "--with-debug",
129
+ "--with-libxml-prefix=#{libxml2_recipe.path}"
130
+ ]
131
+ common_recipe.call recipe
132
+ end
133
+
134
+ $LDFLAGS << " -Wl,-rpath,#{libxml2_recipe.path}/lib"
135
+ $LDFLAGS << " -Wl,-rpath,#{libxslt_recipe.path}/lib"
136
+
137
+ $CFLAGS << " -DNOKOGIRI_USE_PACKAGED_LIBRARIES -DNOKOGIRI_LIBXML2_PATH='\"#{libxml2_recipe.path}\"' -DNOKOGIRI_LIBXSLT_PATH='\"#{libxslt_recipe.path}\"'"
138
+
139
+ HEADER_DIRS = [libxml2_recipe, libxslt_recipe].map { |_| File.join(_.path, "include") }
140
+ LIB_DIRS = [libxml2_recipe, libxslt_recipe].map { |_| File.join(_.path, "lib") }
141
+ XML2_HEADER_DIRS = HEADER_DIRS + [File.join(libxml2_recipe.path, "include", "libxml2")]
92
142
  end
93
143
  end
94
144
 
@@ -117,9 +167,9 @@ asplode "libxml2" unless find_header('libxml/parser.h')
117
167
  asplode "libxslt" unless find_header('libxslt/xslt.h')
118
168
  asplode "libexslt" unless find_header('libexslt/exslt.h')
119
169
  asplode "libiconv" unless have_iconv?
120
- asplode "libxml2" unless find_library("#{lib_prefix}xml2", 'xmlParseDoc')
121
- asplode "libxslt" unless find_library("#{lib_prefix}xslt", 'xsltParseStylesheetDoc')
122
- asplode "libexslt" unless find_library("#{lib_prefix}exslt", 'exsltFuncRegister')
170
+ asplode "libxml2" unless find_library("xml2", 'xmlParseDoc')
171
+ asplode "libxslt" unless find_library("xslt", 'xsltParseStylesheetDoc')
172
+ asplode "libexslt" unless find_library("exslt", 'exsltFuncRegister')
123
173
 
124
174
  unless have_func('xmlHasFeature')
125
175
  abort "-----\nThe function 'xmlHasFeature' is missing from your installation of libxml2. Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well. To get around this problem, please upgrade your installation of libxml2.
@@ -141,4 +191,5 @@ if ENV['CPUPROFILE']
141
191
  end
142
192
 
143
193
  create_makefile('nokogiri/nokogiri')
194
+
144
195
  # :startdoc:
@@ -86,10 +86,7 @@ static VALUE default_sub_element(VALUE self)
86
86
  htmlElemDesc * description;
87
87
  Data_Get_Struct(self, htmlElemDesc, description);
88
88
 
89
- if (description->defaultsubelt)
90
- return NOKOGIRI_STR_NEW2(description->defaultsubelt);
91
-
92
- return Qnil;
89
+ return NOKOGIRI_STR_NEW2(description->defaultsubelt);
93
90
  }
94
91
 
95
92
  /*
@@ -90,6 +90,16 @@ void Init_nokogiri()
90
90
  NOKOGIRI_STR_NEW2(xmlParserVersion)
91
91
  );
92
92
 
93
+ #ifdef NOKOGIRI_USE_PACKAGED_LIBRARIES
94
+ rb_const_set(mNokogiri, rb_intern("NOKOGIRI_USE_PACKAGED_LIBRARIES"), Qtrue);
95
+ rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXML2_PATH"), NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATH));
96
+ rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATH"), NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATH));
97
+ #else
98
+ rb_const_set(mNokogiri, rb_intern("NOKOGIRI_USE_PACKAGED_LIBRARIES"), Qfalse);
99
+ rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXML2_PATH"), Qnil);
100
+ rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATH"), Qnil);
101
+ #endif
102
+
93
103
  #ifdef LIBXML_ICONV_ENABLED
94
104
  rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qtrue);
95
105
  #else
@@ -209,7 +209,7 @@ static void * initFunc(xsltTransformContextPtr ctxt, const xmlChar *uri)
209
209
  int i;
210
210
 
211
211
  for(i = 0; i < RARRAY_LEN(methods); i++) {
212
- VALUE method_name = rb_obj_as_string(rb_ary_entry(methods, i));
212
+ VALUE method_name = rb_obj_as_string(RARRAY_PTR(methods)[i]);
213
213
  xsltRegisterExtFunction(ctxt,
214
214
  (unsigned char *)StringValuePtr(method_name), uri, method_caller);
215
215
  }
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.5.11'
3
+ VERSION = '1.6.0.rc1'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -12,7 +12,7 @@ module Nokogiri
12
12
  end
13
13
 
14
14
  def loaded_parser_version
15
- LIBXML_PARSER_VERSION.scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first.collect{ |j|
15
+ LIBXML_PARSER_VERSION.scan(/^(.*)(..)(..)$/).first.collect{ |j|
16
16
  j.to_i
17
17
  }.join(".")
18
18
  end
@@ -25,6 +25,14 @@ module Nokogiri
25
25
  defined?(LIBXML_VERSION)
26
26
  end
27
27
 
28
+ def libxml2_using_system?
29
+ ! libxml2_using_packaged?
30
+ end
31
+
32
+ def libxml2_using_packaged?
33
+ NOKOGIRI_USE_PACKAGED_LIBRARIES
34
+ end
35
+
28
36
  def warnings
29
37
  return [] unless libxml2?
30
38
 
@@ -49,6 +57,13 @@ module Nokogiri
49
57
  if libxml2?
50
58
  hash_info['libxml'] = {}
51
59
  hash_info['libxml']['binding'] = 'extension'
60
+ if libxml2_using_packaged?
61
+ hash_info['libxml']['source'] = "packaged"
62
+ hash_info['libxml']['libxml2_path'] = NOKOGIRI_LIBXML2_PATH
63
+ hash_info['libxml']['libxslt_path'] = NOKOGIRI_LIBXSLT_PATH
64
+ else
65
+ hash_info['libxml']['source'] = "system"
66
+ end
52
67
  hash_info['libxml']['compiled'] = compiled_parser_version
53
68
  hash_info['libxml']['loaded'] = loaded_parser_version
54
69
  hash_info['warnings'] = warnings
@@ -45,13 +45,12 @@ module Nokogiri
45
45
  # Give the options to the user
46
46
  yield options if block_given?
47
47
 
48
- return new if empty_doc?(string_or_io)
49
-
50
48
  doc = if string_or_io.respond_to?(:read)
51
49
  url ||= string_or_io.respond_to?(:path) ? string_or_io.path : nil
52
50
  read_io(string_or_io, url, encoding, options.to_i)
53
51
  else
54
52
  # read_memory pukes on empty docs
53
+ return new if string_or_io.nil? or string_or_io.empty?
55
54
  read_memory(string_or_io, url, encoding, options.to_i)
56
55
  end
57
56
 
@@ -261,12 +260,6 @@ module Nokogiri
261
260
  end
262
261
 
263
262
  private
264
- def self.empty_doc? string_or_io
265
- string_or_io.nil? ||
266
- (string_or_io.respond_to?(:empty?) && string_or_io.empty?) ||
267
- (string_or_io.respond_to?(:eof?) && string_or_io.eof?)
268
- end
269
-
270
263
  def implied_xpath_context
271
264
  "/"
272
265
  end
@@ -917,23 +917,18 @@ module Nokogiri
917
917
  end
918
918
 
919
919
  def coerce data # :nodoc:
920
- case data
921
- when XML::NodeSet
922
- return data
923
- when XML::DocumentFragment
924
- return data.children
925
- when String
926
- return fragment(data).children
927
- when Document, XML::Attr
928
- # unacceptable
929
- when XML::Node
930
- return data
931
- end
920
+ return data if data.is_a?(XML::NodeSet)
921
+ return data.children if data.is_a?(XML::DocumentFragment)
922
+ return fragment(data).children if data.is_a?(String)
932
923
 
933
- raise ArgumentError, <<-EOERR
924
+ if data.is_a?(Document) || data.is_a?(XML::Attr) || !data.is_a?(XML::Node)
925
+ raise ArgumentError, <<-EOERR
934
926
  Requires a Node, NodeSet or String argument, and cannot accept a #{data.class}.
935
927
  (You probably want to select a node from the Document with at() or search(), or create a new Node via Node.new().)
936
- EOERR
928
+ EOERR
929
+ end
930
+
931
+ data
937
932
  end
938
933
 
939
934
  def implied_xpath_context