nokogiri 1.5.6.rc1 → 1.5.6.rc2

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.

@@ -6,6 +6,9 @@
6
6
 
7
7
  * JRuby で '#' で始まる文字列を名前とする EntityReference を作ろうとすると INVALID_CHARACTER_ERR という例外がはっせいする。 #719
8
8
  * JRuby では Nodeのサブクラスのnamespaceを正しく文字列に変換しない。 #715
9
+ * Nokogiri now detects XSLT transform errors. #731 (Thanks, Justin Fitzsimmons!)
10
+ * Raise an ArgumentError if an invalid encoding is passed to the SAX parser. #756 (Thanks, Bradley Schaefer!)
11
+ * JRuby Node#content now renders newlines properly. #737 (Thanks, Piotr Szmielew!)
9
12
 
10
13
 
11
14
  == 1.5.5 / 2012年6月24日
@@ -6,6 +6,9 @@
6
6
 
7
7
  * JRuby raises INVALID_CHARACTER_ERR exception when EntityReference name starts with '#'. #719
8
8
  * JRuby doesn't coerce namespaces out of strings on a direct subclass of Node. #715
9
+ * Nokogiri now detects XSLT transform errors. #731 (Thanks, Justin Fitzsimmons!)
10
+ * Raise an ArgumentError if an invalid encoding is passed to the SAX parser. #756 (Thanks, Bradley Schaefer!)
11
+ * JRuby Node#content now renders newlines properly. #737 (Thanks, Piotr Szmielew!)
9
12
 
10
13
 
11
14
  == 1.5.5 / 2012-06-24
@@ -43,8 +43,13 @@ ext/java/nokogiri/XmlSyntaxError.java
43
43
  ext/java/nokogiri/XmlText.java
44
44
  ext/java/nokogiri/XmlXpathContext.java
45
45
  ext/java/nokogiri/XsltStylesheet.java
46
+ ext/java/nokogiri/internals/ClosedStreamException.java
46
47
  ext/java/nokogiri/internals/HtmlDomParserContext.java
48
+ ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java
47
49
  ext/java/nokogiri/internals/NokogiriDocumentCache.java
50
+ ext/java/nokogiri/internals/NokogiriDomParser.java
51
+ ext/java/nokogiri/internals/NokogiriEncodingReaderWrapper.java
52
+ ext/java/nokogiri/internals/NokogiriEntityResolver.java
48
53
  ext/java/nokogiri/internals/NokogiriErrorHandler.java
49
54
  ext/java/nokogiri/internals/NokogiriHandler.java
50
55
  ext/java/nokogiri/internals/NokogiriHelpers.java
@@ -62,7 +67,6 @@ ext/java/nokogiri/internals/ReaderNode.java
62
67
  ext/java/nokogiri/internals/SaveContextVisitor.java
63
68
  ext/java/nokogiri/internals/SchemaErrorHandler.java
64
69
  ext/java/nokogiri/internals/XmlDeclHandler.java
65
- ext/java/nokogiri/internals/XmlDomParser.java
66
70
  ext/java/nokogiri/internals/XmlDomParserContext.java
67
71
  ext/java/nokogiri/internals/XmlSaxParser.java
68
72
  ext/java/nokogiri/internals/XsltExtensionFunction.java
@@ -230,13 +234,13 @@ test/files/snuggles.xml
230
234
  test/files/staff.dtd
231
235
  test/files/staff.xml
232
236
  test/files/staff.xslt
237
+ test/files/test_document_url/bar.xml
238
+ test/files/test_document_url/document.dtd
239
+ test/files/test_document_url/document.xml
233
240
  test/files/tlm.html
234
241
  test/files/to_be_xincluded.xml
235
242
  test/files/valid_bar.xml
236
243
  test/files/xinclude.xml
237
- test/files/test_document_url/bar.xml
238
- test/files/test_document_url/document.dtd
239
- test/files/test_document_url/document.xml
240
244
  test/helper.rb
241
245
  test/html/sax/test_parser.rb
242
246
  test/html/sax/test_parser_context.rb
