nokogiri 1.5.6 → 1.5.7.rc1

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.

@@ -1,4 +1,9 @@
1
- == 1.5.6 / unreleased
1
+ == 1.5.7 / unreleased
2
+
3
+ * Bugfixes
4
+ * (JRuby) Java Nokogiri is finally green (passes all tests) under 1.8 and 1.9 mode. High five everyone. #798, #705
5
+
6
+ == 1.5.6 / 2012年12月19日
2
7
 
3
8
  * Features
4
9
 
@@ -16,24 +21,24 @@
16
21
  * Nokogiri はこのバージョンからXSLT変換のエラーを検出するようになった。#731 (ありがとう、Justin Fitzsimmons!)
17
22
  * Don't throw an Error when trying to replace top-level text node in DocumentFragment. #775
18
23
  * SAXパーザに不正なエンコーディングに渡された場合はArgumentErrorを投げるようにした。#756 (ありがとう、Bradley Schaefer!)
19
- * [JRuby] XML宣言の前にスペースがあると、ドキュメントのパーズに失敗する。(#748の修正でこれもなおっている) #790
20
- * [JRuby] Nokogiri::XML::Node#content のJRubyの振る舞いがCRubyと同じではない。#794, #797
21
- * [JRuby] で '#' で始まる文字列を名前とする EntityReference を作ろうとすると INVALID_CHARACTER_ERR という例外がはっせいする。 #719
22
- * [JRuby] では Nodeのサブクラスのnamespaceを正しく文字列に変換しない。 #715
23
- * [JRuby] Node#contentがこのバージョンから改行コードを正しく表示するようになった。#737 (ありがとう、Piotr Szmielew!)
24
- * [JRuby] recover optionが指定されている場合は宣言の無いネームスペースを無視するようにした。#748
25
- * [JRuby] ネームスペースを検出するXPathが続けて実行されても例外を投げてはいけない。#764
26
- * [JRuby] XMLを表示(出力)する際のホワイトスペースの扱いをlibxml2バージョンとさらに同様になるようにした。#771
27
- * [JRuby] ネームスペース付きの属性を含むXMLドキュメントを文字列でbuilderに追加しようとすると失敗する。#770
28
- * [JRuby] Nokogiri::XML::Document#wrapを使って生成したドキュメントに << でノードを追加しようとすると
24
+ * (JRuby) XML宣言の前にスペースがあると、ドキュメントのパーズに失敗する。(#748の修正でこれもなおっている) #790
25
+ * (JRuby) Nokogiri::XML::Node#content のJRubyの振る舞いがCRubyと同じではない。#794, #797
26
+ * (JRuby) で '#' で始まる文字列を名前とする EntityReference を作ろうとすると INVALID_CHARACTER_ERR という例外がはっせいする。 #719
27
+ * (JRuby) では Nodeのサブクラスのnamespaceを正しく文字列に変換しない。 #715
28
+ * (JRuby) Node#contentがこのバージョンから改行コードを正しく表示するようになった。#737 (ありがとう、Piotr Szmielew!)
29
+ * (JRuby) recover optionが指定されている場合は宣言の無いネームスペースを無視するようにした。#748
30
+ * (JRuby) ネームスペースを検出するXPathが続けて実行されても例外を投げてはいけない。#764
31
+ * (JRuby) XMLを表示(出力)する際のホワイトスペースの扱いをlibxml2バージョンとさらに同様になるようにした。#771
32
+ * (JRuby) ネームスペース付きの属性を含むXMLドキュメントを文字列でbuilderに追加しようとすると失敗する。#770
33
+ * (JRuby) Nokogiri::XML::Document#wrapを使って生成したドキュメントに << でノードを追加しようとすると
29
34
  undefined method `length' for nil:NilClassのエラーが発生する #781
30
- * [JRuby] 開いているファイルのデスクリプタを閉じようとすると、"bad file descriptor" が発生する。#495
31
- * [JRuby] JRuby/CRuby incompatibility for attribute decorators. #785
32
- * [JRuby] Issues parsing valid XML with no internal subset in the DTD. #547, #811
33
- * [JRuby] Issues parsing valid node content when it contains colons. #728
34
- * [JRuby] Correctly parse the doc type of html documents. #733
35
- * [JRuby] Include dtd in the xml output when a builder is used with create_internal_subset. #751
36
- * [JRuby] builder requires textwrappers for valid utf8 in jruby, not in mri. #784
35
+ * (JRuby) 開いているファイルのデスクリプタを閉じようとすると、"bad file descriptor" が発生する。#495
36
+ * (JRuby) JRuby/CRuby incompatibility for attribute decorators. #785
37
+ * (JRuby) Issues parsing valid XML with no internal subset in the DTD. #547, #811
38
+ * (JRuby) Issues parsing valid node content when it contains colons. #728
39
+ * (JRuby) Correctly parse the doc type of html documents. #733
40
+ * (JRuby) Include dtd in the xml output when a builder is used with create_internal_subset. #751
41
+ * (JRuby) builder requires textwrappers for valid utf8 in jruby, not in mri. #784
37
42
 
38
43
 
39
44
  == 1.5.5 / 2012年6月24日
@@ -72,7 +77,7 @@
72
77
  * DocumentFragment をベースにしてコメントノードを作ったときに Segmentation fault する。 #677, #678.
73
78
  * at() と search() メソッドで '.' をxpathとして扱う。 #690
74
79
 
75
- * [MRI, Security] XML パース時のディフォルトのオプションを nonet に変更。これにより、ディフォルトでは
80
+ * (MRI, Security) XML パース時のディフォルトのオプションを nonet に変更。これにより、ディフォルトでは
76
81
  ドキュメントパース時にネットワーク接続を行わないようにし、XXE 脆弱性に対応した。#693
77
82
 
78
83
  パース時にネットワークに接続して外部のドキュメントを見にいかせたい場合には、以下のように `nonoet` オプションを設定する:
@@ -102,12 +107,12 @@
102
107
  * Nokogiri::XML::Attribute が JRuby 上で nil namespace を返す #647
103
108
  * Nokogiri::XML::Node#namespace= メソッドが JRuby 上で prefix
104
109
   が無い namespace を設定できない #648
105
- * [JRuby] 1.9 モードで rake を実行するとデッドロックを引き起こす #571
110
+ * (JRuby) 1.9 モードで rake を実行するとデッドロックを引き起こす #571
106
111
  * HTML::Document#meta_encoding does not raise exception on docs with
107
112
  malformed content-type. #655
108
113
  * Fixing segfault related to unsupported encodings in in-context
109
114
  parsing on 1.8.7. #643
110
- * [JRuby] Concurrency issue in XPath parsing. #682
115
+ * (JRuby) Concurrency issue in XPath parsing. #682
111
116
 
112
117
 
113
118
  == 1.5.2 / 2012-03-09
@@ -157,7 +162,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
157
162
  * Do not allow multiple root nodes. #550
158
163
  * Fixes for custom XPath functions. #605, #606 (thanks, Juan Wajnerman!)
159
164
  * Node#to_xml does not override :save_with if it is provided. #505
160
- * Node#set is a private method [JRuby]. #564 (thanks, Nick Sieger!)
165
+ * Node#set is a private method (JRuby). #564 (thanks, Nick Sieger!)
161
166
  * C14n cleanup and Node#canonicalize (thanks, Ivan Pirlik!) #563
162
167
 
163
168
  == 1.5.0 / 2011年7月1日
@@ -232,7 +237,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
232
237
 
233
238
  * Node#serialize とその仲間達はSaveOptionオブジェクトを受け入れる
234
239
  * Nokogiri::CSS::Parser has-a Nokogiri::CSS::Tokenizer
235
- * [JRUBY+FFIのみ] 「弱い参照」はスレッドセーフになった. #355
240
+ * (JRUBY+FFIのみ) 「弱い参照」はスレッドセーフになった. #355
236
241
  * HTML::SAX::Parserから呼ばれるstart_element()コールバックのattributes引数はHTML::XML::Parserによるエミュレートコールバックと同じく連想配列になった. rel. #356
237
242
  * HTML::SAX::Parserのparse*()メソッドはXML::SAX::Parser同様に渡されたブロックをコールバックするようになった.
238
243
  * HTMLパーサーのエンコーディング判定をlibxml2の仕様を超えて拡張・改善した. (XML宣言のencodingを認識、非ASCII文字出現後のmetaタグも文字化けを生じずに反映)
@@ -1,4 +1,17 @@
1
- == 1.5.6 / unreleased
1
+ == 1.5.7 / unreleased
2
+
3
+ * Bugfixes
4
+ * SAX::Parser.parse_io throw an error when used with lower case encoding. #828
5
+ * (JRuby) Java Nokogiri is finally green (passes all tests) under 1.8 and 1.9 mode. High five everyone. #798, #705
6
+ * (JRuby) Nokogiri::XML::Reader broken (as a pull parser) on jruby - reads the whole XML document. #831
7
+ * (JRuby) JRuby hangs parsing "&amp;". #837
8
+ * (JRuby) JRuby NPE parsing an invalid XML instruction. #838
9
+ * (JRuby) Node#content= incompatibility. #839
10
+ * (JRuby) to_xhtml doesn't print the last slash for self-closing tags in JRuby. #834
11
+ * (JRuby) Adding an EntityReference after a Text node mangles the entity in JRuby. #835
12
+ * (JRuby) JRuby version inconsistency: nil for empty attributes. #818
13
+
14
+ == 1.5.6 / 2012-12-19
2
15
 
3
16
  * Features
4
17
 
@@ -16,23 +29,24 @@
16
29
  * Nokogiri now detects XSLT transform errors. #731 (Thanks, Justin Fitzsimmons!)
17
30
  * Don't throw an Error when trying to replace top-level text node in DocumentFragment. #775
18
31
  * Raise an ArgumentError if an invalid encoding is passed to the SAX parser. #756 (Thanks, Bradley Schaefer!)
19
- * [JRuby] space prior to xml preamble causes nokogiri to fail parsing. (fixed along with #748) #790
20
- * [JRuby] Fixed the bug Nokogiri::XML::Node#content inconsistency between Java and C. #794, #797
21
- * [JRuby] raises INVALID_CHARACTER_ERR exception when EntityReference name starts with '#'. #719
22
- * [JRuby] doesn't coerce namespaces out of strings on a direct subclass of Node. #715
23
- * [JRuby] Node#content now renders newlines properly. #737 (Thanks, Piotr Szmielew!)
24
- * [JRuby] Unknown namespace are ignore when the recover option is used. #748
25
- * [JRuby] XPath queries for namespaces should not throw exceptions when called twice in a row. #764
26
- * [JRuby] More consistent (with libxml2) whitespace formatting when emitting XML. #771
27
- * [JRuby] namespaced attributes broken when appending raw xml to builder. #770
28
- * [JRuby] Nokogiri::XML::Document#wrap raises undefined method `length' for nil:NilClass when trying to << to a node. #781
29
- * [JRuby] Fixed "bad file descriptor" bug when closing open file descriptors. #495
30
- * [JRuby] JRuby/CRuby incompatibility for attribute decorators. #785
31
- * [JRuby] Issues parsing valid XML with no internal subset in the DTD. #547, #811
32
- * [JRuby] Issues parsing valid node content when it contains colons. #728
33
- * [JRuby] Correctly parse the doc type of html documents. #733
34
- * [JRuby] Include dtd in the xml output when a builder is used with create_internal_subset. #751
35
- * [JRuby] builder requires textwrappers for valid utf8 in jruby, not in mri. #784
32
+ * Prefixed element inconsistency between CRuby and JRuby. #712
33
+ * (JRuby) space prior to xml preamble causes nokogiri to fail parsing. (fixed along with #748) #790
34
+ * (JRuby) Fixed the bug Nokogiri::XML::Node#content inconsistency between Java and C. #794, #797
35
+ * (JRuby) raises INVALID_CHARACTER_ERR exception when EntityReference name starts with '#'. #719
36
+ * (JRuby) doesn't coerce namespaces out of strings on a direct subclass of Node. #715
37
+ * (JRuby) Node#content now renders newlines properly. #737 (Thanks, Piotr Szmielew!)
38
+ * (JRuby) Unknown namespace are ignore when the recover option is used. #748
39
+ * (JRuby) XPath queries for namespaces should not throw exceptions when called twice in a row. #764
40
+ * (JRuby) More consistent (with libxml2) whitespace formatting when emitting XML. #771
41
+ * (JRuby) namespaced attributes broken when appending raw xml to builder. #770
42
+ * (JRuby) Nokogiri::XML::Document#wrap raises undefined method `length' for nil:NilClass when trying to << to a node. #781
43
+ * (JRuby) Fixed "bad file descriptor" bug when closing open file descriptors. #495
44
+ * (JRuby) JRuby/CRuby incompatibility for attribute decorators. #785
45
+ * (JRuby) Issues parsing valid XML with no internal subset in the DTD. #547, #811
46
+ * (JRuby) Issues parsing valid node content when it contains colons. #728
47
+ * (JRuby) Correctly parse the doc type of html documents. #733
48
+ * (JRuby) Include dtd in the xml output when a builder is used with create_internal_subset. #751
49
+ * (JRuby) builder requires textwrappers for valid utf8 in jruby, not in mri. #784
36
50
 
37
51
 
38
52
  == 1.5.5 / 2012-06-24
@@ -71,7 +85,7 @@
71
85
  * Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
72
86
  * Treat '.' as xpath in at() and search(). #690
73
87
 
74
- * [MRI, Security] Default parse options for XML documents were
88
+ * (MRI, Security) Default parse options for XML documents were
75
89
  changed to not make network connections during document parsing,
76
90
  to avoid XXE vulnerability. #693
77
91
 
@@ -79,7 +93,7 @@
79
93
  be called, like this:
80
94
 
81
95
  Nokogiri::XML::Document.parse(xml) { |config| config.nononet }
82
-
96
+
83
97
  Insert your own joke about double-negatives here.
84
98
 
85
99
 
@@ -105,12 +119,12 @@
105
119
  * Nokogiri::XML::Attribute on JRuby returns a nil namespace #647
106
120
  * Nokogiri::XML::Node#namespace= cannot set a namespace without a
107
121
  prefix on JRuby #648
108
- * [JRuby] 1.9 mode causes dead lock while running rake #571
122
+ * (JRuby) 1.9 mode causes dead lock while running rake #571
109
123
  * HTML::Document#meta_encoding does not raise exception on docs with
110
124
  malformed content-type. #655
111
125
  * Fixing segfault related to unsupported encodings in in-context
112
126
  parsing on 1.8.7. #643
113
- * [JRuby] Concurrency issue in XPath parsing. #682
127
+ * (JRuby) Concurrency issue in XPath parsing. #682
114
128
 
115
129
 
116
130
  == 1.5.2 / 2012-03-09
@@ -155,11 +169,11 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
155
169
  object. #489
156
170
  * 1.5.0 Not using correct character encoding #488
157
171
  * Raw XML string in XML Builder broken on JRuby #486
158
- * Nokogiri 1.5.0 XML generation broken on JRuby #484
172
+ * Nokogiri 1.5.0 XML generation broken on JRuby #484
159
173
  * Do not allow multiple root nodes. #550
160
174
  * Fixes for custom XPath functions. #605, #606 (thanks, Juan Wajnerman!)
161
175
  * Node#to_xml does not override :save_with if it is provided. #505
162
- * Node#set is a private method [JRuby]. #564 (thanks, Nick Sieger!)
176
+ * Node#set is a private method (JRuby). #564 (thanks, Nick Sieger!)
163
177
  * C14n cleanup and Node#canonicalize (thanks, Ivan Pirlik!) #563
164
178
 
165
179
 
@@ -239,7 +253,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
239
253
 
240
254
  * Node#serialize-and-friends now accepts a SaveOption object as the, erm, save object.
241
255
  * Nokogiri::CSS::Parser has-a Nokogiri::CSS::Tokenizer
242
- * [JRUBY+FFI only] Weak references are now threadsafe. #355
256
+ * (JRUBY+FFI only) Weak references are now threadsafe. #355
243
257
  * Make direct start_element() callback (currently used for
244
258
  HTML::SAX::Parser) pass attributes in assoc array, just as
245
259
  emulated start_element() callback does. rel. #356
@@ -272,7 +286,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
272
286
  * Fix a memory leak when duplicating child nodes. #353
273
287
  * Fixed off-by-one bug with nth-last-{child,of-type} CSS selectors when NOT using an+b notation. #354
274
288
  * Fixed passing of non-namespace attributes to SAX::Document#start_element. #356
275
- * Workaround for libxml2 in-context parsing bug. #362
289
+ * Workaround for libxml2 in-context parsing bug. #362
276
290
  * Fixed NodeSet#wrap on nodes within a fragment. #331
277
291
 
278
292
  === 1.4.3 / 2010/07/28
@@ -694,4 +708,3 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
694
708
  * 1 major enhancement
695
709
 
696
710
  * Birthday!
697
-
data/Rakefile CHANGED
@@ -183,8 +183,7 @@ end
183
183
 
184
184
  desc "build a windows gem without all the ceremony."
185
185
  task "gem:windows" => "gem" do
186
- # TODO: 1.8.7-p358, 1.9.3-p194
187
- cross_rubies = ["1.8.7-p330", "1.9.2-p136"]
186
+ cross_rubies = ["1.8.7-p358", "1.9.3-p194"]
188
187
  ruby_cc_version = cross_rubies.collect { |_| _.split("-").first }.join(":") # e.g., "1.8.7:1.9.2"
189
188
  rake_compiler_config_path = "#{ENV['HOME']}/.rake-compiler/config.yml"
190
189
 
data/build_all CHANGED
@@ -31,7 +31,7 @@
31
31
  # end
32
32
  #
33
33
  # - you may also have to hack rubygems.rb to eliminate a reference to
34
- # RUBY_ENGINE
34
+ # RUBY_ENGINE (just comment it out)
35
35
  #
36
36
 
37
37
  HOST=
@@ -71,11 +71,16 @@ if [[ $platform =~ "64" ]] ; then
71
71
  exit 1
72
72
  fi
73
73
  rvm_use 1.8.7
74
- if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-1.8.7-p330/lib/ruby/1.8.7/x86_64-linux/rbconfig.rb ]] ; then
75
- bundle exec rake-compiler cross-ruby VERSION=1.8.7-p330
74
+ if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-1.8.7-p358/lib/ruby/1.8.7/x86_64-linux/rbconfig.rb ]] ; then
75
+
76
+ # if this fails around the purelib.rb thing, try varying the ruby
77
+ # used to run this script, and whether the HOST env var is set
78
+ # below.
79
+
80
+ bundle exec rake-compiler cross-ruby VERSION=1.8.7-p358 # HOST=i386-mingw32
76
81
  fi
