nokogiri-maglev- 1.5.4.20120815005250 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.ja.rdoc CHANGED
@@ -1,42 +1,59 @@
1
- == 1.5.4 / unreleased
1
+ == 1.5.5 / unreleased
2
2
 
3
3
  * Features
4
4
 
5
- * The "nokogiri" script now has more verbose output when passed the `--rng` option. #675 (Thanks, Dan Radez!)
6
- * Build support on hardened Debian systems that use `-Werror=format-security`. #680.
7
- * Better build support for systems with pkg-config. #584
8
- * Better build support for systems with multiple iconv installations.
5
+ * Much-improved support for JRuby in 1.9 mode! Yay!
9
6
 
10
7
  * Bugfixes
11
8
 
12
- * Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
13
- * Treat '.' as xpath in at() and search(). #690
9
+ * JRuby Nokogiri add_previous_sibling が以前は動いていたのに今は動かない(1.5.0 -> 1.5.1)。 #691 (ありがとう, John Shahid!)
10
+ * JRuby バーションは URL が引数にあたえられると HTML ドキュメントを作れない。 #674 (ありがとう, John Shahid!)
11
+ * JRuby バージョンは HTMLとして nil か "" が与えられると NullPointerException を投げる。 #699
12
+ * JRuby 1.9 モードでエラー, uncaught throw 'encoding_found', が発生する。 #673
13
+ * JRuby で US-ASCII にエンコードされた文字列が正しくないエンコードを返してくる。 #583
14
+ * 512 文字以上が与えられたときに XmlSaxPushParser が IndexOutOfBoundsException を投げる。#567, #615
15
+ * Xpath を評価した結果、空の NodeSet が帰ってくる場合に、NodeSet が持っている Document の decorate に失敗して例外が投げられる。#514
16
+ * JRuby で xpath を namespace 付きで指定した場合に、エラーが発生する。pull request #681 (ありがとう, Piotr Szmielew)
17
+ * JRuby で Nokogiri::XML::Node を継承したクラスを定義すると、namespace が表示されない。 #695
18
+ * JRuby で RDF::RDFXML::Writer をインスタンス化しようとすると NAMESPACE_ERR (org.w3c.dom.DOMException) が発生する. #683
19
+ * JRuby で xpath に namespaces を指定すると例外が発生する. #493
14
20
 
15
- * [MRI, Security] Default parse options for XML documents were
16
- changed to not make network connections during document parsing,
17
- to avoid XXE vulnerability. #693
18
21
 
19
- To re-enable this behavior, the configuration method `nononet` may
20
- be called, like this:
22
+ == 1.5.4 / 2012年6月12日
23
+
24
+ * Features
25
+
26
+ * "nokogiri" コマンドに `--rng` オプションが与えられと、より詳しい説明を表示するようになった。 #675 (ありがとう, Dan Radez!)
27
+ * `-Werror=format-security` CFLAGを使っている hardened な Debian 系 Linux でのビルドをサポート #680.
28
+ * pkg-config ありのシステム上でのよりよいビルドをサポート。 #584
29
+ * 複数の iconv がイストールされているシステムでのよりよいビルドをサポート。
30
+
31
+ * Bugfixes
32
+
33
+ * DocumentFragment をベースにしてコメントノードを作ったときに Segmentation fault する。 #677, #678.
34
+ * at() と search() メソッドで '.' をxpathとして扱う。 #690
35
+
36
+ * [MRI, Security] XML パース時のディフォルトのオプションを nonet に変更。これにより、ディフォルトでは
37
+ ドキュメントパース時にネットワーク接続を行わないようにし、XXE 脆弱性に対応した。#693
38
+
39
+ パース時にネットワークに接続して外部のドキュメントを見にいかせたい場合には、以下のように `nonoet` オプションを設定する:
21
40
 
22
41
  Nokogiri::XML::Document.parse(xml) { |config| config.nononet }
23
42
 
24
- Insert your own joke about double-negatives here.
43
+ ここに、自分ならではの二重否定のジョークをうめこむとなおよし。
25
44
 
26
45
 
27
- == 1.5.3 / 2012-06-01
46
+ == 1.5.3 / 2012年6月1日
28
47
 
29
48
  * Features
30
49
 
31
- * Support for "prefixless" CSS selectors ~, > and + like jQuery
32
- supports. #621, #623. (Thanks, David Lee!)
50
+ * jQuery のような "prefixless" CSS セレクタ, ~ >, + をサポート。#621, #623. (ありがとう, David Lee!)
33
51
  * Attempting to improve installation on homebrew 0.9 (with regards
34
52
  to iconv). Isn't package management convenient?
35
53
 
36
54
  * Bugfixes
37
55
 
38
- * Custom xpath functions with empty nodeset arguments cause a
39
- segfault. #634.
56
+ * カスタム xpath 関数が空の nodeset を引数に含む場合、segfault を起こす。 #634.
40
57
  * Nokogiri::XML::Node#css now works for XML documents with default
41
58
  namespaces when the rule contains attribute selector without
42
59
  namespace.