@@ -1,4 +1,4 @@
1
- = Nokogiri (鋸)
1
+ = Nokogiri (鋸) {<img src="https://secure.travis-ci.org/sparklemotion/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/nokogiri] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/sparklemotion/nokogiri]
2
2
 
3
3
  * http://nokogiri.org/
4
4
  * http://github.com/sparklemotion/nokogiri/wikis
@@ -1,4 +1,4 @@
1
- = Nokogiri {<img src="https://secure.travis-ci.org/sparklemotion/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/nokogiri]
1
+ = Nokogiri {<img src="https://secure.travis-ci.org/sparklemotion/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/nokogiri] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/sparklemotion/nokogiri]
2
2
 
3
3
  * http://nokogiri.org
4
4
  * http://github.com/sparklemotion/nokogiri/wikis
data/ROADMAP.md CHANGED
@@ -69,6 +69,9 @@
69
69
  * we should standardize on a hash of options for these and other calls
70
70
  * what should NodeSet#xpath return?
71
71
  * https://github.com/sparklemotion/nokogiri/issues/656
72
+ * also, clean up or unify the implementations of #xpath-and-friends in Node and NodeSet
73
+ * implementations are very similar, but no shared code :(
74
+ * decorate nodes in a consistent manner
72
75
 
73
76
  ## Encoding
74
77
 
data/Rakefile CHANGED
@@ -46,14 +46,10 @@ HOE = Hoe.spec 'nokogiri' do
46
46
  ["mini_portile", ">= 0.2.2"],
47
47
  ["minitest", "~> 2.2.2"],
48
48
  ["rake", ">= 0.9"],
49
- ["rake-compiler", "= 0.8.0"]
49
+ ["rake-compiler", "= 0.8.0"],
50
+ ["racc", ">= 1.4.6"],
51
+ ["rexical", ">= 1.0.5"]
50
52
  ]
51
- if ! java?
52
- self.extra_dev_deps += [
53
- ["racc", ">= 1.4.6"],
54
- ["rexical", ">= 1.0.5"]
55
- ]
56
- end
57
53
 
58
54
  if java?
59
55
  self.spec_extras = { :platform => 'java' }
@@ -118,6 +114,20 @@ desc "Generate css/parser.rb and css/tokenizer.rex"
118
114
  task 'generate' => [GENERATED_PARSER, GENERATED_TOKENIZER]
119
115
  task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
120
116
 
117
+ # This is a big hack to make sure that the racc and rexical
118
+ # dependencies in the Gemfile are constrainted to ruby platforms
119
+ # (i.e. MRI and Rubinius). There's no way to do that through hoe,
120
+ # and any solution will require changing hoe and hoe-bundler.
121
+ old_gemfile_task = Rake::Task['bundler:gemfile']
122
+ task 'bundler:gemfile' do
123
+ old_gemfile_task.invoke
124
+
125
+ lines = File.open('Gemfile', 'r') { |f| f.readlines }.map do |line|
126
+ line =~ /racc|rexical/ ? "#{line.strip}, :platform => :ruby" : line
127
+ end
128
+ File.open('Gemfile', 'w') { |f| lines.each { |line| f.puts line } }
129
+ end
130
+
121
131
  file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
122
132
  racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
123
133
  racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
@@ -149,9 +159,18 @@ task :java_debug do
149
159
  ENV['JAVA_OPTS'] = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y' if java? && ENV['JAVA_DEBUG']
150
160
  end
151
161
 
162
+ if java?
163
+ task :test_18 => :test
164
+ task :test_19 do
165
+ ENV['JRUBY_OPTS'] = "--1.9"
166
+ Rake::Task["test"].invoke
167
+ end
168
+ end
169
+
152
170
  Rake::Task[:test].prerequisites << :compile
153
171
  Rake::Task[:test].prerequisites << :java_debug
154
172
  Rake::Task[:test].prerequisites << :check_extra_deps unless java?
173
+
155
174
  if Hoe.plugins.include?(:debugging)
156
175
  ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
157
176
  Rake::Task["test:#{task_name}"].prerequisites << :compile
data/build_all CHANGED
@@ -2,26 +2,32 @@
2
2
  #
3
3
  # script to build gems for all relevant platforms:
4
4
  # - MRI et al (standard gem)
5
- # - windows (x86-mingw32 and x86-msin32-60)
5
+ # - windows (x86-mingw32 and x86-mswin32-60)
6
6
  # - jruby
7
7
  #
8
- # prerequisite is the mingw32 packages.
9
- # on ubuntu, `sudo apt-get install mingw32`
10
- # for others, read up at https://github.com/luislavena/rake-compiler
8
+ # here's what I recommend for building all the gems:
11
9
  #
12
- # on ubuntus 11 and later, you may have issues with building
13
- # rake-compiler's rubies against openssl v2. Just comment the lines
14
- # out from ossl_ssl.c and you'll be fine.
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.
12
+ # 3. `sudo apt-get install mingw32`
15
13
  #
16
- # you may have issues with Pathname conversion to String in bundler. Add this to the offending bundler file:
14
+ # as you build, you may run into these problems:
17
15
  #
18
- # class Pathname
19
- # def to_str
20
- # to_s
21
- # end
22
- # end
16
+ # - on ubuntus 11 and later, you may have issues with building
17
+ # rake-compiler's rubies against openssl v2. Just comment the lines
18
+ # out from ossl_ssl.c and you'll be fine.
23
19
  #
24
- # you may also have to remove some of the symbol checks in extconf.rb ... crazy.
20
+ # - you may have issues with Pathname conversion to String in
21
+ # bundler. Add this to the offending bundler file:
22
+ #
23
+ # class Pathname
24
+ # def to_str
25
+ # to_s
26
+ # end
27
+ # end
28
+ #
29
+ # - you may also have to hack rubygems.rb to eliminate a reference to
30
+ # RUBY_ENGINE
25
31
  #
26
32
 
27
33
  HOST=
@@ -53,16 +59,23 @@ rm -rf gems
53
59
  mkdir -p gems
54
60
 
55
61
  # windows
56
- # rvm_use 1.8.7
57
- # if [[ ! -a /home/mike/.rake-compiler/ruby/ruby-1.8.7-p330/lib/ruby/1.8.7/x86_64-linux/rbconfig.rb ]] ; then
58
- # bundle exec rake-compiler cross-ruby VERSION=1.8.7-p330
59
- # fi
60
- # if [[ ! -a /home/mike/.rake-compiler/ruby/ruby-1.9.2-p136/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb ]] ; then
61
- # bundle exec rake-compiler cross-ruby VERSION=1.9.2-p136
62
- # fi
63
- # bundle exec rake cross
64
- # bundle exec rake gem:windows
65
- # cp -v pkg/nokogiri*x86-{mingw32,mswin32}*.gem gems
62
+ platform=$(uname -i)
63
+ if [[ $platform =~ "64" ]] ; then
64
+ echo ""
65
+ echo "ERROR: You need to build the windows gem on a 32-bit machine!"
66
+ echo ""
67
+ exit 1
68
+ fi
69
+ rvm_use 1.8.7
70
+ if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-1.8.7-p330/lib/ruby/1.8.7/x86_64-linux/rbconfig.rb ]] ; then
71
+ bundle exec rake-compiler cross-ruby VERSION=1.8.7-p330
72
+ fi
73
+ if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-1.9.2-p136/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb ]] ; then
74
+ bundle exec rake-compiler cross-ruby VERSION=1.9.2-p136
75
+ fi
76
+ bundle exec rake cross
77
+ bundle exec rake gem:windows
78
+ cp -v pkg/nokogiri*x86-{mingw32,mswin32}*.gem gems
66
79
 