77
- if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-1.9.2-p136/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb ]] ; then
78
- bundle exec rake-compiler cross-ruby VERSION=1.9.2-p136
82
+ if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb ]] ; then
83
+ bundle exec rake-compiler cross-ruby VERSION=1.9.3-p194
79
84
  fi
80
85
  bundle exec rake cross
81
86
  bundle exec rake gem:windows
@@ -239,14 +239,17 @@ static void cdata_block(void * ctx, const xmlChar * value, int len)
239
239
 
240
240
  static void processing_instruction(void * ctx, const xmlChar * name, const xmlChar * content)
241
241
  {
242
+ VALUE rb_content;
242
243
  VALUE self = NOKOGIRI_SAX_SELF(ctx);
243
244
  VALUE doc = rb_iv_get(self, "@document");
244
245
 
246
+ rb_content = content ? NOKOGIRI_STR_NEW2(content) : Qnil;
247
+
245
248
  rb_funcall( doc,
246
249
  id_processing_instruction,
247
250
  2,
248
251
  NOKOGIRI_STR_NEW2(name),
249
- NOKOGIRI_STR_NEW2(content)
252
+ rb_content
250
253
  );
251
254
  }
252
255
 
@@ -16,6 +16,7 @@ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
16
16
  # should skip loading xml jars. This is because those are in WEB-INF/lib and