data/CHANGELOG.rdoc CHANGED
@@ -1,4 +1,25 @@
1
- == 1.5.4 / unreleased
1
+ == 1.5.5 / unreleased
2
+
3
+ * Features
4
+
5
+ * Much-improved support for JRuby in 1.9 mode! Yay!
6
+
7
+ * Bugfixes
8
+
9
+ * Regression in JRuby Nokogiri add_previous_sibling (1.5.0 -> 1.5.1) #691 (Thanks, John Shahid!)
10
+ * JRuby unable to create HTML doc if URL arg provided #674 (Thanks, John Shahid!)
11
+ * JRuby raises NullPointerException when given HTML document is nil or empty string. #699
12
+ * JRuby 1.9 error, uncaught throw 'encoding_found', has been fixed. #673
13
+ * Invalid encoding returned in JRuby with US-ASCII. #583
14
+ * XmlSaxPushParser raises IndexOutOfBoundsException when over 512 characters are given. #567, #615
15
+ * When xpath evaluation returns empty NodeSet, decorating NodeSet's base document raises exception. #514
16
+ * JRuby raises exception when xpath with namespace is specified. pull request #681 (Thanks, Piotr Szmielew)
17
+ * JRuby renders nodes without their namespace when subclassing Node. #695
18
+ * JRuby raises NAMESPACE_ERR (org.w3c.dom.DOMException) while instantiating RDF::RDFXML::Writer. #683
19
+ * JRuby is not able to use namespaces in xpath. #493
20
+
21
+
22
+ == 1.5.4 / 2012-06-12
2
23
 
3
24
  * Features
4
25
 
data/README.ja.rdoc CHANGED
@@ -1,10 +1,10 @@
1
1
  = Nokogiri (鋸)
2
2
 
3
3
  * http://nokogiri.org/
4
- * http://github.com/tenderlove/nokogiri/wikis
5
- * http://github.com/tenderlove/nokogiri/tree/master
4
+ * http://github.com/sparklemotion/nokogiri/wikis
5
+ * http://github.com/sparklemotion/nokogiri/tree/master
6
6
  * http://groups.google.com/group/nokogiri-list
7
- * http://github.com/tenderlove/nokogiri/issues
7
+ * http://github.com/sparklemotion/nokogiri/issues
8
8
 
9
9
  == DESCRIPTION:
10
10
 
@@ -29,9 +29,9 @@ XML/HTMLの高速な解析と探索検索、ならびにCSS3セレクタとXPath
29
29
 
30
30
  * http://groups.google.com/group/nokogiri-list
31
31
 