67
80
  # MRI
68
81
  rvm_use 1.8.7
@@ -70,11 +83,11 @@ bundle exec rake gem
70
83
  cp -v pkg/nokogiri*.gem gems # should only be one at this point in the script
71
84
 
72
85
  # jruby
73
- rvm_use jruby-1.6.5
86
+ rvm_use jruby
74
87
  bundle install --quiet --local || bundle install
75
88
  bundle exec rake clean clobber
76
89
  rvm_use 1.8.7
77
90
  bundle exec rake generate
78
- rvm_use jruby-1.6.5
91
+ rvm_use jruby
79
92
  bundle exec rake gem
80
- cp -v pkg/nokogiri*java.gem gems
93
+ cp -v pkg/nokogiri*java.gem gems
@@ -27,6 +27,7 @@ end
27
27
 
28
28
  if RbConfig::MAKEFILE_CONFIG['CC'] =~ /mingw/
29
29
  $CFLAGS << " -DIN_LIBXML"
30
+ $LIBS << " -lz" # TODO why is this necessary?
30
31
  end
31
32
 
32
33
  if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
@@ -109,6 +109,10 @@ static VALUE serialize(VALUE self, VALUE xmlobj)
109
109
  return rval ;
110
110
  }
111
111
 
112
+ static void swallow_superfluous_xml_errors(void * userdata, xmlErrorPtr error, ...)
113
+ {
114
+ }
115
+
112
116
  /*
113
117
  * call-seq:
114
118
  * transform(document, params = [])
@@ -126,12 +130,13 @@ static VALUE serialize(VALUE self, VALUE xmlobj)
126
130
  */
127
131
  static VALUE transform(int argc, VALUE* argv, VALUE self)
128
132
  {
129
- VALUE xmldoc, paramobj ;
133
+ VALUE xmldoc, paramobj, errstr, exception ;
130
134
  xmlDocPtr xml ;
131
135
  xmlDocPtr result ;
132
136
  nokogiriXsltStylesheetTuple *wrapper;
133
137
  const char** params ;
134
138
  long param_len, j ;
139
+ int parse_error_occurred ;
135
140
 
136
141
  rb_scan_args(argc, argv, "11", &xmldoc, &paramobj);
137
142
  if (NIL_P(paramobj)) { paramobj = rb_ary_new2(0L) ; }
@@ -158,10 +163,22 @@ static VALUE transform(int argc, VALUE* argv, VALUE self)
158
163
  }
159
164
  params[param_len] = 0 ;
160
165
 
166
+ errstr = rb_str_new(0, 0);
167
+ xsltSetGenericErrorFunc((void *)errstr, xslt_generic_error_handler);
168
+ xmlSetGenericErrorFunc(NULL, (xmlGenericErrorFunc)&swallow_superfluous_xml_errors);
169
+
161
170
  result = xsltApplyStylesheet(wrapper->ss, xml, params);
162
171
  free(params);
163
172
 
164
- if (!result) rb_raise(rb_eRuntimeError, "could not perform xslt transform on document");
173
+ xsltSetGenericErrorFunc(NULL, NULL);
174
+ xmlSetGenericErrorFunc(NULL, NULL);
175
+
176
+ parse_error_occurred = (Qfalse == rb_funcall(errstr, rb_intern("empty?"), 0));
177
+
178
+ if (parse_error_occurred) {
179
+ exception = rb_exc_new3(rb_eRuntimeError, errstr);
180
+ rb_exc_raise(exception);
181
+ }
165
182
 
166
183
  return Nokogiri_wrap_xml_document((VALUE)0, result) ;
167
184
  }
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.5.6.rc1'
3
+ VERSION = '1.5.6.rc2'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -299,20 +299,7 @@ module Nokogiri
299
299
  def add_previous_sibling node_or_tags
300
300
  raise ArgumentError.new("A document may not have multiple root nodes.") if parent.is_a?(XML::Document) && !node_or_tags.is_a?(XML::ProcessingInstruction)
301
301
 
302
- node_or_tags = coerce(node_or_tags)
303
- if node_or_tags.is_a?(XML::NodeSet)
304
- if text?
305
- pivot = Nokogiri::XML::Node.new 'dummy', document
306
- add_previous_sibling_node pivot
307
- else
308
- pivot = self
309
- end
310
- node_or_tags.each { |n| pivot.send :add_previous_sibling_node, n }
311
- pivot.unlink if text?
312
- else
313
- add_previous_sibling_node node_or_tags
314
- end
315
- node_or_tags
302
+ add_sibling :previous, node_or_tags
316
303
  end
317
304
 
318
305
  ###
@@ -325,20 +312,7 @@ module Nokogiri
325
312
  def add_next_sibling node_or_tags
326
313
  raise ArgumentError.new("A document may not have multiple root nodes.") if parent.is_a?(XML::Document)
327
314
 