17
17
  # already set in the classpath.
18
18
  unless $LOAD_PATH.to_s.include?("appengine-rack")
19
+ require 'stringio'
19
20
  require 'isorelax.jar'
20
21
  require 'jing.jar'
21
22
  require 'nekohtml.jar'
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.5.6'
3
+ VERSION = '1.5.7.rc1'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -114,6 +114,7 @@ module Nokogiri
114
114
 
115
115
  private
116
116
  def check_encoding(encoding)
117
+ encoding.upcase!
117
118
  raise ArgumentError.new("'#{encoding}' is not a valid encoding") unless ENCODINGS[encoding]
118
119
  end
119
120
  end
@@ -1,6 +1,7 @@
1
1
  #Process.setrlimit(Process::RLIMIT_CORE, Process::RLIM_INFINITY) unless RUBY_PLATFORM =~ /(java|mswin|mingw)/i
2
2
  $VERBOSE = true
3
3
  require 'minitest/autorun'
4
+ require 'minitest/pride'
4
5
  require 'fileutils'
5
6
  require 'tempfile'
6
7
  require 'pp'
@@ -132,6 +132,10 @@ module Nokogiri
132
132
  ]]
133
133
  ], @parser.document.start_elements
134
134
  end
135
+
136
+ def test_empty_processing_instruction
137
+ @parser.parse_memory("<strong>this will segfault<?strong>")
138
+ end
135
139
  end