32
- {バグ報告}[http://github.com/tenderlove/nokogiri/issues]
32
+ {バグ報告}[http://github.com/sparklemotion/nokogiri/issues]
33
33
 
34
- * http://github.com/tenderlove/nokogiri/issues
34
+ * http://github.com/sparklemotion/nokogiri/issues
35
35
 
36
36
  IRCのチャンネルはfreenodeの #nokogiri です。
37
37
 
data/README.rdoc CHANGED
@@ -1,10 +1,10 @@
1
- = Nokogiri {<img src="https://secure.travis-ci.org/tenderlove/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/tenderlove/nokogiri]
1
+ = Nokogiri {<img src="https://secure.travis-ci.org/sparklemotion/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/nokogiri]
2
2
 
3
3
  * http://nokogiri.org
4
- * http://github.com/tenderlove/nokogiri/wikis
5
- * http://github.com/tenderlove/nokogiri/tree/master
4
+ * http://github.com/sparklemotion/nokogiri/wikis
5
+ * http://github.com/sparklemotion/nokogiri/tree/master
6
6
  * http://groups.google.com/group/nokogiri-talk
7
- * http://github.com/tenderlove/nokogiri/issues
7
+ * http://github.com/sparklemotion/nokogiri/issues
8
8
 
9
9
  == DESCRIPTION:
10
10
 
@@ -34,10 +34,10 @@ is available here:
34
34
 
35
35
  * http://groups.google.com/group/nokogiri-talk
36
36
 
37
- The {bug tracker}[http://github.com/tenderlove/nokogiri/issues]
37
+ The {bug tracker}[http://github.com/sparklemotion/nokogiri/issues]
38
38
  is available here:
39
39
 
40
- * http://github.com/tenderlove/nokogiri/issues
40
+ * http://github.com/sparklemotion/nokogiri/issues
41
41
 
42
42
  The IRC channel is #nokogiri on freenode.
43
43
 
@@ -46,9 +46,9 @@ The IRC channel is #nokogiri on freenode.
46
46
  require 'nokogiri'
47
47
  require 'open-uri'
48
48
 
49
- # Get a Nokogiri::HTML:Document for the page we’re interested in...
49
+ # Get a Nokogiri::HTML::Document for the page we’re interested in...
50
50
 
51
- doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
51
+ doc = Nokogiri::HTML(open('http://www.google.com/search?q=sparklemotion'))
52
52
 
53
53
  # Do funky things with it using Nokogiri::XML::Node methods...
54
54
 
@@ -151,7 +151,7 @@ Then run rake:
151
151
 
152
152
  Copyright (c) 2008 - 2012:
153
153
 
154
- * {Aaron Patterson}[http://tenderlovemaking.com]
154
+ * {Aaron Patterson}[http://sparklemotionmaking.com]
155
155
  * {Mike Dalessio}[http://mike.daless.io]
156
156
  * {Charles Nutter}[http://blog.headius.com]
157
157
  * {Sergio Arbeo}[http://www.serabe.com]
data/ROADMAP.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  ## overhaul serialize/pretty printing API
4
4
 
5
- * https://github.com/tenderlove/nokogiri/issues/530
5
+ * https://github.com/sparklemotion/nokogiri/issues/530
6
6
  XHTML formatting can't be turned off
7
7
 
8
- * https://github.com/tenderlove/nokogiri/issues/415
8
+ * https://github.com/sparklemotion/nokogiri/issues/415
9
9
  XML formatting should be no formatting
10
10
 
11
11
 
@@ -16,35 +16,35 @@
16
16
 
17
17
  ## Node should not be Enumerable; and should have a better attributes API
18
18
 
19
- * https://github.com/tenderlove/nokogiri/issues/679
19
+ * https://github.com/sparklemotion/nokogiri/issues/679
20
20
  Mixing in Enumerable has some unintended consequences; plus we want to improve the attributes API
21
21
 
22
- * (closed) https://github.com/tenderlove/nokogiri/issues/666
22
+ * (closed) https://github.com/sparklemotion/nokogiri/issues/666
23
23
  Some ideas for a better attributes API?
24
24
 
25
25
 
26
26
  ## improve CSS query parsing
27
27
 
28
- * https://github.com/tenderlove/nokogiri/issues/528
28
+ * https://github.com/sparklemotion/nokogiri/issues/528
29
29
  support `:not()` with a nontrivial argument, like `:not(div p.c)`
30
30
 
31
- * https://github.com/tenderlove/nokogiri/issues/451
31
+ * https://github.com/sparklemotion/nokogiri/issues/451
32
32
  chained :not pseudoselectors
33
33
 
34
34
  * better jQuery selector support:
35
- * https://github.com/tenderlove/nokogiri/issues/621
36
- * https://github.com/tenderlove/nokogiri/issues/342
37
- * https://github.com/tenderlove/nokogiri/issues/628
38
- * https://github.com/tenderlove/nokogiri/issues/652
39
- * https://github.com/tenderlove/nokogiri/issues/688
35
+ * https://github.com/sparklemotion/nokogiri/issues/621
36
+ * https://github.com/sparklemotion/nokogiri/issues/342
37
+ * https://github.com/sparklemotion/nokogiri/issues/628
38
+ * https://github.com/sparklemotion/nokogiri/issues/652
39
+ * https://github.com/sparklemotion/nokogiri/issues/688
40
40
 
41
- * https://github.com/tenderlove/nokogiri/issues/394
41
+ * https://github.com/sparklemotion/nokogiri/issues/394
42
42
  nth-of-type is wrong, and possibly other selectors as well
43
43
 
44
- * https://github.com/tenderlove/nokogiri/issues/309
44
+ * https://github.com/sparklemotion/nokogiri/issues/309
45
45
  incorrect query being executed
46
46
 
47
- * https://github.com/tenderlove/nokogiri/issues/350
47
+ * https://github.com/sparklemotion/nokogiri/issues/350
48
48
  :has is wrong?
49
49
 
50
50
 
@@ -52,15 +52,15 @@
52
52
 
53
53
  * there are a few tickets about searches not working properly if you
54
54
  use or do not use the context node as part of the search.
55
- - https://github.com/tenderlove/nokogiri/issues/213
56
- - https://github.com/tenderlove/nokogiri/issues/370
57
- - https://github.com/tenderlove/nokogiri/issues/454
58
- - https://github.com/tenderlove/nokogiri/issues/572
55
+ - https://github.com/sparklemotion/nokogiri/issues/213
56
+ - https://github.com/sparklemotion/nokogiri/issues/370
57
+ - https://github.com/sparklemotion/nokogiri/issues/454
58
+ - https://github.com/sparklemotion/nokogiri/issues/572
59
59
 
60
60
 
61
61
  ## Better Syntax for custom XPath function handler
62
62
 
63
- * https://github.com/tenderlove/nokogiri/pull/464
63
+ * https://github.com/sparklemotion/nokogiri/pull/464
64
64
 
65
65
 
66
66
  ## Better Syntax around Node#xpath and NodeSet#xpath
@@ -68,7 +68,7 @@
68
68
  * look at those methods, and use of Node#extract_params in Node#{css,search}
69
69
  * we should standardize on a hash of options for these and other calls
70
70
  * what should NodeSet#xpath return?
71
- * https://github.com/tenderlove/nokogiri/issues/656
71
+ * https://github.com/sparklemotion/nokogiri/issues/656
72
72
 
73
73
  ## Encoding
74
74
 
data/Rakefile CHANGED
@@ -38,8 +38,8 @@ HOE = Hoe.spec 'nokogiri-maglev-' do
38
38
  'nokogiri.gemspec',
39
39
  'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
40
40
  'lib/nokogiri/1.{8,9}',
41
- GENERATED_PARSER,
42
- GENERATED_TOKENIZER
41
+ # GENERATED_PARSER,
42
+ # GENERATED_TOKENIZER
43
43
  ]
44
44
 
45
45
  self.extra_dev_deps += [
@@ -49,11 +49,15 @@ HOE = Hoe.spec 'nokogiri-maglev-' do
49
49
  ["hoe-git", ">= 1.4"],
50
50
  ["mini_portile", ">= 0.2.2"],
51
51
  ["minitest", "~> 2.2.2"],
52
- ["racc", ">= 1.4.6"],
53
52
  ["rake", ">= 0.9"],
54
- ["rake-compiler", "= 0.8.0"],
55
- ["rexical", ">= 1.0.5"],
53
+ ["rake-compiler", "= 0.8.0"]
56
54
  ]
55
+ if ! java?
56
+ self.extra_dev_deps += [
57
+ ["racc", ">= 1.4.6"],
58
+ ["rexical", ">= 1.0.5"]
59
+ ]
60
+ end
57
61
 
58
62
  if java?
59
63
  self.spec_extras = { :platform => 'java' }
@@ -145,8 +149,14 @@ end
145
149
 
146
150
  require 'tasks/test'
147
151
 
152
+ task :java_debug do
153
+ ENV['JAVA_OPTS'] = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y' if java? && ENV['JAVA_DEBUG']
154
+ end
155
+
148
156
  Rake::Task[:test].prerequisites << :compile unless maglev?
157
+ Rake::Task[:test].prerequisites << :java_debug
149
158
  Rake::Task[:test].prerequisites << :check_extra_deps unless (java? or maglev?)
159
+
150
160
  if Hoe.plugins.include?(:debugging)
151
161
  ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
152
162
  Rake::Task["test:#{task_name}"].prerequisites << :compile
data/Y_U_NO_GEMSPEC.md CHANGED
@@ -16,9 +16,9 @@ OHAI! Thank you for asking this question!
16
16
  Team Nokogiri gets asked this pretty frequently. Just a sample from
17
17
  the historical record:
18
18
 
19
- * [Issue #274](https://github.com/tenderlove/nokogiri/issues/274)
20
- * [Issue #371](https://github.com/tenderlove/nokogiri/issues/371)
21
- * [A commit removing nokogiri.gemspec](https://github.com/tenderlove/nokogiri/commit/7f17a643a05ca381d65131515b54d4a3a61ca2e1#commitcomment-667477)
19
+ * [Issue #274](https://github.com/sparklemotion/nokogiri/issues/274)
20
+ * [Issue #371](https://github.com/sparklemotion/nokogiri/issues/371)
21
+ * [A commit removing nokogiri.gemspec](https://github.com/sparklemotion/nokogiri/commit/7f17a643a05ca381d65131515b54d4a3a61ca2e1#commitcomment-667477)
22
22
  * [A nokogiri-talk thread](http://groups.google.com/group/nokogiri-talk/browse_thread/thread/4706b002e492d23f)
23
23
  * [Another nokogiri-talk thread](http://groups.google.com/group/nokogiri-talk/browse_thread/thread/0b201bb80ea3eea0)
24
24
 
@@ -1331,8 +1331,8 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1331
1331
  return DOC_RUBY_OBJECT(node->doc);
1332
1332
 
1333
1333
  /* It's OK if the node doesn't have a fully-realized document (as in XML::Reader). */
1334
- /* see https://github.com/tenderlove/nokogiri/issues/95 */
1335
- /* and https://github.com/tenderlove/nokogiri/issues/439 */
1334
+ /* see https://github.com/sparklemotion/nokogiri/issues/95 */
1335
+ /* and https://github.com/sparklemotion/nokogiri/issues/439 */
1336
1336
  doc = node->doc;
1337
1337
  if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
1338
1338
  node_has_a_document = DOC_RUBY_OBJECT_TEST(doc);
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.9
3
+ # This file is automatically generated by Racc 1.4.8
4
4
  # from Racc grammer file "".
5
5
  #
6
6
 
@@ -180,7 +180,7 @@ module Nokogiri
180
180
  m = chunk.match(/(<meta\s)(.*)(charset\s*=\s*([\w-]+))(.*)/i) and
181
181
  return m[4]
182
182
  catch(:encoding_found) {
183
- Nokogiri::HTML::SAX::Parser.new(JumpSAXHandler.new(:encoding_found.to_s)).parse(chunk)
183
+ Nokogiri::HTML::SAX::Parser.new(JumpSAXHandler.new(:encoding_found)).parse(chunk)
184
184
  nil
185
185
  }
186
186
  else
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.5.4'
3
+ VERSION = '1.5.5'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -150,7 +150,7 @@ module Nokogiri
150
150
  sets = paths.map { |path|
151
151
  ctx = XPathContext.new(self)
152
152
  ctx.register_namespaces(ns)
153
- path = path.gsub(/\/xmlns:/,'/:') unless Nokogiri.uses_libxml?
153
+ path = path.gsub(/xmlns:/, ' :') unless Nokogiri.uses_libxml?
154
154
 
155
155
  binds.each do |key,value|
156
156
  ctx.register_variable key.to_s, value
@@ -23,7 +23,7 @@ module Nokogiri
23
23
  # Save builder created document
24
24
  AS_BUILDER = 128
25
25
  # the default for XML documents
26
- DEFAULT_XML = AS_XML # https://github.com/tenderlove/nokogiri/issues/#issue/415
26
+ DEFAULT_XML = AS_XML # https://github.com/sparklemotion/nokogiri/issues/#issue/415
27
27
  # the default for HTML document
28
28
  DEFAULT_HTML = NO_DECLARATION | NO_EMPTY_TAGS | AS_HTML
29
29
  else
@@ -85,6 +85,17 @@ module Nokogiri
85
85
  assert_equal @html.to_s, html.to_s
86
86
  end
87
87
 
88
+ def test_document_parse_method_with_url
89
+ require 'open-uri'
90
+ begin
91
+ html = open('http://google.com').read
92
+ rescue
93
+ skip("This test needs the internet. Skips if no internet available.")
94
+ end
95
+ doc = Nokogiri::HTML html ,"http:/foobar.foobar/"
96
+ refute_empty doc.to_s, "Document should not be empty"
97
+ end
98
+
88
99
  ###
89
100
  # Nokogiri::HTML returns an empty Document when given a blank string GH#11
90
101
  def test_empty_string_returns_empty_doc
@@ -506,6 +517,12 @@ eohtml
506
517
  assert @html.serialize
507
518
  assert @html.to_html
508
519
  end
520
+
521
+ def test_empty_document
522
+ # empty document should return "" #699
523
+ assert_equal "", Nokogiri::HTML.parse(nil).text
524
+ assert_equal "", Nokogiri::HTML.parse("").text
525
+ end
509
526
  end
510
527
  end
511
528
  end
@@ -268,7 +268,7 @@ module Nokogiri
268
268
  assert_equal 44, @xml.validate.length
269
269
  else
270
270
  xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE) {|cfg| cfg.dtdvalid}
271
- assert_equal 37, xml.validate.length
271
+ assert_equal 40, xml.validate.length
272
272
  end
273
273
  end
274
274
 
data/test/xml/test_dtd.rb CHANGED
@@ -14,12 +14,8 @@ module Nokogiri
14
14
  end
15
15
 
16
16
  def test_external_id
17
- if Nokogiri.uses_libxml?
18
- xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar"><foo />')
19
- else
20
- xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar" ""><foo />')
21
- end
22
- assert dtd = xml.internal_subset
17
+ xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar" ""><foo />')
18
+ assert dtd = xml.internal_subset, 'no internal subset'
23
19
  assert_equal 'bar', dtd.external_id
24
20
  end
25
21
 
@@ -74,7 +70,7 @@ module Nokogiri
74
70
  else
75
71
  xml = Nokogiri::XML(File.open(XML_FILE)) {|cfg| cfg.dtdvalid}
76
72
  list = xml.internal_subset.validate xml
77
- assert_equal 37, list.length
73
+ assert_equal 40, list.length
78
74
  end
79
75
  end
80
76
 
@@ -17,5 +17,219 @@ module Nokogiri
17
17
  100.times { EntityReference.new(@xml, 'foo') }
18
18
  end
19
19
  end
20
+
21
+ module Common
22
+ PATH = 'test/files/test_document_url/'
23
+
24
+ attr_accessor :path, :parser
25
+
26
+ def xml_document
27
+ File.join path, 'document.xml'
28
+ end
29
+
30
+ def self.included base
31
+ def base.test_relative_and_absolute_path method_name, &block
32
+ test_relative_path method_name, &block
33
+ test_absolute_path method_name, &block
34
+ end
35
+
36
+ def base.test_absolute_path method_name, &block
37
+ define_method "#{method_name}_with_absolute_path" do
38
+ self.path = "#{File.expand_path PATH}/"
39
+ instance_eval(&block)
40
+ end
41
+ end
42
+
43
+ def base.test_relative_path method_name, &block
44
+ define_method method_name do
45
+ self.path = PATH
46
+ instance_eval(&block)
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ class TestDOMEntityReference < Nokogiri::TestCase
53
+ include Common
54
+
55
+ def setup
56
+ super
57
+ @parser = Nokogiri::XML::Document
58
+ end
59
+
60
+ test_relative_and_absolute_path :test_dom_entity_reference_with_dtdloda do
61
+ # Make sure that we can parse entity references and include them in the document
62
+ html = File.read xml_document
63
+ doc = @parser.parse html, path do |cfg|
64
+ cfg.default_xml
65
+ cfg.dtdload
66
+ cfg.noent
67
+ end
68
+ assert_equal [], doc.errors
69
+ assert_equal "foobar", doc.xpath('//blah').text
70
+ end
71
+
72
+ test_relative_and_absolute_path :test_dom_entity_reference_with_dtdvalid do
73
+ # Make sure that we can parse entity references and include them in the document
74
+ html = File.read xml_document
75
+ doc = @parser.parse html, path do |cfg|
76
+ cfg.default_xml
77
+ cfg.dtdvalid
78
+ cfg.noent
79
+ end
80
+ assert_equal [], doc.errors
81
+ assert_equal "foobar", doc.xpath('//blah').text
82
+ end
83
+
84
+ test_absolute_path :test_dom_dtd_loading_with_absolute_path do
85
+ # Make sure that we can parse entity references and include them in the document
86
+ html = %Q[<?xml version="1.0" encoding="UTF-8" ?>
87
+ <!DOCTYPE document SYSTEM "#{path}/document.dtd">
88
+ <document>
89
+ <body>&bar;</body>
90
+ </document>
91
+ ]
92
+ doc = @parser.parse html, xml_document do |cfg|
93
+ cfg.default_xml
94
+ cfg.dtdvalid
95
+ cfg.noent
96
+ end
97
+ assert_equal [], doc.errors
98
+ assert_equal "foobar", doc.xpath('//blah').text
99
+ end
100
+
101
+ test_relative_and_absolute_path :test_dom_entity_reference_with_io do
102
+ # Make sure that we can parse entity references and include them in the document
103
+ html = File.open xml_document
104
+ doc = @parser.parse html, nil do |cfg|
105
+ cfg.default_xml
106
+ cfg.dtdload
107
+ cfg.noent
108
+ end
109
+ assert_equal [], doc.errors
110
+ assert_equal "foobar", doc.xpath('//blah').text
111
+ end
112
+
113
+ test_relative_and_absolute_path :test_dom_entity_reference_without_noent do
114
+ # Make sure that we don't include entity references unless NOENT is set to true
115
+ html = File.read xml_document
116
+ doc = @parser.parse html, path do |cfg|
117
+ cfg.default_xml
118
+ cfg.dtdload
119
+ end
120
+ assert_equal [], doc.errors
121
+ assert_kind_of Nokogiri::XML::EntityReference, doc.xpath('//body').first.children.first
122
+ end
123
+
124
+ test_relative_and_absolute_path :test_dom_entity_reference_without_dtdload do
125
+ # Make sure that we don't include entity references unless NOENT is set to true
126
+ html = File.read xml_document
127
+ doc = @parser.parse html, path do |cfg|
128
+ cfg.default_xml
129
+ end
130
+ assert_kind_of Nokogiri::XML::EntityReference, doc.xpath('//body').first.children.first
131
+ if Nokogiri.uses_libxml?
132
+ assert_equal ["Entity 'bar' not defined"], doc.errors.map(&:to_s)
133
+ end
134
+ end
135
+
136
+ test_relative_and_absolute_path :test_document_dtd_loading_with_nonet do
137
+ # Make sure that we don't include remote entities unless NOENT is set to true
138
+ html = %Q[<?xml version="1.0" encoding="UTF-8" ?>
139
+ <!DOCTYPE document SYSTEM "http://foo.bar.com/">
140
+ <document>
141
+ <body>&bar;</body>
142
+ </document>
143
+ ]
144
+ doc = @parser.parse html, path do |cfg|
145
+ cfg.default_xml
146
+ cfg.dtdload
147
+ end
148
+ assert_kind_of Nokogiri::XML::EntityReference, doc.xpath('//body').first.children.first
149
+ if Nokogiri.uses_libxml?
150
+ assert_equal ["Attempt to load network entity http://foo.bar.com/", "Entity 'bar' not defined"], doc.errors.map(&:to_s)
151
+ else
152
+ assert_equal ["Attempt to load network entity http://foo.bar.com/"], doc.errors.map(&:to_s)
153
+ end
154
+ end
155
+ # TODO: can we retreive a resource pointing to localhost when NONET is set to true ?
156
+ end
157
+
158
+ class TestSaxEntityReference < Nokogiri::SAX::TestCase
159
+ include Common
160
+
161
+ def setup
162
+ super
163
+ @parser = XML::SAX::Parser.new(Doc.new) do |ctx|
164
+ ctx.replace_entities = true
165
+ end
166
+ end
167
+
168
+ test_relative_and_absolute_path :test_sax_entity_reference do
169
+ # Make sure that we can parse entity references and include them in the document
170
+ html = File.read xml_document
171
+ @parser.parse html
172
+ refute_nil @parser.document.errors
173
+ assert_equal ["Entity 'bar' not defined"], @parser.document.errors.map(&:to_s).map(&:strip)
174
+ end
175
+
176
+ test_relative_and_absolute_path :test_more_sax_entity_reference do
177
+ # Make sure that we don't include entity references unless NOENT is set to true
178
+ html = %Q[<?xml version="1.0" encoding="UTF-8" ?>
179
+ <!DOCTYPE document SYSTEM "http://foo.bar.com/">
180
+ <document>
181
+ <body>&bar;</body>
182
+ </document>
183
+ ]
184
+ @parser.parse html
185
+ refute_nil @parser.document.errors
186
+ assert_equal ["Entity 'bar' not defined"], @parser.document.errors.map(&:to_s).map(&:strip)
187
+ end
188
+ end
189
+
190
+ class TestReaderEntityReference < Nokogiri::TestCase
191
+ include Common
192
+
193
+ def setup
194
+ super
195
+ end
196
+
197
+ test_relative_and_absolute_path :test_reader_entity_reference do
198
+ # Make sure that we can parse entity references and include them in the document
199
+ html = File.read xml_document
200
+ reader = Nokogiri::XML::Reader html, path do |cfg|
201
+ cfg.default_xml
202
+ cfg.dtdload
203
+ cfg.noent
204
+ end
205
+ nodes = []
206
+ reader.each { |n| nodes << n.value }
207
+ assert_equal ['foobar'], nodes.compact.map(&:strip).reject(&:empty?)
208
+ end
209
+
210
+ test_relative_and_absolute_path :test_reader_entity_reference_without_noent do
211
+ # Make sure that we can parse entity references and include them in the document
212
+ html = File.read xml_document
213
+ reader = Nokogiri::XML::Reader html, path do |cfg|
214
+ cfg.default_xml
215
+ cfg.dtdload
216
+ end
217
+ nodes = []
218
+ reader.each { |n| nodes << n.value }
219
+ assert_equal [], nodes.compact.map(&:strip).reject(&:empty?)
220
+ end
221
+
222
+ test_relative_and_absolute_path :test_reader_entity_reference_without_dtdload do
223
+ # Make sure that we can parse entity references and include them in the document
224
+ html = File.read xml_document
225
+ assert_raises(Nokogiri::XML::SyntaxError) do
226
+ reader = Nokogiri::XML::Reader html, path do |cfg|
227
+ cfg.default_xml
228
+ end
229
+ nodes = []
230
+ reader.each { |n| nodes << n.value }
231
+ end
232
+ end
233
+ end
20
234
  end
21
235
  end
@@ -156,6 +156,7 @@ module Nokogiri
156
156
  @doc.at_xpath("/root/a1/text()").content.must_equal "First nodehello"
157
157
  end
158
158
  end
159
+
159
160
  describe "#replace" do
160
161
  it "merges the Text node with adjacent Text nodes" do
161
162
  @doc.at_xpath("/root/a3/bx").replace Nokogiri::XML::Text.new('hello', @doc)
@@ -247,6 +248,13 @@ module Nokogiri
247
248
  assert_equal "foo <p></p> bartext node", xml.root.children.to_html
248
249
  end
249
250
 
251
+ it 'should remove the child node after the operation' do
252
+ fragment = Nokogiri::HTML::DocumentFragment.parse("a<a>b</a>")
253
+ node = fragment.children.last
254
+ node.add_previous_sibling node.children
255
+ assert_empty node.children, "should have no childrens"
256
+ end
257
+
250
258
  describe "with a text node before" do
251
259
  it "should not defensively dup the 'before' text node" do
252
260
  xml = Nokogiri::XML %Q(<root>before<p></p>after</root>)
@@ -321,7 +329,7 @@ module Nokogiri
321
329
 
322
330
  describe "unlinking a node and then reparenting it" do
323
331
  it "not blow up" do
324
- # see http://github.com/tenderlove/nokogiri/issues#issue/22
332
+ # see http://github.com/sparklemotion/nokogiri/issues#issue/22
325
333
  10.times do
326
334
  begin
327
335
  doc = Nokogiri::XML <<-EOHTML
@@ -217,7 +217,7 @@ module Nokogiri
217
217
  end
218
218
 
219
219
  def test_custom_xpath_handler_with_args_under_gc_pressure
220
- # see http://github.com/tenderlove/nokogiri/issues/#issue/345
220
+ # see http://github.com/sparklemotion/nokogiri/issues/#issue/345
221
221
  tool_inspector = Class.new do
222
222
  def name_equals(nodeset, name, *args)
223
223
  nodeset.all? do |node|
@@ -263,6 +263,33 @@ module Nokogiri
263
263
  }.new)
264
264
  assert_equal foo, doc.xpath("//foo")
265
265
  end
266
+
267
+ def test_node_set_should_be_decorated
268
+ # "called decorate on nill" exception in JRuby issue#514
269
+ process_output= <<END
270
+ <test>
271
+ <track type="Image">
272
+ <Format>LZ77</Format>
273
+ </test>
274
+ END
275
+ doc = Nokogiri::XML.parse(process_output)
276
+ node = doc.xpath(%{//track[@type='Video']})
277
+ assert_equal "[]", node.xpath("Format").inspect
278
+ end
279
+
280
+ def test_very_specific_xml_xpath_making_problems_in_jruby
281
+ # manually merges pull request #681
282
+ xml_string = %q{<?xml version="1.0" encoding="UTF-8"?>
283
+ <ONIXMessage xmlns:elibri="http://elibri.com.pl/ns/extensions" release="3.0" xmlns="http://www.editeur.org/onix/3.0/reference">
284
+ <Product>
285
+ <RecordReference>a</RecordReference>
286
+ </Product>
287
+ </ONIXMessage>}
288
+
289
+ xml_doc = Nokogiri::XML(xml_string)
290
+ onix = xml_doc.children.first
291
+ assert_equal 'a', onix.at_xpath('xmlns:Product').at_xpath('xmlns:RecordReference').text
292
+ end
266
293
  end
267
294
  end
268
295
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri-maglev-
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4.20120815005250
4
+ version: 1.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,7 +16,7 @@ date: 2012-08-14 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: hoe-bundler
19
- requirement: &70249603047560 !ruby/object:Gem::Requirement
19
+ requirement: &69853301411900 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '1.1'
25
25
  type: :development
26
26
  prerelease: false
27
- version_requirements: *70249603047560
27
+ version_requirements: *69853301411900
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: hoe-debugging
30
- requirement: &70249603045740 !ruby/object:Gem::Requirement
30
+ requirement: &69853301410160 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: 1.0.3
36
36
  type: :development
37
37
  prerelease: false
38
- version_requirements: *70249603045740
38
+ version_requirements: *69853301410160
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: hoe-gemspec
41
- requirement: &70249603044800 !ruby/object:Gem::Requirement
41
+ requirement: &69853301409220 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: '1.0'
47
47
  type: :development
48
48
  prerelease: false
49
- version_requirements: *70249603044800
49
+ version_requirements: *69853301409220
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: hoe-git
52
- requirement: &70249603043820 !ruby/object:Gem::Requirement
52
+ requirement: &69853301408220 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: '1.4'
58
58
  type: :development
59
59
  prerelease: false
60
- version_requirements: *70249603043820
60
+ version_requirements: *69853301408220
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: mini_portile
63
- requirement: &70249603042500 !ruby/object:Gem::Requirement
63
+ requirement: &69853301406940 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: 0.2.2
69
69
  type: :development
70
70
  prerelease: false
71
- version_requirements: *70249603042500
71
+ version_requirements: *69853301406940
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: minitest
74
- requirement: &70249603041740 !ruby/object:Gem::Requirement
74
+ requirement: &69853301406100 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ~>
@@ -79,43 +79,43 @@ dependencies:
79
79
  version: 2.2.2
80
80
  type: :development
81
81
  prerelease: false
82
- version_requirements: *70249603041740
82
+ version_requirements: *69853301406100
83
83
  - !ruby/object:Gem::Dependency
84
- name: racc
85
- requirement: &70249603040980 !ruby/object:Gem::Requirement
84
+ name: rake
85
+ requirement: &69853301405400 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
89
89
  - !ruby/object:Gem::Version
90
- version: 1.4.6
90
+ version: '0.9'
91
91
  type: :development
92
92
  prerelease: false
93
- version_requirements: *70249603040980
93
+ version_requirements: *69853301405400
94
94
  - !ruby/object:Gem::Dependency
95
- name: rake
96
- requirement: &70249603040300 !ruby/object:Gem::Requirement
95
+ name: rake-compiler
96
+ requirement: &69853301404680 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - ! '>='
99
+ - - =
100
100
  - !ruby/object:Gem::Version
101
- version: '0.9'
101
+ version: 0.8.0
102
102
  type: :development
103
103
  prerelease: false
104
- version_requirements: *70249603040300
104
+ version_requirements: *69853301404680
105
105
  - !ruby/object:Gem::Dependency
106
- name: rake-compiler
107
- requirement: &70249603101660 !ruby/object:Gem::Requirement
106
+ name: racc
107
+ requirement: &69853301468460 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
- - - =
110
+ - - ! '>='
111
111
  - !ruby/object:Gem::Version
112
- version: 0.8.0
112
+ version: 1.4.6
113
113
  type: :development
114
114
  prerelease: false
115
- version_requirements: *70249603101660
115
+ version_requirements: *69853301468460
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: rexical
118
- requirement: &70249603100880 !ruby/object:Gem::Requirement
118
+ requirement: &69853301467720 !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
121
121
  - - ! '>='
@@ -123,10 +123,10 @@ dependencies:
123
123
  version: 1.0.5
124
124
  type: :development
125
125
  prerelease: false
126
- version_requirements: *70249603100880
126
+ version_requirements: *69853301467720
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: rdoc
129
- requirement: &70249603100140 !ruby/object:Gem::Requirement
129
+ requirement: &69853301466920 !ruby/object:Gem::Requirement
130
130
  none: false
131
131
  requirements:
132
132
  - - ~>
@@ -134,10 +134,10 @@ dependencies:
134
134
  version: '3.10'
135
135
  type: :development
136
136
  prerelease: false
137
- version_requirements: *70249603100140
137
+ version_requirements: *69853301466920
138
138
  - !ruby/object:Gem::Dependency
139
139
  name: hoe
140
- requirement: &70249603099380 !ruby/object:Gem::Requirement
140
+ requirement: &69853301466200 !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements:
143
143
  - - ~>
@@ -145,7 +145,7 @@ dependencies:
145
145
  version: '2.16'
146
146
  type: :development
147
147
  prerelease: false
148
- version_requirements: *70249603099380
148
+ version_requirements: *69853301466200
149
149
  description: ! 'Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among Nokogiri''s
150
150
 
151
151
  many features is the ability to search documents via XPath or CSS3 selectors.
@@ -202,9 +202,9 @@ extra_rdoc_files:
202
202
  - ext/nokogiri/xml_processing_instruction.c
203
203
  - ext/nokogiri/xml_text.c
204
204
  - ext/nokogiri/xml_xpath_context.c
205
- - ext/nokogiri/xml_node.c
206
205
  - ext/nokogiri/xml_document.c
207
206
  - ext/nokogiri/nokogiri.c
207
+ - ext/nokogiri/xml_node.c
208
208
  files:
209
209
  - .autotest
210
210
  - .gemtest
@@ -482,9 +482,9 @@ test_files:
482
482
  - test/html/test_node_encoding.rb
483
483
  - test/html/test_builder.rb
484
484
  - test/html/test_element_description.rb
485
- - test/html/test_document.rb
486
485
  - test/html/test_document_fragment.rb
487
486
  - test/html/test_node.rb
487
+ - test/html/test_document.rb
488
488
  - test/test_convert_xpath.rb
489
489
  - test/test_css_cache.rb
490
490
  - test/test_encoding_handler.rb
@@ -496,12 +496,10 @@ test_files:
496
496
  - test/xml/sax/test_push_parser.rb
497
497
  - test/xml/test_attribute_decl.rb
498
498
  - test/xml/test_comment.rb
499
- - test/xml/test_dtd.rb
500
499
  - test/xml/test_dtd_encoding.rb
501
500
  - test/xml/test_element_content.rb
502
501
  - test/xml/test_element_decl.rb
503
502
  - test/xml/test_entity_decl.rb
504
- - test/xml/test_entity_reference.rb
505
503
  - test/xml/test_node_encoding.rb
506
504
  - test/xml/test_processing_instruction.rb
507
505
  - test/xml/test_relax_ng.rb
@@ -515,17 +513,19 @@ test_files:
515
513
  - test/xml/test_namespace.rb
516
514
  - test/xml/test_node_attributes.rb
517
515
  - test/xml/test_node_inheritance.rb
518
- - test/xml/test_node_reparenting.rb
519
516
  - test/xml/test_reader_encoding.rb
520
517
  - test/xml/test_text.rb
521
518
  - test/xml/test_unparented_node.rb
522
519
  - test/xml/test_xinclude.rb
523
- - test/xml/test_xpath.rb
524
- - test/xml/test_document.rb
525
520
  - test/xml/test_document_fragment.rb
526
521
  - test/xml/test_node_set.rb
527
522
  - test/xml/test_parse_options.rb
528
523
  - test/xml/test_node.rb
524
+ - test/xml/test_dtd.rb
525
+ - test/xml/test_entity_reference.rb
526
+ - test/xml/test_node_reparenting.rb
527
+ - test/xml/test_xpath.rb
528
+ - test/xml/test_document.rb
529
529
  - test/xslt/test_exception_handling.rb
530
530
  - test/xslt/test_custom_functions.rb
531
531
  - test/test_nokogiri.rb