328
- node_or_tags = coerce(node_or_tags)
329
- if node_or_tags.is_a?(XML::NodeSet)
330
- if text?
331
- pivot = Nokogiri::XML::Node.new 'dummy', document
332
- add_next_sibling_node pivot
333
- else
334
- pivot = self
335
- end
336
- node_or_tags.reverse_each { |n| pivot.send :add_next_sibling_node, n }
337
- pivot.unlink if text?
338
- else
339
- add_next_sibling_node node_or_tags
340
- end
341
- node_or_tags
315
+ add_sibling :next, node_or_tags
342
316
  end
343
317
 
344
318
  ####
@@ -761,12 +735,7 @@ module Nokogiri
761
735
  # See Node#write_to for a list of +options+. For formatted output,
762
736
  # use Node#to_xhtml instead.
763
737
  def to_html options = {}
764
- # FIXME: this is a hack around broken libxml versions
765
- return dump_html if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
766
-
767
- options[:save_with] |= SaveOptions::DEFAULT_HTML if options[:save_with]
768
- options[:save_with] = SaveOptions::DEFAULT_HTML unless options[:save_with]
769
- serialize(options)
738
+ to_format SaveOptions::DEFAULT_HTML, options
770
739
  end
771
740
 
772
741
  ###
@@ -787,12 +756,7 @@ module Nokogiri
787
756
  #
788
757
  # See Node#write_to for a list of +options+
789
758
  def to_xhtml options = {}
790
- # FIXME: this is a hack around broken libxml versions
791
- return dump_html if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
792
-
793
- options[:save_with] |= SaveOptions::DEFAULT_XHTML if options[:save_with]
794
- options[:save_with] = SaveOptions::DEFAULT_XHTML unless options[:save_with]
795
- serialize(options)
759
+ to_format SaveOptions::DEFAULT_XHTML, options
796
760
  end
797
761
 
798
762
  ###
@@ -835,11 +799,7 @@ module Nokogiri
835
799
  #
836
800
  # See Node#write_to for a list of +options+
837
801
  def write_html_to io, options = {}
838
- # FIXME: this is a hack around broken libxml versions
839
- return (io << dump_html) if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
840
-
841
- options[:save_with] ||= SaveOptions::DEFAULT_HTML
842
- write_to io, options
802
+ write_format_to SaveOptions::DEFAULT_HTML, io, options
843
803
  end
844
804
 
845
805
  ###
@@ -847,11 +807,7 @@ module Nokogiri
847
807
  #
848
808
  # See Node#write_to for a list of +options+
849
809
  def write_xhtml_to io, options = {}
850
- # FIXME: this is a hack around broken libxml versions
851
- return (io << dump_html) if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
852
-
853
- options[:save_with] ||= SaveOptions::DEFAULT_XHTML
854
- write_to io, options
810
+ write_format_to SaveOptions::DEFAULT_XHTML, io, options
855
811
  end
856
812
 
857
813
  ###
@@ -898,6 +854,43 @@ module Nokogiri
898
854
 
899
855
  private
900
856
 
857
+ def add_sibling next_or_previous, node_or_tags
858
+ impl = (next_or_previous == :next) ? :add_next_sibling_node : :add_previous_sibling_node
859
+ iter = (next_or_previous == :next) ? :reverse_each : :each
860
+
861
+ node_or_tags = coerce node_or_tags
862
+ if node_or_tags.is_a?(XML::NodeSet)
863
+ if text?
864
+ pivot = Nokogiri::XML::Node.new 'dummy', document
865
+ send impl, pivot
866
+ else
867
+ pivot = self
868
+ end
869
+ node_or_tags.send(iter) { |n| pivot.send impl, n }
870
+ pivot.unlink if text?
871
+ else
872
+ send impl, node_or_tags
873
+ end
874
+ node_or_tags
875
+ end
876
+
877
+ def to_format save_option, options
878
+ # FIXME: this is a hack around broken libxml versions
879
+ return dump_html if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
880
+
881
+ options[:save_with] |= save_option if options[:save_with]
882
+ options[:save_with] = save_option unless options[:save_with]
883
+ serialize(options)
884
+ end
885
+
886
+ def write_format_to save_option, io, options
887
+ # FIXME: this is a hack around broken libxml versions
888
+ return (io << dump_html) if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
889
+
890
+ options[:save_with] ||= save_option
891
+ write_to io, options
892
+ end
893
+
901
894
  def extract_params params # :nodoc:
902
895
  # Pop off our custom function handler if it exists