136
140
  end
137
141
  end
@@ -195,9 +195,11 @@ module Nokogiri
195
195
  def test_to_xhtml
196
196
  doc = "<span>foo<br></span><span>bar</span>"
197
197
  fragment = Nokogiri::HTML::Document.new.fragment(doc)
198
- if !Nokogiri.jruby? && Nokogiri::VERSION_INFO['libxml']['loaded'] >= "2.7.0"
198
+ if Nokogiri.jruby? || Nokogiri::VERSION_INFO['libxml']['loaded'] >= "2.7.0"
199
199
  assert_equal "<span>foo<br /></span><span>bar</span>", fragment.to_xhtml
200
200
  else
201
+ # FIXME: why are we doing this ? this violates the spec,
202
+ # see http://www.w3.org/TR/xhtml1/#C_2
201
203
  assert_equal "<span>foo<br></span><span>bar</span>", fragment.to_xhtml
202
204
  end
203
205
  end
@@ -34,6 +34,29 @@ class TestReader < Nokogiri::TestCase
34
34
  assert_equal [false, false, nil, nil, true, nil], results
35
35
  end
36
36
 
37
+ # Issue #831
38
+ # Make sure that the reader doesn't block reading the entire input
39
+ def test_reader_blocking
40
+ rd, wr = IO.pipe()
41
+ node_out = nil
42
+ t = Thread.start do
43
+ reader = Nokogiri::XML::Reader(rd, 'UTF-8')
44
+ reader.each do |node|
45
+ node_out = node
46
+ break
47
+ end
48
+ end
49
+ sleep(1) # sleep for one second to make sure the reader will actually block for input
50
+ wr.puts "<foo>"
51
+ wr.puts "<bar/>" * 10000
52
+ wr.flush
53
+ res = t.join(5) # wait 5 seconds for the thread to finish
54
+ wr.close
55
+ rd.close
56
+ refute_nil node_out, "Didn't read any nodes, exclude the trivial case"
57
+ refute_nil res, "Reader blocks trying to read the entire stream"
58
+ end
59
+
37
60
  def test_reader_takes_block