903
896
  handler = params.find { |param|
@@ -68,6 +68,7 @@ module Nokogiri
68
68
 
69
69
  # Create a new Parser with +doc+ and +encoding+
70
70
  def initialize doc = Nokogiri::XML::SAX::Document.new, encoding = 'UTF-8'
71
+ check_encoding(encoding)
71
72
  @encoding = encoding
72
73
  @document = doc
73
74
  @warned = false
@@ -87,6 +88,7 @@ module Nokogiri
87
88
  ###
88
89
  # Parse given +io+
89
90
  def parse_io io, encoding = 'ASCII'
91
+ check_encoding(encoding)
90
92
  @encoding = encoding
91
93
  ctx = ParserContext.io(io, ENCODINGS[encoding])
92
94
  yield ctx if block_given?
@@ -109,6 +111,11 @@ module Nokogiri
109
111
  yield ctx if block_given?
110
112
  ctx.parse_with self
111
113
  end
114
+
115
+ private
116
+ def check_encoding(encoding)
117
+ raise ArgumentError.new("'#{encoding}' is not a valid encoding") unless ENCODINGS[encoding]
118
+ end
112
119
  end
113
120
  end
114
121
  end
@@ -24,7 +24,7 @@ module Nokogiri
24
24
  def parse string, modules = {}
25
25
  modules.each do |url, klass|
26
26
  XSLT.register url, klass
27
- end
27
+ end
28
28
 
29
29
  if Nokogiri.jruby?
30
30
  Stylesheet.parse_stylesheet_doc(XML.parse(string), string)
@@ -4,10 +4,10 @@ HOST = Rake::ExtensionCompiler.mingw_host
4
4
 
5
5
  require 'mini_portile'
6
6
  $recipes = {}
7
- $recipes[:zlib] = MiniPortile.new "zlib", "1.2.5"
7
+ $recipes[:zlib] = MiniPortile.new "zlib", "1.2.7"
8
8
  $recipes[:libiconv] = MiniPortile.new "libiconv", "1.13.1"
9
- $recipes[:libxml2] = MiniPortile.new "libxml2", "2.7.7"
10
- $recipes[:libxslt] = MiniPortile.new "libxslt", "1.1.26"
9
+ $recipes[:libxml2] = MiniPortile.new "libxml2", "2.7.7"
10
+ $recipes[:libxslt] = MiniPortile.new "libxslt", "1.1.26"
11
11
  $recipes.each { |_, recipe| recipe.host = HOST }
12
12
 
13
13
  file "lib/nokogiri/nokogiri.rb" do
@@ -369,6 +369,29 @@ eohtml
369
369
  assert_equal('Hello world!', node.inner_text.strip)
370
370
  end
371
371
 
372
+ def test_doc_type
373
+ html = Nokogiri::HTML(<<-eohtml)
374
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
375
+ <html xmlns="http://www.w3.org/1999/xhtml">
376
+ <body>
377
+ <p>Rainbow Dash</p>
378
+ </body>
379
+ </html>
380
+ eohtml
381
+ assert_equal "html", html.internal_subset.name
382
+ assert_equal "-//W3C//DTD XHTML 1.1//EN", html.internal_subset.external_id
383
+ assert_equal "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", html.internal_subset.system_id
384
+ assert_equal "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">", html.to_s[0,97]
385
+ end
386
+
387
+ def test_content_size
388
+ html = Nokogiri::HTML('<div>
389
+ </div>')
390
+ assert_equal 1, html.content.size
391
+ assert_equal 1, html.content.split("").size
392
+ assert_equal "\n", html.content
393
+ end
394
+
372
395
  def test_find_by_xpath
373
396
  found = @html.xpath('//div/a')
374
397
  assert_equal 3, found.length
@@ -189,8 +189,37 @@ encoding="iso-8859-1" indent="yes"/>
189
189
  Nokogiri::XSLT.quote_params(params.to_a.flatten)))
190
190
  check_params result_doc, params
191
191
  end
192
+
193
+ def test_xslt_paramaters
194
+ xslt_str = <<-EOX
195
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
196
+ <xsl:template match="/">
197
+ <xsl:value-of select="$foo" />
198
+ </xsl:template>
199
+ </xsl:stylesheet>
200
+ EOX
201
+
202
+ xslt = Nokogiri::XSLT(xslt_str)
203
+ doc = Nokogiri::XML("<root />")
204
+ assert_match %r{bar}, xslt.transform(doc, Nokogiri::XSLT.quote_params('foo' => 'bar')).to_s
205
+ end
206
+
207
+ def test_xslt_transform_error
208
+ xslt_str = <<-EOX
209
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
210
+ <xsl:template match="/">
211
+ <xsl:value-of select="$foo" />
212
+ </xsl:template>
213
+ </xsl:stylesheet>
214
+ EOX
215
+
216
+ xslt = Nokogiri::XSLT(xslt_str)
217
+ doc = Nokogiri::XML("<root />")
218
+ assert_raises(RuntimeError) { xslt.transform(doc) }
219
+ end
192
220
  end
193
221
 
222
+
194
223
  def test_xslt_parse_error
195
224
  xslt_str = <<-EOX
196
225
  <xsl:stylesheet version="1.0"
@@ -210,6 +239,7 @@ encoding="iso-8859-1" indent="yes"/>
210
239
  assert_raises(RuntimeError) { Nokogiri::XSLT.parse(xslt_str) }
211
240
  end
212
241
 
242
+
213
243
  def test_passing_a_non_document_to_transform
214
244
  xsl = Nokogiri::XSLT('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"></xsl:stylesheet>')
215
245
  assert_raises(ArgumentError) { xsl.transform("<div></div>") }
@@ -250,6 +250,11 @@ module Nokogiri
250
250
  assert_raises(ArgumentError) { @parser.parse_memory(nil) }
251
251
  end
252
252
 
253
+ def test_bad_encoding_args
254
+ assert_raises(ArgumentError) { XML::SAX::Parser.new(Doc.new, 'not an encoding') }
255
+ assert_raises(ArgumentError) { @parser.parse_io(StringIO.new('<root/>'), 'not an encoding')}
256
+ end
257
+
253
258
  def test_ctag
254
259
  @parser.parse_memory(<<-eoxml)
255
260
  <p id="asdfasdf">
@@ -1031,7 +1031,15 @@ EOXML
1031
1031
  subject = Nokogiri::XML::Node.new 'foo', document
1032
1032
  ns = subject.add_namespace nil, 'bar'
1033
1033
  subject.namespace = ns
1034
- assert_match subject.to_xml, /xmlns="bar"/
1034
+ assert_match(/xmlns="bar"/, subject.to_xml)
1035
+ end
1036
+
1037
+ def test_text_node_colon
1038
+ document = Nokogiri::XML::Document.new
1039
+ root = Nokogiri::XML::Node.new 'foo', document
1040
+ document.root = root
1041
+ root << "<a>hello:with_colon</a>"
1042
+ assert_match(/hello:with_colon/, document.to_xml)
1035
1043
  end
1036
1044
  end
1037
1045
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424087
4
+ hash: -258463307
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
9
  - 6
10
10
  - rc
11
- - 1
12
- version: 1.5.6.rc1
11
+ - 2
12
+ version: 1.5.6.rc2
13
13
  platform: ruby
14
14
  authors:
15
15
  - Aaron Patterson
@@ -20,9 +20,11 @@ autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
22
 
23
- date: 2012-07-11 00:00:00 Z
23
+ date: 2012-09-12 00:00:00 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
+ prerelease: false
27
+ name: hoe-bundler
26
28
  version_requirements: &id001 !ruby/object:Gem::Requirement
27
29
  none: false
28
30
  requirements:
@@ -33,11 +35,11 @@ dependencies:
33
35
  - 1
34
36
  - 1
35
37
  version: "1.1"
36
- prerelease: false
37
38
  requirement: *id001
38
39
  type: :development
39
- name: hoe-bundler
40
40
  - !ruby/object:Gem::Dependency
41
+ prerelease: false
42
+ name: hoe-debugging
41
43
  version_requirements: &id002 !ruby/object:Gem::Requirement
42
44
  none: false
43
45
  requirements:
@@ -49,11 +51,11 @@ dependencies:
49
51
  - 0
50
52
  - 3
51
53
  version: 1.0.3
52
- prerelease: false
53
54
  requirement: *id002
54
55
  type: :development
55
- name: hoe-debugging
56
56
  - !ruby/object:Gem::Dependency
57
+ prerelease: false
58
+ name: hoe-gemspec
57
59
  version_requirements: &id003 !ruby/object:Gem::Requirement
58
60
  none: false
59
61
  requirements:
@@ -64,11 +66,11 @@ dependencies:
64
66
  - 1
65
67
  - 0
66
68
  version: "1.0"
67
- prerelease: false
68
69
  requirement: *id003
69
70
  type: :development
70
- name: hoe-gemspec
71
71
  - !ruby/object:Gem::Dependency
72
+ prerelease: false
73
+ name: hoe-git
72
74
  version_requirements: &id004 !ruby/object:Gem::Requirement
73
75
  none: false
74
76
  requirements:
@@ -79,11 +81,11 @@ dependencies:
79
81
  - 1
80
82
  - 4
81
83
  version: "1.4"
82
- prerelease: false
83
84
  requirement: *id004
84
85
  type: :development
85
- name: hoe-git
86
86
  - !ruby/object:Gem::Dependency
87
+ prerelease: false
88
+ name: mini_portile
87
89
  version_requirements: &id005 !ruby/object:Gem::Requirement
88
90
  none: false
89
91
  requirements:
@@ -95,11 +97,11 @@ dependencies:
95
97
  - 2
96
98
  - 2
97
99
  version: 0.2.2
98
- prerelease: false
99
100
  requirement: *id005
100
101
  type: :development
101
- name: mini_portile
102
102
  - !ruby/object:Gem::Dependency
103
+ prerelease: false
104
+ name: minitest
103
105
  version_requirements: &id006 !ruby/object:Gem::Requirement
104
106
  none: false
105
107
  requirements:
@@ -111,11 +113,11 @@ dependencies:
111
113
  - 2
112
114
  - 2
113
115
  version: 2.2.2
114
- prerelease: false
115
116
  requirement: *id006
116
117
  type: :development
117
- name: minitest
118
118
  - !ruby/object:Gem::Dependency
119
+ prerelease: false
120
+ name: rake
119
121
  version_requirements: &id007 !ruby/object:Gem::Requirement
120
122
  none: false
121
123
  requirements:
@@ -126,11 +128,11 @@ dependencies:
126
128
  - 0
127
129
  - 9
128
130
  version: "0.9"
129
- prerelease: false
130
131
  requirement: *id007
131
132
  type: :development
132
- name: rake
133
133
  - !ruby/object:Gem::Dependency
134
+ prerelease: false
135
+ name: rake-compiler
134
136
  version_requirements: &id008 !ruby/object:Gem::Requirement
135
137
  none: false
136
138
  requirements:
@@ -142,11 +144,11 @@ dependencies:
142
144
  - 8
143
145
  - 0
144
146
  version: 0.8.0
145
- prerelease: false
146
147
  requirement: *id008
147
148
  type: :development
148
- name: rake-compiler
149
149
  - !ruby/object:Gem::Dependency
150
+ prerelease: false
151
+ name: racc
150
152
  version_requirements: &id009 !ruby/object:Gem::Requirement
151
153
  none: false
152
154
  requirements:
@@ -158,11 +160,11 @@ dependencies:
158
160
  - 4
159
161
  - 6
160
162
  version: 1.4.6
161
- prerelease: false
162
163
  requirement: *id009
163
164
  type: :development
164
- name: racc
165
165
  - !ruby/object:Gem::Dependency
166
+ prerelease: false
167
+ name: rexical
166
168
  version_requirements: &id010 !ruby/object:Gem::Requirement
167
169
  none: false
168
170
  requirements:
@@ -174,11 +176,11 @@ dependencies:
174
176
  - 0
175
177
  - 5
176
178
  version: 1.0.5
177
- prerelease: false
178
179
  requirement: *id010
179
180
  type: :development
180
- name: rexical
181
181
  - !ruby/object:Gem::Dependency
182
+ prerelease: false
183
+ name: rdoc
182
184
  version_requirements: &id011 !ruby/object:Gem::Requirement
183
185
  none: false
184
186
  requirements:
@@ -189,11 +191,11 @@ dependencies:
189
191
  - 3