38
61
  options = nil
39
62
  Nokogiri::XML::Reader(File.read(XML_FILE), XML_FILE) do |cfg|
@@ -319,12 +342,23 @@ class TestReader < Nokogiri::TestCase
319
342
  end
320
343
 
321
344
  def test_outer_xml
322
- str = "<x><y>hello</y></x>"
323
- reader = Nokogiri::XML::Reader.from_memory(str)
345
+ str = ["<x><y>hello</y></x>", "<y>hello</y>", "hello", "<y/>", "<x/>"]
346
+ reader = Nokogiri::XML::Reader.from_memory(str.first)
324
347
 
325
- reader.read
348
+ xml = []
349
+ reader.map { |node| xml << node.outer_xml }
350
+
351
+ assert_equal str, xml
352
+ end
353
+
354
+ def test_outer_xml_with_empty_nodes
355
+ str = ["<x><y/></x>", "<y/>", "<x/>"]
356
+ reader = Nokogiri::XML::Reader.from_memory(str.first)
357
+
358
+ xml = []
359
+ reader.map { |node| xml << node.outer_xml }
326
360
 
327
- assert_equal str, reader.outer_xml
361
+ assert_equal str, xml
328
362
  end
329
363
 
330
364
  def test_state
@@ -194,8 +194,17 @@ module Nokogiri
194
194
  end
195
195
 
196
196
  def test_parse_io
197
+ call_parse_io_with_encoding 'UTF-8'
198
+ end
199
+
200
+ # issue #828
201
+ def test_parse_io_lower_case_encoding
202
+ call_parse_io_with_encoding 'utf-8'
203
+ end
204
+
205
+ def call_parse_io_with_encoding encoding
197
206
  File.open(XML_FILE, 'rb') { |f|
198
- @parser.parse_io(f, 'UTF-8')
207
+ @parser.parse_io(f, encoding)
199
208
  }
200
209
  assert(@parser.document.cdata_blocks.length > 0)
201
210
  if RUBY_VERSION =~ /^1\.9/
@@ -26,6 +26,30 @@ module Nokogiri
26
26
  assert doc.root
27
27
  end
28
28
 
29
+ # issue #838
30
+ def test_document_with_invalid_prolog
31
+ doc = Nokogiri::XML '<? ?>'
32
+ assert_empty doc.content
33
+ end
34
+
35
+ # issue #837
36
+ def test_document_with_refentity
37
+ doc = Nokogiri::XML '&amp;'
38
+ assert_equal '', doc.content
39
+ end
40
+
41
+ # issue #835
42
+ def test_manually_adding_reference_entities
43
+ d = Nokogiri::XML::Document.new
44
+ root = Nokogiri::XML::Element.new('bar', d)
45
+ txt = Nokogiri::XML::Text.new('foo', d)
46
+ ent = Nokogiri::XML::EntityReference.new(d, '#8217')
47
+ root << txt
48
+ root << ent
49
+ d << root
50
+ assert_match d.to_html, /&#8217;/
51
+ end
52
+
29
53
  def test_document_with_initial_space
30
54
  doc = Nokogiri::XML(" <?xml version='1.0' encoding='utf-8' ?><first \>")
31
55
  assert_equal 2, doc.children.size
@@ -26,7 +26,7 @@ EOF
26
26
  doc = Nokogiri::XML xml
27
27
  lf_node = Nokogiri::XML::EntityReference.new(doc, "#xa")
28
28
  doc.xpath('/item').first.add_child(lf_node)
29
- assert_equal "#xa", doc.xpath('./item').first.child.name
29
+ assert_match doc.to_xml, /&#xa;/
30
30
  end