190
192
  - 10
191
193
  version: "3.10"
192
- prerelease: false
193
194
  requirement: *id011
194
195
  type: :development
195
- name: rdoc
196
196
  - !ruby/object:Gem::Dependency
197
+ prerelease: false
198
+ name: hoe
197
199
  version_requirements: &id012 !ruby/object:Gem::Requirement
198
200
  none: false
199
201
  requirements:
@@ -204,10 +206,8 @@ dependencies:
204
206
  - 2
205
207
  - 16
206
208
  version: "2.16"
207
- prerelease: false
208
209
  requirement: *id012
209
210
  type: :development
210
- name: hoe
211
211
  description: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser. Among Nokogiri's\n\
212
212
  many features is the ability to search documents via XPath or CSS3 selectors.\n\n\
213
213
  XML is like violence - if it doesn\xE2\x80\x99t solve your problems, you are not using\n\
@@ -228,40 +228,40 @@ extra_rdoc_files:
228
228
  - Manifest.txt
229
229
  - README.ja.rdoc
230
230
  - README.rdoc
231
- - ext/nokogiri/xml_sax_push_parser.c
232
- - ext/nokogiri/xml_relax_ng.c
233
- - ext/nokogiri/html_sax_parser_context.c
234
- - ext/nokogiri/html_entity_lookup.c
235
231
  - ext/nokogiri/xml_text.c
232
+ - ext/nokogiri/xml_xpath_context.c
236
233
  - ext/nokogiri/html_sax_push_parser.c
237
- - ext/nokogiri/nokogiri.c
238
- - ext/nokogiri/xml_element_decl.c
239
- - ext/nokogiri/xml_encoding_handler.c
240
- - ext/nokogiri/html_document.c
234
+ - ext/nokogiri/xml_cdata.c
235
+ - ext/nokogiri/html_element_description.c
236
+ - ext/nokogiri/xml_comment.c
241
237
  - ext/nokogiri/xslt_stylesheet.c
242
- - ext/nokogiri/xml_attribute_decl.c
243
- - ext/nokogiri/xml_io.c
244
238
  - ext/nokogiri/xml_document_fragment.c
245
- - ext/nokogiri/xml_namespace.c
246
- - ext/nokogiri/xml_libxml2_hacks.c
239
+ - ext/nokogiri/html_document.c
247
240
  - ext/nokogiri/xml_sax_parser_context.c
248
- - ext/nokogiri/xml_comment.c
249
- - ext/nokogiri/xml_sax_parser.c
250
- - ext/nokogiri/html_element_description.c
251
- - ext/nokogiri/xml_xpath_context.c
252
- - ext/nokogiri/xml_syntax_error.c
253
- - ext/nokogiri/xml_document.c
241
+ - ext/nokogiri/xml_element_content.c
254
242
  - ext/nokogiri/xml_entity_decl.c
255
- - ext/nokogiri/xml_node.c
256
- - ext/nokogiri/xml_node_set.c
257
243
  - ext/nokogiri/xml_reader.c
244
+ - ext/nokogiri/xml_io.c
245
+ - ext/nokogiri/xml_entity_reference.c
246
+ - ext/nokogiri/xml_libxml2_hacks.c
247
+ - ext/nokogiri/nokogiri.c
248
+ - ext/nokogiri/xml_encoding_handler.c
249
+ - ext/nokogiri/html_entity_lookup.c
250
+ - ext/nokogiri/xml_sax_parser.c
251
+ - ext/nokogiri/xml_schema.c
252
+ - ext/nokogiri/xml_namespace.c
258
253
  - ext/nokogiri/xml_processing_instruction.c
259
- - ext/nokogiri/xml_element_content.c
254
+ - ext/nokogiri/html_sax_parser_context.c
255
+ - ext/nokogiri/xml_document.c
256
+ - ext/nokogiri/xml_sax_push_parser.c
257
+ - ext/nokogiri/xml_relax_ng.c
260
258
  - ext/nokogiri/xml_dtd.c
261
259
  - ext/nokogiri/xml_attr.c
262
- - ext/nokogiri/xml_schema.c
263
- - ext/nokogiri/xml_cdata.c
264
- - ext/nokogiri/xml_entity_reference.c
260
+ - ext/nokogiri/xml_element_decl.c
261
+ - ext/nokogiri/xml_syntax_error.c
262
+ - ext/nokogiri/xml_attribute_decl.c
263
+ - ext/nokogiri/xml_node.c
264
+ - ext/nokogiri/xml_node_set.c
265
265
  files:
266
266
  - .autotest
267
267
  - .gemtest
@@ -436,13 +436,13 @@ files:
436
436
  - test/files/staff.dtd
437
437
  - test/files/staff.xml
438
438
  - test/files/staff.xslt
439
+ - test/files/test_document_url/bar.xml
440
+ - test/files/test_document_url/document.dtd
441
+ - test/files/test_document_url/document.xml
439
442
  - test/files/tlm.html
440
443
  - test/files/to_be_xincluded.xml
441
444
  - test/files/valid_bar.xml
442
445
  - test/files/xinclude.xml
443
- - test/files/test_document_url/bar.xml
444
- - test/files/test_document_url/document.dtd
445
- - test/files/test_document_url/document.xml
446
446
  - test/helper.rb
447
447
  - test/html/sax/test_parser.rb
448
448
  - test/html/sax/test_parser_context.rb
@@ -536,70 +536,70 @@ required_rubygems_version: !ruby/object:Gem::Requirement
536
536
  requirements: []
537
537
 
538
538
  rubyforge_project: nokogiri