31
31
  end
32
32
 
@@ -232,14 +232,12 @@ EOF
232
232
  end
233
233
 
234
234
  test_relative_and_absolute_path :test_reader_entity_reference_without_dtdload do
235
- # Make sure that we can parse entity references and include them in the document
236
235
  html = File.read xml_document
237
236
  assert_raises(Nokogiri::XML::SyntaxError) do
238
237
  reader = Nokogiri::XML::Reader html, path do |cfg|
239
238
  cfg.default_xml
240
239
  end
241
- nodes = []
242
- reader.each { |n| nodes << n.value }
240
+ reader.each { |n| n }
243
241
  end
244
242
  end
245
243
  end
@@ -624,6 +624,13 @@ module Nokogiri
624
624
  assert_equal "Yes", address[:domestic]
625
625
  end
626
626
 
627
+ def test_empty_attribute_reading
628
+ node = Nokogiri::XML '<foo empty="" whitespace=" "/>'
629
+
630
+ assert_equal '', node.root['empty']
631
+ assert_equal ' ', node.root['whitespace']
632
+ end
633
+
627
634
  def test_delete
628
635
  address = @xml.xpath('/staff/employee/address').first
629
636
  assert_equal 'Yes', address['domestic']
@@ -804,6 +811,16 @@ module Nokogiri
804
811
  assert_equal '12345678', node.content
805
812
  end
806
813
 
814
+ # issue #839
815
+ def test_encoding_of_copied_nodes
816
+ d1 = Nokogiri::XML('<r><a>&amp;</a></r>')
817
+ d2 = Nokogiri::XML('<r></r>')
818
+ ne = d1.root.xpath('//a').first.dup(1)
819
+ ne.content += "& < & > \" &"
820
+ d2.root << ne
821
+ assert_match d2.to_s, /<a>&amp;&amp; &lt; &amp; &gt; " &amp;<\/a>/
822
+ end
823
+
807
824
  def test_content_after_appending_text
808
825
  doc = Nokogiri::XML '<foo />'
809
826
  node = doc.children.first
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease:
4
+ hash: -959733986
5
+ prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 6
10
- version: 1.5.6
9
+ - 7
10
+ - rc
11
+ - 1
12
+ version: 1.5.7.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Aaron Patterson
@@ -18,7 +20,7 @@ autorequire:
18
20
  bindir: bin
19
21
  cert_chain: []
20
22
 
21
- date: 2012-12-19 00:00:00 Z
23
+ date: 2013-02-22 00:00:00 Z
22
24
  dependencies:
23
25
  - !ruby/object:Gem::Dependency
24
26
  prerelease: false
@@ -33,8 +35,8 @@ dependencies:
33
35
  - 1
34
36
  - 1
35
37
  version: "1.1"
36
- requirement: *id001
37
38
  type: :development
39
+ requirement: *id001
38
40
  - !ruby/object:Gem::Dependency
39
41
  prerelease: false
40
42
  name: hoe-debugging
@@ -49,8 +51,8 @@ dependencies:
49
51
  - 0
50
52
  - 3
51
53
  version: 1.0.3
52
- requirement: *id002
53
54
  type: :development
55
+ requirement: *id002
54
56
  - !ruby/object:Gem::Dependency
55
57
  prerelease: false
56
58
  name: hoe-gemspec
@@ -64,8 +66,8 @@ dependencies:
64
66
  - 1
65
67
  - 0
66
68
  version: "1.0"
67
- requirement: *id003
68
69
  type: :development
70
+ requirement: *id003
69
71
  - !ruby/object:Gem::Dependency
70
72
  prerelease: false
71
73
  name: hoe-git
@@ -79,8 +81,8 @@ dependencies:
79
81
  - 1
80
82
  - 4
81
83
  version: "1.4"
82
- requirement: *id004
83
84
  type: :development
85
+ requirement: *id004
84
86
  - !ruby/object:Gem::Dependency
85
87
  prerelease: false
86
88
  name: mini_portile
@@ -95,8 +97,8 @@ dependencies:
95
97
  - 2
96
98
  - 2
97
99
  version: 0.2.2
98
- requirement: *id005
99
100
  type: :development
101
+ requirement: *id005
100
102
  - !ruby/object:Gem::Dependency
101
103
  prerelease: false
102
104
  name: minitest
@@ -111,8 +113,8 @@ dependencies:
111
113
  - 2
112
114
  - 2
113
115
  version: 2.2.2
114
- requirement: *id006
115
116
  type: :development
117
+ requirement: *id006
116
118
  - !ruby/object:Gem::Dependency
117
119
  prerelease: false
118
120
  name: rake
@@ -126,8 +128,8 @@ dependencies:
126
128
  - 0
127
129
  - 9
128
130
  version: "0.9"
129
- requirement: *id007
130
131
  type: :development
132
+ requirement: *id007
131
133
  - !ruby/object:Gem::Dependency
132
134
  prerelease: false
133
135
  name: rake-compiler
@@ -142,8 +144,8 @@ dependencies:
142
144
  - 8
143
145
  - 0
144
146
  version: 0.8.0
145
- requirement: *id008
146
147
  type: :development
148
+ requirement: *id008
147
149
  - !ruby/object:Gem::Dependency
148
150
  prerelease: false
149
151
  name: racc
@@ -158,8 +160,8 @@ dependencies:
158
160
  - 4
159
161
  - 6
160
162
  version: 1.4.6
161
- requirement: *id009
162
163
  type: :development
164
+ requirement: *id009
163
165
  - !ruby/object:Gem::Dependency
164
166
  prerelease: false
165
167
  name: rexical
@@ -174,8 +176,8 @@ dependencies:
174
176
  - 0
175
177
  - 5
176
178
  version: 1.0.5
177
- requirement: *id010
178
179
  type: :development
180
+ requirement: *id010
179
181
  - !ruby/object:Gem::Dependency
180
182
  prerelease: false
181
183
  name: rdoc
@@ -189,8 +191,8 @@ dependencies:
189
191
  - 3
190
192
  - 10
191
193
  version: "3.10"
192
- requirement: *id011
193
194
  type: :development
195
+ requirement: *id011
194
196
  - !ruby/object:Gem::Dependency
195
197
  prerelease: false
196
198
  name: hoe
@@ -204,8 +206,8 @@ dependencies:
204
206
  - 2
205
207
  - 16
206
208
  version: "2.16"
207
- requirement: *id012
208
209
  type: :development
210
+ requirement: *id012
209
211
  description: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser. Among Nokogiri's\n\
210
212
  many features is the ability to search documents via XPath or CSS3 selectors.\n\n\
211
213
  XML is like violence - if it doesn\xE2\x80\x99t solve your problems, you are not using\n\
@@ -226,40 +228,40 @@ extra_rdoc_files:
226
228
  - Manifest.txt
227
229
  - README.ja.rdoc
228
230
  - README.rdoc
229
- - ext/nokogiri/xml_text.c
230
- - ext/nokogiri/xml_xpath_context.c
231
- - ext/nokogiri/html_sax_push_parser.c
232
- - ext/nokogiri/xml_cdata.c
233
- - ext/nokogiri/html_element_description.c
234
- - ext/nokogiri/xml_comment.c
231
+ - ext/nokogiri/html_sax_parser_context.c
235
232
  - ext/nokogiri/xslt_stylesheet.c
236
- - ext/nokogiri/xml_document_fragment.c
237
- - ext/nokogiri/html_document.c
238
- - ext/nokogiri/xml_sax_parser_context.c
239
- - ext/nokogiri/xml_element_content.c
233
+ - ext/nokogiri/xml_namespace.c
234
+ - ext/nokogiri/xml_node.c
235
+ - ext/nokogiri/xml_attr.c
240
236
  - ext/nokogiri/xml_entity_decl.c
241
237
  - ext/nokogiri/xml_reader.c
242
- - ext/nokogiri/xml_io.c
238
+ - ext/nokogiri/xml_document.c
239
+ - ext/nokogiri/xml_sax_push_parser.c
240
+ - ext/nokogiri/xml_comment.c
241
+ - ext/nokogiri/xml_element_content.c
242
+ - ext/nokogiri/xml_sax_parser_context.c
243
+ - ext/nokogiri/xml_element_decl.c
244
+ - ext/nokogiri/xml_node_set.c
243
245
  - ext/nokogiri/xml_entity_reference.c
244
- - ext/nokogiri/xml_libxml2_hacks.c
245
- - ext/nokogiri/nokogiri.c
246
+ - ext/nokogiri/xml_xpath_context.c
247
+ - ext/nokogiri/xml_document_fragment.c
246
248
  - ext/nokogiri/xml_encoding_handler.c
247
- - ext/nokogiri/html_entity_lookup.c
249
+ - ext/nokogiri/html_sax_push_parser.c
250
+ - ext/nokogiri/xml_text.c
248
251
  - ext/nokogiri/xml_sax_parser.c
249
252
  - ext/nokogiri/xml_schema.c
250
- - ext/nokogiri/xml_namespace.c
251
- - ext/nokogiri/xml_processing_instruction.c
252
- - ext/nokogiri/html_sax_parser_context.c
253
- - ext/nokogiri/xml_document.c
254
- - ext/nokogiri/xml_sax_push_parser.c
255
- - ext/nokogiri/xml_relax_ng.c
256
253
  - ext/nokogiri/xml_dtd.c
257
- - ext/nokogiri/xml_attr.c
258
- - ext/nokogiri/xml_element_decl.c
259
- - ext/nokogiri/xml_syntax_error.c
254
+ - ext/nokogiri/xml_libxml2_hacks.c
260
255
  - ext/nokogiri/xml_attribute_decl.c
261
- - ext/nokogiri/xml_node.c
262
- - ext/nokogiri/xml_node_set.c
256
+ - ext/nokogiri/xml_syntax_error.c
257
+ - ext/nokogiri/xml_io.c
258
+ - ext/nokogiri/xml_relax_ng.c
259
+ - ext/nokogiri/nokogiri.c
260
+ - ext/nokogiri/xml_processing_instruction.c
261
+ - ext/nokogiri/xml_cdata.c
262
+ - ext/nokogiri/html_entity_lookup.c
263
+ - ext/nokogiri/html_element_description.c
264
+ - ext/nokogiri/html_document.c
263
265
  files:
264
266
  - .autotest
265
267
  - .gemtest
@@ -523,79 +525,81 @@ required_ruby_version: !ruby/object:Gem::Requirement
523
525
  required_rubygems_version: !ruby/object:Gem::Requirement
524
526
  none: false
525
527
  requirements:
526
- - - ">="
528
+ - - ">"
527
529
  - !ruby/object:Gem::Version
528
- hash: 3
530
+ hash: 25
529
531
  segments:
530
- - 0
531
- version: "0"
532
+ - 1
533
+ - 3
534
+ - 1
535
+ version: 1.3.1
532
536
  requirements: []