539
- rubygems_version: 1.8.10
539
+ rubygems_version: 1.8.24
540
540
  signing_key:
541
541
  specification_version: 3
542
542
  summary: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser"
543
543
  test_files:
544
- - test/test_convert_xpath.rb
545
- - test/test_soap4r_sax.rb
546
544
  - test/test_memory_leak.rb
547
- - test/test_nokogiri.rb
548
- - test/test_css_cache.rb
549
- - test/css/test_nthiness.rb
550
- - test/css/test_xpath_visitor.rb
551
- - test/css/test_parser.rb
552
- - test/css/test_tokenizer.rb
553
- - test/decorators/test_slop.rb
554
- - test/html/test_document.rb
555
- - test/html/test_document_encoding.rb
556
- - test/html/test_named_characters.rb
557
- - test/html/test_document_fragment.rb
558
- - test/html/test_node.rb
559
- - test/html/test_builder.rb
560
- - test/html/sax/test_parser_context.rb
561
- - test/html/sax/test_parser.rb
562
- - test/html/test_node_encoding.rb
563
- - test/html/test_element_description.rb
564
- - test/test_reader.rb
565
- - test/xml/test_parse_options.rb
566
- - test/xml/test_unparented_node.rb
567
- - test/xml/test_element_decl.rb
568
- - test/xml/test_document.rb
569
- - test/xml/test_dtd.rb
570
- - test/xml/test_document_encoding.rb
571
- - test/xml/test_entity_decl.rb
572
- - test/xml/test_dtd_encoding.rb
573
- - test/xml/node/test_save_options.rb
574
- - test/xml/node/test_subclass.rb
545
+ - test/xml/test_node_attributes.rb
575
546
  - test/xml/test_document_fragment.rb
576
- - test/xml/test_cdata.rb
577
- - test/xml/test_text.rb
578
- - test/xml/test_reader_encoding.rb
579
- - test/xml/test_xpath.rb
580
- - test/xml/test_element_content.rb
581
- - test/xml/test_node.rb
582
- - test/xml/test_builder.rb
583
- - test/xml/sax/test_push_parser.rb
584
- - test/xml/sax/test_parser_context.rb
585
- - test/xml/sax/test_parser.rb
586
- - test/xml/test_schema.rb
587
547
  - test/xml/test_node_set.rb
588
- - test/xml/test_attr.rb
548
+ - test/xml/node/test_subclass.rb
549
+ - test/xml/node/test_save_options.rb
589
550
  - test/xml/test_processing_instruction.rb
590
- - test/xml/test_node_encoding.rb
591
- - test/xml/test_node_inheritance.rb
551
+ - test/xml/test_node.rb
552
+ - test/xml/test_dtd.rb
553
+ - test/xml/test_xinclude.rb
554
+ - test/xml/sax/test_parser.rb
555
+ - test/xml/sax/test_parser_context.rb
556
+ - test/xml/sax/test_push_parser.rb
557
+ - test/xml/test_parse_options.rb
558
+ - test/xml/test_element_content.rb
559
+ - test/xml/test_dtd_encoding.rb
592
560
  - test/xml/test_syntax_error.rb
561
+ - test/xml/test_text.rb
562
+ - test/xml/test_node_encoding.rb
563
+ - test/xml/test_unparented_node.rb
564
+ - test/xml/test_cdata.rb
565
+ - test/xml/test_element_decl.rb
566
+ - test/xml/test_xpath.rb
567
+ - test/xml/test_reader_encoding.rb
593
568
  - test/xml/test_comment.rb
594
- - test/xml/test_entity_reference.rb
595
- - test/xml/test_node_reparenting.rb
596
569
  - test/xml/test_attribute_decl.rb
597
- - test/xml/test_xinclude.rb
598
- - test/xml/test_relax_ng.rb
570
+ - test/xml/test_document_encoding.rb
571
+ - test/xml/test_schema.rb
572
+ - test/xml/test_node_inheritance.rb
599
573
  - test/xml/test_namespace.rb
600
- - test/xml/test_node_attributes.rb
574
+ - test/xml/test_relax_ng.rb
575
+ - test/xml/test_entity_reference.rb
601
576
  - test/xml/test_c14n.rb
602
- - test/test_xslt_transforms.rb
577
+ - test/xml/test_attr.rb
578
+ - test/xml/test_document.rb
579
+ - test/xml/test_node_reparenting.rb
580
+ - test/xml/test_builder.rb
581
+ - test/xml/test_entity_decl.rb
582
+ - test/test_convert_xpath.rb
583
+ - test/html/test_document_fragment.rb
584
+ - test/html/test_node.rb
585
+ - test/html/sax/test_parser.rb
586
+ - test/html/sax/test_parser_context.rb
587
+ - test/html/test_node_encoding.rb
588
+ - test/html/test_named_characters.rb
589
+ - test/html/test_document_encoding.rb
590
+ - test/html/test_document.rb
591
+ - test/html/test_element_description.rb
592
+ - test/html/test_builder.rb
593
+ - test/test_css_cache.rb
594
+ - test/test_encoding_handler.rb
595
+ - test/css/test_parser.rb
596
+ - test/css/test_xpath_visitor.rb
597
+ - test/css/test_tokenizer.rb
598
+ - test/css/test_nthiness.rb
599
+ - test/decorators/test_slop.rb
600
+ - test/test_soap4r_sax.rb
601
+ - test/test_nokogiri.rb
603
602
  - test/xslt/test_custom_functions.rb
604
603
  - test/xslt/test_exception_handling.rb
605
- - test/test_encoding_handler.rb
604
+ - test/test_reader.rb
605
+ - test/test_xslt_transforms.rb