533
537
 
534
538
  rubyforge_project: nokogiri
535
- rubygems_version: 1.8.24
539
+ rubygems_version: 1.8.25
536
540
  signing_key:
537
541
  specification_version: 3
538
542
  summary: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser"
539
543
  test_files:
544
+ - test/test_nokogiri.rb
540
545
  - test/test_memory_leak.rb
541
- - test/xml/test_node_attributes.rb
542
- - test/xml/test_document_fragment.rb
543
- - test/xml/test_node_set.rb
544
- - test/xml/node/test_subclass.rb
545
- - test/xml/node/test_save_options.rb
546
- - test/xml/test_processing_instruction.rb
547
- - test/xml/test_node.rb
548
- - test/xml/test_dtd.rb
549
- - test/xml/test_xinclude.rb
550
- - test/xml/sax/test_parser.rb
551
- - test/xml/sax/test_parser_context.rb
552
- - test/xml/sax/test_push_parser.rb
553
- - test/xml/test_parse_options.rb
546
+ - test/test_convert_xpath.rb
554
547
  - test/xml/test_element_content.rb
555
- - test/xml/test_dtd_encoding.rb
556
- - test/xml/test_syntax_error.rb
557
- - test/xml/test_text.rb
558
- - test/xml/test_node_encoding.rb
559
- - test/xml/test_unparented_node.rb
560
- - test/xml/test_cdata.rb
548
+ - test/xml/test_builder.rb
561
549
  - test/xml/test_element_decl.rb
562
- - test/xml/test_xpath.rb
563
- - test/xml/test_reader_encoding.rb
564
- - test/xml/test_comment.rb
550
+ - test/xml/test_parse_options.rb
551
+ - test/xml/test_dtd_encoding.rb
565
552
  - test/xml/test_attribute_decl.rb
566
- - test/xml/test_document_encoding.rb
567
- - test/xml/test_schema.rb
553
+ - test/xml/test_cdata.rb
554
+ - test/xml/test_document_fragment.rb
555
+ - test/xml/test_dtd.rb
556
+ - test/xml/test_node_reparenting.rb
557
+ - test/xml/test_c14n.rb
568
558
  - test/xml/test_node_inheritance.rb
559
+ - test/xml/test_schema.rb
560
+ - test/xml/node/test_save_options.rb
561
+ - test/xml/node/test_subclass.rb
562
+ - test/xml/test_processing_instruction.rb
563
+ - test/xml/test_attr.rb
569
564
  - test/xml/test_namespace.rb
570
565
  - test/xml/test_relax_ng.rb
571
- - test/xml/test_entity_reference.rb
572
- - test/xml/test_c14n.rb
573
- - test/xml/test_attr.rb
566
+ - test/xml/test_xpath.rb
567
+ - test/xml/test_reader_encoding.rb
568
+ - test/xml/test_node_encoding.rb
569
+ - test/xml/test_node_attributes.rb
570
+ - test/xml/test_text.rb
574
571
  - test/xml/test_document.rb
575
- - test/xml/test_node_reparenting.rb
576
- - test/xml/test_builder.rb
572
+ - test/xml/test_entity_reference.rb
573
+ - test/xml/test_node.rb
574
+ - test/xml/test_document_encoding.rb
575
+ - test/xml/test_unparented_node.rb
576
+ - test/xml/test_syntax_error.rb
577
577
  - test/xml/test_entity_decl.rb
578
- - test/test_convert_xpath.rb
578
+ - test/xml/test_comment.rb
579
+ - test/xml/sax/test_parser.rb
580
+ - test/xml/sax/test_parser_context.rb
581
+ - test/xml/sax/test_push_parser.rb
582
+ - test/xml/test_node_set.rb
583
+ - test/xml/test_xinclude.rb
584
+ - test/test_css_cache.rb
585
+ - test/xslt/test_exception_handling.rb
586
+ - test/xslt/test_custom_functions.rb
587
+ - test/decorators/test_slop.rb
588
+ - test/html/test_builder.rb
579
589
  - test/html/test_document_fragment.rb
590
+ - test/html/test_named_characters.rb
591
+ - test/html/test_element_description.rb
592
+ - test/html/test_node_encoding.rb
593
+ - test/html/test_document.rb
580
594
  - test/html/test_node.rb
595
+ - test/html/test_document_encoding.rb
581
596
  - test/html/sax/test_parser.rb
582
597
  - test/html/sax/test_parser_context.rb
583
- - test/html/test_node_encoding.rb
584
- - test/html/test_named_characters.rb
585
- - test/html/test_document_encoding.rb
586
- - test/html/test_document.rb
587
- - test/html/test_element_description.rb
588
- - test/html/test_builder.rb
589
- - test/test_css_cache.rb
590
- - test/test_encoding_handler.rb
591
- - test/css/test_parser.rb
592
- - test/css/test_xpath_visitor.rb
598
+ - test/test_xslt_transforms.rb
593
599
  - test/css/test_tokenizer.rb
600
+ - test/css/test_parser.rb
594
601
  - test/css/test_nthiness.rb
595
- - test/decorators/test_slop.rb
602
+ - test/css/test_xpath_visitor.rb
603
+ - test/test_encoding_handler.rb
596
604
  - test/test_soap4r_sax.rb
597
- - test/test_nokogiri.rb
598
- - test/xslt/test_custom_functions.rb
599
- - test/xslt/test_exception_handling.rb
600
605
  - test/test_reader.rb
601
- - test/test_xslt_transforms.rb