nokogiri 1.5.3.rc3-x86-mswin32-60 → 1.5.3.rc4-x86-mswin32-60

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,5 +1,9 @@
1
1
  == 1.5.3 / unreleased
2
2
 
3
+ * Features
4
+
5
+ * Support for "prefixless" CSS selectors ~, > and + like jQuery supports. #621, #623. (Thanks, David Lee!)
6
+
3
7
  * Bugfixes
4
8
 
5
9
  * Custom xpath functions with empty nodeset arguments cause a segfault. #634.
@@ -8,6 +12,11 @@
8
12
  namespace.
9
13
  * Fixed marshalling bugs around how arguments are passed to (and
10
14
  returned from) XSLT custom xpath functions. #640.
15
+ * Nokogiri::XML::Reader#outer_xml がJRubyで正しく動作しない #617
16
+ * Nokogiri::XML::Attribute が JRuby 上で nil namespace を返す #647
17
+ * Nokogiri::XML::Node#namespace= メソッドが JRuby 上で prefix が無い namespace を設定できない #648
18
+ * JRuby 1.9 モードで rake を実行するとデッドロックを引き起こす #571
19
+ * HTML::Document#meta_encoding does not raise exception on docs with malformed content-type. #655
11
20
 
12
21
 
13
22
  == 1.5.2 / 2012-03-09
@@ -1,5 +1,9 @@
1
1
  == 1.5.3 / unreleased
2
2
 
3
+ * Features
4
+
5
+ * Support for "prefixless" CSS selectors ~, > and + like jQuery supports. #621, #623. (Thanks, David Lee!)
6
+
3
7
  * Bugfixes
4
8
 
5
9
  * Custom xpath functions with empty nodeset arguments cause a segfault. #634.
@@ -8,6 +12,11 @@
8
12
  namespace.
9
13
  * Fixed marshalling bugs around how arguments are passed to (and
10
14
  returned from) XSLT custom xpath functions. #640.
15
+ * Nokogiri::XML::Reader#outer_xml is broken in JRuby #617
16
+ * Nokogiri::XML::Attribute on JRuby returns a nil namespace #647
17
+ * Nokogiri::XML::Node#namespace= cannot set a namespace without a prefix on JRuby #648
18
+ * JRuby 1.9 mode causes dead lock while running rake #571
19
+ * HTML::Document#meta_encoding does not raise exception on docs with malformed content-type. #655
11
20
 
12
21
 
13
22
  == 1.5.2 / 2012-03-09
@@ -439,7 +448,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
439
448
  * Nokogiri::HTML.fragment will properly handle text only nodes (LH #43)
440
449
  * Nokogiri::XML::Node#before will prepend text nodes (LH #44)
441
450
  * Nokogiri::XML::Node#after will append text nodes
442
- * Nokogiri::XML::Node#search automatically registers root namepsaces (LH #42)
451
+ * Nokogiri::XML::Node#search automatically registers root namespaces (LH #42)
443
452
  * Nokogiri::XML::NodeSet#search automatically registers namespaces
444
453
  * Nokogiri::HTML::NamedCharacters delegates to libxml2
445
454
  * Nokogiri::XML::Node#[] can take a symbol (LH #48)
@@ -559,7 +568,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
559
568
 
560
569
  * Bugfixes
561
570
 
562
- * Changed memory mangement from weak refs to document refs
571
+ * Changed memory management from weak refs to document refs
563
572
  * Plugged some memory leaks
564
573
  * Builder blocks can call methods from surrounding contexts
565
574
 
@@ -58,7 +58,6 @@ ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java
58
58
  ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java
59
59
  ext/java/nokogiri/internals/NokogiriXsltErrorListener.java
60
60
  ext/java/nokogiri/internals/ParserContext.java
61
- ext/java/nokogiri/internals/PushInputStream.java
62
61
  ext/java/nokogiri/internals/ReaderNode.java
63
62
  ext/java/nokogiri/internals/SaveContextVisitor.java
64
63
  ext/java/nokogiri/internals/SchemaErrorHandler.java
data/ROADMAP.md CHANGED
@@ -26,6 +26,7 @@
26
26
  * https://github.com/tenderlove/nokogiri/issues/621
27
27
  * https://github.com/tenderlove/nokogiri/issues/342
28
28
  * https://github.com/tenderlove/nokogiri/issues/628
29
+ * https://github.com/tenderlove/nokogiri/issues/652
29
30
 
30
31
  * https://github.com/tenderlove/nokogiri/issues/394
31
32
  nth-of-type is wrong, and possibly other selectors as well
@@ -52,12 +53,22 @@
52
53
  * https://github.com/tenderlove/nokogiri/pull/464
53
54
 
54
55
 
56
+ ## Better Syntax around Node#xpath and NodeSet#xpath
57
+
58
+ * look at those methods, and use of Node#extract_params in Node#{css,search}
59
+ * we should standardize on a hash of options for these and other calls
60
+ * what should NodeSet#xpath return?
61
+ * https://github.com/tenderlove/nokogiri/issues/656
62
+
55
63
  ## Encoding
56
64
 
57
65
  We have a lot of issues open around encoding. Is this really an issue?
58
66
  Somebody who knows something about encoding, and cares, should point
59
67
  this one.
60
68
 
69
+ * Extract EncodingReader as a real object that can be injected
70
+ https://groups.google.com/forum/#!msg/nokogiri-talk/arJeAtMqvkg/tGihB-iBRSAJ
71
+
61
72
 
62
73
  ## Reader
63
74
 
@@ -33,8 +33,8 @@ Thank you so much!
33
33
 
34
34
  Hello!
35
35
 
36
- Thanks for asking this question! Your request for help will not go
37
- unanswered!
36
+ Thanks for asking this question! Your request for assistance using
37
+ Nokogiri will not go unanswered!
38
38
 
39
39
  However, Nokogiri's Github Issues is reserved for reporting bugs or
40
40
  submitting patches. If you ask your question on the mailing list, Team
@@ -25,7 +25,7 @@ int io_read_callback(void * ctx, char * buffer, int len) {
25
25
  safe_len = str_len > (size_t)len ? (size_t)len : str_len;
26
26
  memcpy(buffer, StringValuePtr(string), safe_len);
27
27
 
28
- return safe_len;
28
+ return (int)safe_len;
29
29
  }
30
30
 
31
31
  VALUE write_check(VALUE *args) {
@@ -11,13 +11,10 @@ VALUE cNokogiriXmlNamespace ;
11
11
  static VALUE prefix(VALUE self)
12
12
  {
13
13
  xmlNsPtr ns;
14
- xmlDocPtr doc;
15
14
 
16
15
  Data_Get_Struct(self, xmlNs, ns);
17
16
  if(!ns->prefix) return Qnil;
18
17
 
19
- Data_Get_Struct(rb_iv_get(self, "@document"), xmlDoc, doc);
20
-
21
18
  return NOKOGIRI_STR_NEW2(ns->prefix);
22
19
  }
23
20
 
@@ -30,13 +27,10 @@ static VALUE prefix(VALUE self)
30
27
  static VALUE href(VALUE self)
31
28
  {
32
29
  xmlNsPtr ns;
33
- xmlDocPtr doc;
34
30
 
35
31
  Data_Get_Struct(self, xmlNs, ns);
36
32
  if(!ns->href) return Qnil;
37
33
 
38
- Data_Get_Struct(rb_iv_get(self, "@document"), xmlDoc, doc);
39
-
40
34
  return NOKOGIRI_STR_NEW2(ns->href);
41
35
  }
42
36
 
Binary file
Binary file
@@ -1,6 +1,8 @@
1
1
  module Nokogiri
2
2
  module CSS
3
3
  class Node
4
+ ALLOW_COMBINATOR_ON_SELF = [:DIRECT_ADJACENT_SELECTOR, :FOLLOWING_SELECTOR, :CHILD_SELECTOR]
5
+
4
6
  # Get the type of this node
5
7
  attr_accessor :type
6
8
  # Get the value of this node
@@ -21,6 +23,7 @@ module Nokogiri
21
23
  # Convert this CSS node to xpath with +prefix+ using +visitor+
22
24
  def to_xpath prefix = '//', visitor = XPathVisitor.new
23
25
  self.preprocess!
26
+ prefix = '.' if ALLOW_COMBINATOR_ON_SELF.include?(type) && value.first.nil?
24
27
  prefix + visitor.accept(self)
25
28
  end
26
29
 
@@ -14,172 +14,180 @@ module Nokogiri
14
14
  ##### State transition tables begin ###
15
15
 
16
16
  racc_action_table = [
17
- 5, 59, 28, 23, 12, 25, 63, 60, 5, 1,
18
- 6, 62, 12, 60, 69, 24, 17, 1, 86, 20,
19
- 98, 97, 6, 12, 9, 10, 14, 20, 17, 70,
20
- 6, 5, 9, 10, 14, 12, 17, -24, 44, 5,
21
- 1, 6, 44, 12, 10, 64, 65, 17, 1, 68,
22
- 20, 5, 67, 6, 62, 9, 10, 14, 20, 17,
23
- 29, 6, 31, 9, 10, 14, 12, 17, 12, 65,
24
- 20, 1, 87, 12, 88, 9, 66, 12, 12, 61,
25
- 28, 56, 12, 57, 6, 91, 6, 10, 14, 10,
26
- 17, 6, 17, 92, 10, 6, 6, 17, 10, 10,
27
- 6, 17, 17, 10, 5, 44, 17, 72, 75, 28,
28
- 56, 46, 57, 52, 28, 56, 95, 57, 73, 76,
29
- 77, 96, 78, 20, 72, 75, 71, 22, 9, 99,
30
- -24, 101, 36, 38, 40, 73, 76, 77, 102, 78,
31
- nil, nil, 35, 71, 37, 39, 28, 56, nil, 57 ]
17
+ 6, 62, 7, 63, 14, 19, 23, 26, 20, 2,
18
+ 71, 14, 6, 63, 85, 17, 14, 22, 25, 28,
19
+ 83, 2, 7, 72, 11, 13, 15, -26, 20, 7,
20
+ 49, 28, 13, 70, 7, 20, 11, 13, 15, 6,
21
+ 20, 64, 65, 14, 19, 23, 26, 64, 2, 36,
22
+ 59, 6, 60, 67, 17, 14, 22, 25, 28, 90,
23
+ 2, 7, 6, 11, 13, 15, 14, 20, 66, 67,
24
+ 28, 2, 91, 7, 14, 11, 13, 15, 14, 20,
25
+ 69, 28, 6, 2, 7, 68, 11, 13, 15, 14,
26
+ 20, 37, 7, 39, 94, 13, 7, 14, 20, 13,
27
+ 15, 28, 20, 6, 49, 14, 11, 7, 36, 59,
28
+ 13, 60, 53, 20, 14, 7, 36, 59, 13, 60,
29
+ 95, 20, 28, 7, 101, 100, 13, 11, 49, 20,
30
+ 74, 76, 7, 36, 31, 13, 33, 50, 20, 74,
31
+ 76, 75, 77, 79, 98, 80, 32, 99, 42, 73,
32
+ 75, 77, 79, 102, 80, 19, 23, 26, 73, 36,
33
+ 59, -26, 60, 104, 105, 17, nil, 22, 25 ]
32
34
 
33
35
  racc_action_check = [
34
- 0, 21, 5, 5, 0, 5, 23, 45, 9, 0,
35
- 15, 23, 9, 21, 30, 5, 15, 9, 45, 0,
36
- 79, 79, 0, 8, 0, 0, 0, 9, 0, 31,
37
- 9, 34, 9, 9, 9, 34, 9, 29, 8, 60,
38
- 34, 8, 42, 60, 8, 25, 25, 8, 60, 28,
39
- 34, 6, 27, 34, 56, 34, 34, 34, 60, 34,
40
- 6, 60, 6, 60, 60, 60, 44, 60, 83, 57,
41
- 6, 44, 58, 19, 59, 6, 26, 18, 13, 22,
42
- 62, 62, 16, 62, 44, 63, 83, 44, 44, 83,
43
- 44, 19, 83, 64, 19, 18, 13, 19, 18, 13,
44
- 16, 18, 13, 16, 17, 11, 16, 32, 32, 20,
45
- 20, 10, 20, 17, 65, 65, 69, 65, 32, 32,
46
- 32, 74, 32, 17, 33, 33, 32, 4, 17, 80,
47
- 1, 85, 7, 7, 7, 33, 33, 33, 92, 33,
48
- nil, nil, 7, 33, 7, 7, 68, 68, nil, 68 ]
36
+ 0, 29, 21, 45, 0, 0, 0, 0, 21, 0,
37
+ 38, 24, 63, 29, 45, 0, 63, 0, 0, 0,
38
+ 42, 63, 0, 39, 0, 0, 0, 37, 0, 24,
39
+ 47, 63, 24, 36, 63, 24, 63, 63, 63, 11,
40
+ 63, 59, 31, 11, 11, 11, 11, 31, 11, 70,
41
+ 70, 9, 70, 60, 11, 9, 11, 11, 11, 61,
42
+ 9, 11, 44, 11, 11, 11, 44, 11, 33, 33,
43
+ 9, 44, 62, 9, 87, 9, 9, 9, 49, 9,
44
+ 35, 44, 7, 49, 44, 34, 44, 44, 44, 12,
45
+ 44, 7, 87, 7, 65, 87, 49, 27, 87, 49,
46
+ 49, 7, 49, 20, 12, 18, 7, 12, 64, 64,
47
+ 12, 64, 20, 12, 1, 27, 28, 28, 27, 28,
48
+ 66, 27, 20, 18, 81, 81, 18, 20, 16, 18,
49
+ 41, 41, 1, 6, 6, 1, 6, 13, 1, 40,
50
+ 40, 41, 41, 41, 71, 41, 6, 78, 8, 41,
51
+ 40, 40, 40, 82, 40, 10, 10, 10, 40, 67,
52
+ 67, 2, 67, 89, 95, 10, nil, 10, 10 ]
49
53
 
50
54
  racc_action_pointer = [
51
- -2, 101, nil, nil, 98, -8, 49, 125, 17, 6,
52
- 100, 84, nil, 72, nil, -14, 76, 102, 71, 67,
53
- 99, 1, 68, -1, nil, 34, 53, 29, 37, 8,
54
- -15, 4, 104, 121, 29, nil, nil, nil, nil, nil,
55
- nil, nil, 21, nil, 60, -5, nil, nil, nil, nil,
56
- nil, nil, nil, nil, nil, nil, 42, 57, 49, 74,
57
- 37, nil, 70, 72, 86, 104, nil, nil, 136, 105,
58
- nil, nil, nil, nil, 96, nil, nil, nil, nil, 10,
59
- 104, nil, nil, 62, nil, 108, nil, nil, nil, nil,
60
- nil, nil, 125, nil, nil, nil, nil, nil, nil, nil,
61
- nil, nil, nil ]
55
+ -2, 108, 132, nil, nil, nil, 123, 80, 119, 49,
56
+ 148, 37, 83, 126, nil, nil, 107, nil, 99, nil,
57
+ 101, -22, nil, nil, 5, nil, nil, 91, 106, 1,
58
+ nil, 35, nil, 57, 62, 57, 21, -2, -19, -2,
59
+ 136, 127, 9, nil, 60, -9, nil, 9, nil, 72,
60
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 29,
61
+ 41, 36, 72, 10, 98, 81, 113, 149, nil, nil,
62
+ 39, 133, nil, nil, nil, nil, nil, nil, 122, nil,
63
+ nil, 114, 128, nil, nil, nil, nil, 68, nil, 140,
64
+ nil, nil, nil, nil, nil, 151, nil, nil, nil, nil,
65
+ nil, nil, nil, nil, nil, nil ]
62
66
 
63
67
  racc_action_default = [
64
- -25, -23, -20, -2, -72, -72, -25, -18, -48, -25,
65
- -72, -16, -57, -53, -21, -12, -56, -72, -55, -54,
66
- -72, -72, -72, -41, -31, -39, -72, -72, -40, -30,
67
- -72, -72, -60, -60, -25, -5, -3, -8, -4, -7,
68
- -6, -9, -47, -11, -25, -72, -19, -15, -49, -13,
69
- -14, -52, -46, -45, -51, -50, -41, -39, -72, -72,
70
- -25, -22, -72, -72, -44, -72, -32, -33, -72, -72,
71
- -28, -61, -66, -62, -72, -67, -63, -64, -65, -72,
72
- -72, -17, -10, -69, -71, -72, -35, -34, 103, -1,
73
- -38, -43, -72, -36, -37, -29, -26, -58, -59, -27,
74
- -70, -68, -42 ]
68
+ -27, -56, -25, -3, -22, -2, -74, -27, -74, -27,
69
+ -20, -27, -50, -74, -59, -23, -17, -6, -55, -4,
70
+ -74, -13, -9, -5, -58, -8, -7, -57, -74, -74,
71
+ -52, -43, -33, -41, -74, -74, -42, -32, -74, -74,
72
+ -62, -62, -74, -18, -27, -74, -10, -49, -12, -27,
73
+ -21, -16, -51, -48, -47, -14, -15, -54, -53, -43,
74
+ -41, -74, -74, -27, -74, -74, -46, -74, -34, -35,
75
+ -74, -74, -30, -63, -68, -64, -69, -65, -74, -66,
76
+ -67, -74, -74, -24, -19, -37, -11, -71, -73, -74,
77
+ -36, 106, -1, -40, -45, -74, -38, -39, -31, -28,
78
+ -60, -61, -29, -72, -70, -44 ]
75
79
 
76
80
  racc_goto_table = [
77
- 42, 26, 81, 43, 33, 48, 47, 49, 51, 21,
78
- 54, 55, 74, 80, 41, 53, 58, 50, 45, 30,
79
- 32, 83, 34, 27, 85, nil, nil, nil, 89, nil,
80
- nil, nil, nil, nil, nil, nil, 84, 82, nil, nil,
81
+ 30, 43, 34, 48, 29, 41, 55, 51, 78, 82,
82
+ 46, 47, 56, 38, 40, 45, 87, 52, 54, 44,
83
+ 35, 89, nil, 57, 61, nil, 58, nil, nil, nil,
84
+ nil, nil, nil, nil, nil, nil, 84, nil, 86, nil,
85
+ nil, nil, nil, nil, nil, nil, nil, nil, 88, nil,
86
+ nil, nil, nil, nil, nil, 92, nil, nil, nil, nil,
87
+ 93, nil, nil, 96, nil, nil, 97, nil, nil, nil,
81
88
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
82
- nil, nil, nil, nil, nil, nil, nil, nil, 90, nil,
83
- nil, 93, nil, nil, 94, nil, nil, nil, nil, nil,
84
- nil, nil, nil, nil, nil, 100 ]
89
+ nil, nil, nil, nil, nil, nil, 103 ]
85
90
 
86
91
  racc_goto_check = [
87
- 7, 17, 2, 8, 9, 7, 8, 10, 7, 1,
88
- 7, 7, 16, 16, 6, 9, 17, 11, 1, 14,
89
- 15, 5, 3, 18, 21, nil, nil, nil, 2, nil,
90
- nil, nil, nil, nil, nil, nil, 7, 8, nil, nil,
92
+ 8, 2, 18, 9, 1, 10, 11, 9, 17, 17,
93
+ 7, 8, 12, 15, 16, 1, 6, 8, 10, 4,
94
+ 19, 22, nil, 8, 18, nil, 8, nil, nil, nil,
95
+ nil, nil, nil, nil, nil, nil, 2, nil, 9, nil,
96
+ nil, nil, nil, nil, nil, nil, nil, nil, 8, nil,
97
+ nil, nil, nil, nil, nil, 2, nil, nil, nil, nil,
98
+ 18, nil, nil, 18, nil, nil, 18, nil, nil, nil,
91
99
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
92
- nil, nil, nil, nil, nil, nil, nil, nil, 17, nil,
93
- nil, 17, nil, nil, 17, nil, nil, nil, nil, nil,
94
- nil, nil, nil, nil, nil, 7 ]
100
+ nil, nil, nil, nil, nil, nil, 8 ]
95
101
 
96
102
  racc_goto_pointer = [
97
- nil, 9, -32, 15, nil, -23, 6, -8, -5, -2,
98
- -8, 2, nil, nil, 13, 14, -20, -4, 18, nil,
99
- nil, -20 ]
103
+ nil, 4, -8, nil, 9, nil, -33, -2, -1, -9,
104
+ -2, -15, -9, nil, nil, 6, 7, -32, -4, 14,
105
+ nil, nil, -28 ]
100
106
 
101
107
  racc_goto_default = [
102
- nil, nil, 3, nil, 7, 8, nil, 11, nil, 15,
103
- 16, 18, 19, 2, 4, nil, nil, nil, nil, 13,
104
- 79, nil ]
108
+ nil, nil, 3, 5, 9, 10, 12, nil, 16, nil,
109
+ 21, 24, 27, 1, 4, 8, nil, nil, nil, nil,
110
+ 18, 81, nil ]
105
111
 
106
112
  racc_reduce_table = [
107
113
  0, 0, :racc_error,
108
114
  3, 32, :_reduce_1,
109
115
  1, 32, :_reduce_2,
110
- 1, 34, :_reduce_3,
111
- 1, 34, :_reduce_4,
112
- 1, 34, :_reduce_5,
113
- 1, 34, :_reduce_6,
114
- 1, 34, :_reduce_7,
115
- 1, 34, :_reduce_8,
116
- 2, 35, :_reduce_9,
117
- 3, 35, :_reduce_10,
118
- 2, 35, :_reduce_11,
119
- 1, 35, :_reduce_none,
120
- 2, 35, :_reduce_13,
121
- 2, 35, :_reduce_14,
122
- 2, 35, :_reduce_15,
123
- 1, 35, :_reduce_16,
124
- 3, 33, :_reduce_17,
125
- 1, 33, :_reduce_none,
126
- 2, 43, :_reduce_19,
116
+ 1, 32, :_reduce_3,
117
+ 1, 35, :_reduce_4,
118
+ 1, 35, :_reduce_5,
119
+ 1, 35, :_reduce_6,
120
+ 1, 35, :_reduce_7,
121
+ 1, 35, :_reduce_8,
122
+ 1, 35, :_reduce_9,
123
+ 2, 36, :_reduce_10,
124
+ 3, 36, :_reduce_11,
125
+ 2, 36, :_reduce_12,
127
126
  1, 36, :_reduce_none,
128
- 1, 36, :_reduce_21,
129
- 3, 44, :_reduce_22,
130
- 1, 44, :_reduce_23,
131
- 1, 45, :_reduce_24,
132
- 0, 45, :_reduce_none,
133
- 4, 42, :_reduce_26,
134
- 4, 42, :_reduce_27,
135
- 3, 42, :_reduce_28,
136
- 3, 46, :_reduce_29,
137
- 1, 46, :_reduce_30,
138
- 2, 40, :_reduce_31,
139
- 3, 40, :_reduce_32,
140
- 3, 40, :_reduce_33,
141
- 3, 40, :_reduce_34,
142
- 3, 40, :_reduce_35,
143
- 3, 48, :_reduce_36,
144
- 3, 48, :_reduce_37,
145
- 3, 48, :_reduce_38,
146
- 1, 48, :_reduce_none,
147
- 1, 48, :_reduce_none,
148
- 1, 48, :_reduce_41,
149
- 4, 49, :_reduce_42,
150
- 3, 49, :_reduce_43,
151
- 2, 49, :_reduce_44,
152
- 2, 41, :_reduce_45,
153
- 2, 41, :_reduce_46,
127
+ 2, 36, :_reduce_14,
128
+ 2, 36, :_reduce_15,
129
+ 2, 36, :_reduce_16,
130
+ 1, 36, :_reduce_17,
131
+ 2, 34, :_reduce_18,
132
+ 3, 33, :_reduce_19,
133
+ 1, 33, :_reduce_none,
134
+ 2, 44, :_reduce_21,
154
135
  1, 37, :_reduce_none,
155
- 0, 37, :_reduce_none,
156
- 2, 38, :_reduce_49,
157
- 2, 38, :_reduce_50,
158
- 2, 38, :_reduce_51,
159
- 2, 38, :_reduce_52,
160
- 1, 38, :_reduce_none,
161
- 1, 38, :_reduce_none,
136
+ 1, 37, :_reduce_23,
137
+ 3, 45, :_reduce_24,
138
+ 1, 45, :_reduce_25,
139
+ 1, 46, :_reduce_26,
140
+ 0, 46, :_reduce_none,
141
+ 4, 43, :_reduce_28,
142
+ 4, 43, :_reduce_29,
143
+ 3, 43, :_reduce_30,
144
+ 3, 47, :_reduce_31,
145
+ 1, 47, :_reduce_32,
146
+ 2, 41, :_reduce_33,
147
+ 3, 41, :_reduce_34,
148
+ 3, 41, :_reduce_35,
149
+ 3, 41, :_reduce_36,
150
+ 3, 41, :_reduce_37,
151
+ 3, 49, :_reduce_38,
152
+ 3, 49, :_reduce_39,
153
+ 3, 49, :_reduce_40,
154
+ 1, 49, :_reduce_none,
155
+ 1, 49, :_reduce_none,
156
+ 1, 49, :_reduce_43,
157
+ 4, 50, :_reduce_44,
158
+ 3, 50, :_reduce_45,
159
+ 2, 50, :_reduce_46,
160
+ 2, 42, :_reduce_47,
161
+ 2, 42, :_reduce_48,
162
162
  1, 38, :_reduce_none,
163
- 1, 38, :_reduce_none,
164
- 1, 50, :_reduce_57,
165
- 2, 47, :_reduce_58,
166
- 2, 47, :_reduce_59,
167
- 0, 47, :_reduce_none,
168
- 1, 51, :_reduce_61,
169
- 1, 51, :_reduce_62,
170
- 1, 51, :_reduce_63,
171
- 1, 51, :_reduce_64,
172
- 1, 51, :_reduce_65,
173
- 1, 51, :_reduce_66,
174
- 1, 51, :_reduce_67,
175
- 3, 39, :_reduce_68,
176
- 1, 52, :_reduce_none,
177
- 2, 52, :_reduce_none,
178
- 1, 52, :_reduce_none ]
179
-
180
- racc_reduce_n = 72
181
-
182
- racc_shift_n = 103
163
+ 0, 38, :_reduce_none,
164
+ 2, 39, :_reduce_51,
165
+ 2, 39, :_reduce_52,
166
+ 2, 39, :_reduce_53,
167
+ 2, 39, :_reduce_54,
168
+ 1, 39, :_reduce_none,
169
+ 1, 39, :_reduce_none,
170
+ 1, 39, :_reduce_none,
171
+ 1, 39, :_reduce_none,
172
+ 1, 51, :_reduce_59,
173
+ 2, 48, :_reduce_60,
174
+ 2, 48, :_reduce_61,
175
+ 0, 48, :_reduce_none,
176
+ 1, 52, :_reduce_63,
177
+ 1, 52, :_reduce_64,
178
+ 1, 52, :_reduce_65,
179
+ 1, 52, :_reduce_66,
180
+ 1, 52, :_reduce_67,
181
+ 1, 52, :_reduce_68,
182
+ 1, 52, :_reduce_69,
183
+ 3, 40, :_reduce_70,
184
+ 1, 53, :_reduce_none,
185
+ 2, 53, :_reduce_none,
186
+ 1, 53, :_reduce_none ]
187
+
188
+ racc_reduce_n = 74
189
+
190
+ racc_shift_n = 106
183
191
 
184
192
  racc_token_table = {
185
193
  false => 0,
@@ -269,6 +277,7 @@ Racc_token_to_s_table = [
269
277
  "$start",
270
278
  "selector",
271
279
  "simple_selector_1toN",
280
+ "prefixless_combinator_selector",
272
281
  "combinator",
273
282
  "simple_selector",
274
283
  "element_name",
@@ -307,22 +316,22 @@ def _reduce_2(val, _values, result)
307
316
  end
308
317
 
309
318
  def _reduce_3(val, _values, result)
310
- result = :DIRECT_ADJACENT_SELECTOR
319
+ result = val.flatten
311
320
  result
312
321
  end
313
322
 
314
323
  def _reduce_4(val, _values, result)
315
- result = :CHILD_SELECTOR
324
+ result = :DIRECT_ADJACENT_SELECTOR
316
325
  result
317
326
  end
318
327
 
319
328
  def _reduce_5(val, _values, result)
320
- result = :PRECEDING_SELECTOR
329
+ result = :CHILD_SELECTOR
321
330
  result
322
331
  end
323
332
 
324
333
  def _reduce_6(val, _values, result)
325
- result = :DESCENDANT_SELECTOR
334
+ result = :FOLLOWING_SELECTOR
326
335
  result
327
336
  end
328
337
 
@@ -332,11 +341,16 @@ def _reduce_7(val, _values, result)
332
341
  end
333
342
 
334
343
  def _reduce_8(val, _values, result)
335
- result = :CHILD_SELECTOR
344
+ result = :DESCENDANT_SELECTOR
336
345
  result
337
346
  end
338
347
 
339
348
  def _reduce_9(val, _values, result)
349
+ result = :CHILD_SELECTOR
350
+ result
351
+ end
352
+
353
+ def _reduce_10(val, _values, result)
340
354
  result = if val[1].nil?
341
355
  val.first
342
356
  else
@@ -346,7 +360,7 @@ def _reduce_9(val, _values, result)
346
360
  result
347
361
  end
348
362
 
349
- def _reduce_10(val, _values, result)
363
+ def _reduce_11(val, _values, result)
350
364
  result = Node.new(:CONDITIONAL_SELECTOR,
351
365
  [
352
366
  val.first,
@@ -357,27 +371,27 @@ def _reduce_10(val, _values, result)
357
371
  result
358
372
  end
359
373
 
360
- def _reduce_11(val, _values, result)
374
+ def _reduce_12(val, _values, result)
361
375
  result = Node.new(:CONDITIONAL_SELECTOR, val)
362
376
 
363
377
  result
364
378
  end
365
379
 
366
- # reduce 12 omitted
380
+ # reduce 13 omitted
367
381
 
368
- def _reduce_13(val, _values, result)
382
+ def _reduce_14(val, _values, result)
369
383
  result = Node.new(:CONDITIONAL_SELECTOR, val)
370
384
 
371
385
  result
372
386
  end
373
387
 
374
- def _reduce_14(val, _values, result)
388
+ def _reduce_15(val, _values, result)
375
389
  result = Node.new(:CONDITIONAL_SELECTOR, val)
376
390
 
377
391
  result
378
392
  end
379
393
 
380
- def _reduce_15(val, _values, result)
394
+ def _reduce_16(val, _values, result)
381
395
  result = Node.new(:CONDITIONAL_SELECTOR,
382
396
  [
383
397
  Node.new(:ELEMENT_NAME, ['*']),
@@ -388,7 +402,7 @@ def _reduce_15(val, _values, result)
388
402
  result
389
403
  end
390
404
 
391
- def _reduce_16(val, _values, result)
405
+ def _reduce_17(val, _values, result)
392
406
  result = Node.new(:CONDITIONAL_SELECTOR,
393
407
  [Node.new(:ELEMENT_NAME, ['*']), val.first]
394
408
  )
@@ -396,27 +410,33 @@ def _reduce_16(val, _values, result)
396
410
  result
397
411
  end
398
412
 
399
- def _reduce_17(val, _values, result)
400
- result = Node.new(val[1], [val.first, val.last])
413
+ def _reduce_18(val, _values, result)
414
+ result = Node.new(val.first, [nil, val.last])
401
415
 
402
416
  result
403
417
  end
404
418
 
405
- # reduce 18 omitted
406
-
407
419
  def _reduce_19(val, _values, result)
408
- result = Node.new(:CLASS_CONDITION, [val[1]])
420
+ result = Node.new(val[1], [val.first, val.last])
421
+
409
422
  result
410
423
  end
411
424
 
412
425
  # reduce 20 omitted
413
426
 
414
427
  def _reduce_21(val, _values, result)
428
+ result = Node.new(:CLASS_CONDITION, [val[1]])
429
+ result
430
+ end
431
+
432
+ # reduce 22 omitted
433
+
434
+ def _reduce_23(val, _values, result)
415
435
  result = Node.new(:ELEMENT_NAME, val)
416
436
  result
417
437
  end
418
438
 
419
- def _reduce_22(val, _values, result)
439
+ def _reduce_24(val, _values, result)
420
440
  result = Node.new(:ELEMENT_NAME,
421
441
  [[val.first, val.last].compact.join(':')]
422
442
  )
@@ -424,21 +444,21 @@ def _reduce_22(val, _values, result)
424
444
  result
425
445
  end
426
446
 
427
- def _reduce_23(val, _values, result)
447
+ def _reduce_25(val, _values, result)
428
448
  name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
429
449
  result = Node.new(:ELEMENT_NAME, [name])
430
450
 
431
451
  result
432
452
  end
433
453
 
434
- def _reduce_24(val, _values, result)
454
+ def _reduce_26(val, _values, result)
435
455
  result = val[0]
436
456
  result
437
457
  end
438
458
 
439
- # reduce 25 omitted
459
+ # reduce 27 omitted
440
460
 
441
- def _reduce_26(val, _values, result)
461
+ def _reduce_28(val, _values, result)
442
462
  result = Node.new(:ATTRIBUTE_CONDITION,
443
463
  [val[1]] + (val[2] || [])
444
464
  )
@@ -446,7 +466,7 @@ def _reduce_26(val, _values, result)
446
466
  result
447
467
  end
448
468
 
449
- def _reduce_27(val, _values, result)
469
+ def _reduce_29(val, _values, result)
450
470
  result = Node.new(:ATTRIBUTE_CONDITION,
451
471
  [val[1]] + (val[2] || [])
452
472
  )
@@ -454,7 +474,7 @@ def _reduce_27(val, _values, result)
454
474
  result
455
475
  end
456
476
 
457
- def _reduce_28(val, _values, result)
477
+ def _reduce_30(val, _values, result)
458
478
  # Non standard, but hpricot supports it.
459
479
  result = Node.new(:PSEUDO_CLASS,
460
480
  [Node.new(:FUNCTION, ['nth-child(', val[1]])]
@@ -463,7 +483,7 @@ def _reduce_28(val, _values, result)
463
483
  result
464
484
  end
465
485
 
466
- def _reduce_29(val, _values, result)
486
+ def _reduce_31(val, _values, result)
467
487
  result = Node.new(:ELEMENT_NAME,
468
488
  [[val.first, val.last].compact.join(':')]
469
489
  )
@@ -471,7 +491,7 @@ def _reduce_29(val, _values, result)
471
491
  result
472
492
  end
473
493
 
474
- def _reduce_30(val, _values, result)
494
+ def _reduce_32(val, _values, result)
475
495
  # Default namespace is not applied to attributes.
476
496
  # So we don't add prefix "xmlns:" as in namespaced_ident.
477
497
  result = Node.new(:ELEMENT_NAME, [val.first])
@@ -479,56 +499,56 @@ def _reduce_30(val, _values, result)
479
499
  result
480
500
  end
481
501
 
482
- def _reduce_31(val, _values, result)
502
+ def _reduce_33(val, _values, result)
483
503
  result = Node.new(:FUNCTION, [val.first.strip])
484
504
 
485
505
  result
486
506
  end
487
507
 
488
- def _reduce_32(val, _values, result)
508
+ def _reduce_34(val, _values, result)
489
509
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
490
510
 
491
511
  result
492
512
  end
493
513
 
494
- def _reduce_33(val, _values, result)
514
+ def _reduce_35(val, _values, result)
495
515
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
496
516
 
497
517
  result
498
518
  end
499
519
 
500
- def _reduce_34(val, _values, result)
520
+ def _reduce_36(val, _values, result)
501
521
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
502
522
 
503
523
  result
504
524
  end
505
525
 
506
- def _reduce_35(val, _values, result)
526
+ def _reduce_37(val, _values, result)
507
527
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
508
528
 
509
529
  result
510
530
  end
511
531
 
512
- def _reduce_36(val, _values, result)
532
+ def _reduce_38(val, _values, result)
513
533
  result = [val.first, val.last]
514
534
  result
515
535
  end
516
536
 
517
- def _reduce_37(val, _values, result)
537
+ def _reduce_39(val, _values, result)
518
538
  result = [val.first, val.last]
519
539
  result
520
540
  end
521
541
 
522
- def _reduce_38(val, _values, result)
542
+ def _reduce_40(val, _values, result)
523
543
  result = [val.first, val.last]
524
544
  result
525
545
  end
526
546
 
527
- # reduce 39 omitted
547
+ # reduce 41 omitted
528
548
 
529
- # reduce 40 omitted
549
+ # reduce 42 omitted
530
550
 
531
- def _reduce_41(val, _values, result)
551
+ def _reduce_43(val, _values, result)
532
552
  if val[0] == 'even'
533
553
  val = ["2","n","+","0"]
534
554
  result = Node.new(:AN_PLUS_B, val)
@@ -546,7 +566,7 @@ def _reduce_41(val, _values, result)
546
566
  result
547
567
  end
548
568
 
549
- def _reduce_42(val, _values, result)
569
+ def _reduce_44(val, _values, result)
550
570
  if val[1] == 'n'
551
571
  result = Node.new(:AN_PLUS_B, val)
552
572
  else
@@ -556,7 +576,7 @@ def _reduce_42(val, _values, result)
556
576
  result
557
577
  end
558
578
 
559
- def _reduce_43(val, _values, result)
579
+ def _reduce_45(val, _values, result)
560
580
  # n+3, -n+3
561
581
  if val[0] == 'n'
562
582
  val.unshift("1")
@@ -572,7 +592,7 @@ def _reduce_43(val, _values, result)
572
592
  result
573
593
  end
574
594
 
575
- def _reduce_44(val, _values, result)
595
+ def _reduce_46(val, _values, result)
576
596
  if val[1] == 'n'
577
597
  val << "+"
578
598
  val << "0"
@@ -584,116 +604,116 @@ def _reduce_44(val, _values, result)
584
604
  result
585
605
  end
586
606
 
587
- def _reduce_45(val, _values, result)
607
+ def _reduce_47(val, _values, result)
588
608
  result = Node.new(:PSEUDO_CLASS, [val[1]])
589
609
 
590
610
  result
591
611
  end
592
612
 
593
- def _reduce_46(val, _values, result)
613
+ def _reduce_48(val, _values, result)
594
614
  result = Node.new(:PSEUDO_CLASS, [val[1]])
595
615
  result
596
616
  end
597
617
 
598
- # reduce 47 omitted
618
+ # reduce 49 omitted
599
619
 
600
- # reduce 48 omitted
620
+ # reduce 50 omitted
601
621
 
602
- def _reduce_49(val, _values, result)
622
+ def _reduce_51(val, _values, result)
603
623
  result = Node.new(:COMBINATOR, val)
604
624
 
605
625
  result
606
626
  end
607
627
 
608
- def _reduce_50(val, _values, result)
628
+ def _reduce_52(val, _values, result)
609
629
  result = Node.new(:COMBINATOR, val)
610
630
 
611
631
  result
612
632
  end
613
633
 
614
- def _reduce_51(val, _values, result)
634
+ def _reduce_53(val, _values, result)
615
635
  result = Node.new(:COMBINATOR, val)
616
636
 
617
637
  result
618
638
  end
619
639
 
620
- def _reduce_52(val, _values, result)
640
+ def _reduce_54(val, _values, result)
621
641
  result = Node.new(:COMBINATOR, val)
622
642
 
623
643
  result
624
644
  end
625
645
 
626
- # reduce 53 omitted
627
-
628
- # reduce 54 omitted
629
-
630
646
  # reduce 55 omitted
631
647
 
632
648
  # reduce 56 omitted
633
649
 
634
- def _reduce_57(val, _values, result)
650
+ # reduce 57 omitted
651
+
652
+ # reduce 58 omitted
653
+
654
+ def _reduce_59(val, _values, result)
635
655
  result = Node.new(:ID, val)
636
656
  result
637
657
  end
638
658
 
639
- def _reduce_58(val, _values, result)
659
+ def _reduce_60(val, _values, result)
640
660
  result = [val.first, val[1]]
641
661
  result
642
662
  end
643
663
 
644
- def _reduce_59(val, _values, result)
664
+ def _reduce_61(val, _values, result)
645
665
  result = [val.first, val[1]]
646
666
  result
647
667
  end
648
668
 
649
- # reduce 60 omitted
669
+ # reduce 62 omitted
650
670
 
651
- def _reduce_61(val, _values, result)
671
+ def _reduce_63(val, _values, result)
652
672
  result = :equal
653
673
  result
654
674
  end
655
675
 
656
- def _reduce_62(val, _values, result)
676
+ def _reduce_64(val, _values, result)
657
677
  result = :prefix_match
658
678
  result
659
679
  end
660
680
 
661
- def _reduce_63(val, _values, result)
681
+ def _reduce_65(val, _values, result)
662
682
  result = :suffix_match
663
683
  result
664
684
  end
665
685
 
666
- def _reduce_64(val, _values, result)
686
+ def _reduce_66(val, _values, result)
667
687
  result = :substring_match
668
688
  result
669
689
  end
670
690
 
671
- def _reduce_65(val, _values, result)
691
+ def _reduce_67(val, _values, result)
672
692
  result = :not_equal
673
693
  result
674
694
  end
675
695
 
676
- def _reduce_66(val, _values, result)
696
+ def _reduce_68(val, _values, result)
677
697
  result = :includes
678
698
  result
679
699
  end
680
700
 
681
- def _reduce_67(val, _values, result)
701
+ def _reduce_69(val, _values, result)
682
702
  result = :dash_match
683
703
  result
684
704
  end
685
705
 
686
- def _reduce_68(val, _values, result)
706
+ def _reduce_70(val, _values, result)
687
707
  result = Node.new(:NOT, [val[1]])
688
708
 
689
709
  result
690
710
  end
691
711
 
692
- # reduce 69 omitted
712
+ # reduce 71 omitted
693
713
 
694
- # reduce 70 omitted
714
+ # reduce 72 omitted
695
715
 
696
- # reduce 71 omitted
716
+ # reduce 73 omitted
697
717
 
698
718
  def _reduce_none(val, _values, result)
699
719
  val[0]
@@ -9,12 +9,13 @@ rule
9
9
  : selector COMMA simple_selector_1toN {
10
10
  result = [val.first, val.last].flatten
11
11
  }
12
+ | prefixless_combinator_selector { result = val.flatten }
12
13
  | simple_selector_1toN { result = val.flatten }
13
14
  ;
14
15
  combinator
15
16
  : PLUS { result = :DIRECT_ADJACENT_SELECTOR }
16
17
  | GREATER { result = :CHILD_SELECTOR }
17
- | TILDE { result = :PRECEDING_SELECTOR }
18
+ | TILDE { result = :FOLLOWING_SELECTOR }
18
19
  | S { result = :DESCENDANT_SELECTOR }
19
20
  | DOUBLESLASH { result = :DESCENDANT_SELECTOR }
20
21
  | SLASH { result = :CHILD_SELECTOR }
@@ -59,6 +60,11 @@ rule
59
60
  )
60
61
  }
61
62
  ;
63
+ prefixless_combinator_selector
64
+ : combinator simple_selector_1toN {
65
+ result = Node.new(val.first, [nil, val.last])
66
+ }
67
+ ;
62
68
  simple_selector_1toN
63
69
  : simple_selector combinator simple_selector_1toN {
64
70
  result = Node.new(val[1], [val.first, val.last])
@@ -126,13 +126,13 @@ module Nokogiri
126
126
  {
127
127
  'combinator' => ' and ',
128
128
  'direct_adjacent_selector' => "/following-sibling::*[1]/self::",
129
- 'preceding_selector' => "/following-sibling::",
129
+ 'following_selector' => "/following-sibling::",
130
130
  'descendant_selector' => '//',
131
131
  'child_selector' => '/',
132
132
  }.each do |k,v|
133
133
  class_eval %{
134
134
  def visit_#{k} node
135
- "\#{node.value.first.accept(self)}#{v}\#{node.value.last.accept(self)}"
135
+ "\#{node.value.first.accept(self) if node.value.first}#{v}\#{node.value.last.accept(self)}"
136
136
  end
137
137
  }
138
138
  end
@@ -6,7 +6,8 @@ module Nokogiri
6
6
  # then nil is returned.
7
7
  def meta_encoding
8
8
  meta = meta_content_type and
9
- /charset\s*=\s*([\w-]+)/i.match(meta['content'])[1]
9
+ match = /charset\s*=\s*([\w-]+)/i.match(meta['content']) and
10
+ match[1]
10
11
  end
11
12
 
12
13
  ###
@@ -3,7 +3,7 @@ module Nokogiri
3
3
  class ElementDescription
4
4
 
5
5
  # Methods are defined protected by method_defined? because at
6
- # this point the C-library or Java library is alraedy loaded,
6
+ # this point the C-library or Java library is already loaded,
7
7
  # and we don't want to clobber any methods that have been
8
8
  # defined there.
9
9
 
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.5.3.rc3'
3
+ VERSION = '1.5.3.rc4'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -132,7 +132,7 @@ module Nokogiri
132
132
  # in the hash.
133
133
  #
134
134
  # Note this is a very expensive operation in current implementation, as it
135
- # traverses the entire graph, and also has to bring each node accross the
135
+ # traverses the entire graph, and also has to bring each node across the
136
136
  # libxml bridge into a ruby object.
137
137
  def collect_namespaces
138
138
  ns = {}
@@ -25,11 +25,11 @@ module Nokogiri
25
25
  NOBLANKS = 1 << 8
26
26
  # use the SAX1 interface internally
27
27
  SAX1 = 1 << 9
28
- # Implement XInclude substitition
28
+ # Implement XInclude substitution
29
29
  XINCLUDE = 1 << 10
30
30
  # Forbid network access
31
31
  NONET = 1 << 11
32
- # Do not reuse the context dictionnary
32
+ # Do not reuse the context dictionary
33
33
  NODICT = 1 << 12
34
34
  # remove redundant namespaces declarations
35
35
  NSCLEAN = 1 << 13
@@ -218,6 +218,33 @@ module Nokogiri
218
218
  @parser.parse("E + F G")
219
219
  end
220
220
 
221
+ def test_child_selector
222
+ assert_xpath("//a//b/i", @parser.parse('a b>i'))
223
+ assert_xpath("//a//b/i", @parser.parse('a b > i'))
224
+ assert_xpath("//a/b/i", @parser.parse('a > b > i'))
225
+ end
226
+
227
+ def test_prefixless_child_selector
228
+ assert_xpath("./a", @parser.parse('>a'))
229
+ assert_xpath("./a", @parser.parse('> a'))
230
+ assert_xpath("./a//b/i", @parser.parse('>a b>i'))
231
+ assert_xpath("./a/b/i", @parser.parse('> a > b > i'))
232
+ end
233
+
234
+ def test_prefixless_preceding_sibling_selector
235
+ assert_xpath("./following-sibling::a", @parser.parse('~a'))
236
+ assert_xpath("./following-sibling::a", @parser.parse('~ a'))
237
+ assert_xpath("./following-sibling::a//b/following-sibling::i", @parser.parse('~a b~i'))
238
+ assert_xpath("./following-sibling::a//b/following-sibling::i", @parser.parse('~ a b ~ i'))
239
+ end
240
+
241
+ def test_prefixless_direct_adjacent_selector
242
+ assert_xpath("./following-sibling::*[1]/self::a", @parser.parse('+a'))
243
+ assert_xpath("./following-sibling::*[1]/self::a", @parser.parse('+ a'))
244
+ assert_xpath("./following-sibling::*[1]/self::a/following-sibling::*[1]/self::b", @parser.parse('+a+b'))
245
+ assert_xpath("./following-sibling::*[1]/self::a/following-sibling::*[1]/self::b", @parser.parse('+ a + b'))
246
+ end
247
+
221
248
  def test_attribute
222
249
  assert_xpath "//h1[@a = 'Tender Lovemaking']",
223
250
  @parser.parse("h1[a='Tender Lovemaking']")
@@ -125,8 +125,10 @@ module Nokogiri
125
125
 
126
126
  def test_meta_encoding
127
127
  assert_equal 'UTF-8', @html.meta_encoding
128
+ end
128
129
 
129
- html = Nokogiri::HTML(<<-eohtml)
130
+ def test_meta_encoding_is_strict_about_http_equiv
131
+ doc = Nokogiri::HTML(<<-eohtml)
130
132
  <html>
131
133
  <head>
132
134
  <meta http-equiv="X-Content-Type" content="text/html; charset=Shift_JIS">
@@ -136,7 +138,21 @@ module Nokogiri
136
138
  </body>
137
139
  </html>
138
140
  eohtml
139
- assert_nil html.meta_encoding
141
+ assert_nil doc.meta_encoding
142
+ end
143
+
144
+ def test_meta_encoding_handles_malformed_content_charset
145
+ doc = Nokogiri::HTML(<<EOHTML)
146
+ <html>
147
+ <head>
148
+ <meta http-equiv="Content-type" content="text/html; utf-8" />
149
+ </head>
150
+ <body>
151
+ foo
152
+ </body>
153
+ </html>
154
+ EOHTML
155
+ assert_nil doc.meta_encoding
140
156
  end
141
157
 
142
158
  def test_meta_encoding=
@@ -422,4 +422,67 @@ class TestReader < Nokogiri::TestCase
422
422
  end
423
423
  end
424
424
 
425
+ def test_correct_outer_xml_inclusion
426
+ xml = Nokogiri::XML::Reader.from_io(StringIO.new(<<-eoxml))
427
+ <root-element>
428
+ <children>
429
+ <child n="1">
430
+ <field>child-1</field>
431
+ </child>
432
+ <child n="2">
433
+ <field>child-2</field>
434
+ </child>
435
+ <child n="3">
436
+ <field>child-3</field>
437
+ </child>
438
+ </children>
439
+ </root-element>
440
+ eoxml
441
+
442
+ nodelengths = []
443
+ has_child2 = []
444
+
445
+ xml.each do |node|
446
+ if node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT and node.name == "child"
447
+ nodelengths << node.outer_xml.length
448
+ has_child2 << !!(node.outer_xml =~ /child-2/)
449
+ end
450
+ end
451
+
452
+ assert_equal(nodelengths[0], nodelengths[1])
453
+ assert(has_child2[1])
454
+ assert(!has_child2[0])
455
+ end
456
+
457
+ def test_correct_inner_xml_inclusion
458
+ xml = Nokogiri::XML::Reader.from_io(StringIO.new(<<-eoxml))
459
+ <root-element>
460
+ <children>
461
+ <child n="1">
462
+ <field>child-1</field>
463
+ </child>
464
+ <child n="2">
465
+ <field>child-2</field>
466
+ </child>
467
+ <child n="3">
468
+ <field>child-3</field>
469
+ </child>
470
+ </children>
471
+ </root-element>
472
+ eoxml
473
+
474
+ nodelengths = []
475
+ has_child2 = []
476
+
477
+ xml.each do |node|
478
+ if node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT and node.name == "child"
479
+ nodelengths << node.inner_xml.length
480
+ has_child2 << !!(node.inner_xml =~ /child-2/)
481
+ end
482
+ end
483
+
484
+ assert_equal(nodelengths[0], nodelengths[1])
485
+ assert(has_child2[1])
486
+ assert(!has_child2[0])
487
+ end
425
488
  end
@@ -142,6 +142,7 @@ module Nokogiri
142
142
  end
143
143
 
144
144
  def test_broken_encoding
145
+ skip("ultra hard to fix for pure Java version") if Nokogiri.jruby?
145
146
  @parser.options |= XML::ParseOptions::RECOVER
146
147
  # This is ISO_8859-1:
147
148
  @parser.<< "<?xml version='1.0' encoding='UTF-8'?><r>Gau\337</r>"
@@ -993,6 +993,27 @@ EOXML
993
993
  assert_no_match("<ul>\n <li>", xml.to_xml(:save_with => XML::Node::SaveOptions::AS_XML))
994
994
  assert_no_match("<ul>\n <li>", node.to_xml(:save_with => XML::Node::SaveOptions::AS_XML))
995
995
  end
996
+
997
+ # issue 647
998
+ def test_default_namespace_should_be_created
999
+ subject = Nokogiri::XML.parse('<foo xml:bar="http://bar.com"/>').root
1000
+ ns = subject.attributes['bar'].namespace
1001
+ assert_not_nil ns
1002
+ assert_equal ns.class, Nokogiri::XML::Namespace
1003
+ assert_equal 'xml', ns.prefix
1004
+ assert_equal "http://www.w3.org/XML/1998/namespace", ns.href
1005
+ end
1006
+
1007
+ # issue 648
1008
+ def test_namespace_without_prefix_should_be_set
1009
+ node = Nokogiri::XML.parse('<foo xmlns="http://bar.com"/>').root
1010
+ subject = Nokogiri::XML::Node.new 'foo', node.document
1011
+ subject.namespace = node.namespace
1012
+ ns = subject.namespace
1013
+ assert_equal ns.class, Nokogiri::XML::Namespace
1014
+ assert_nil ns.prefix
1015
+ assert_equal ns.href, "http://bar.com"
1016
+ end
996
1017
  end
997
1018
  end
998
1019
  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: -4247147358
4
+ hash: 2354687645
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
9
  - 3
10
10
  - rc
11
- - 3
12
- version: 1.5.3.rc3
11
+ - 4
12
+ version: 1.5.3.rc4
13
13
  platform: x86-mswin32-60
14
14
  authors:
15
15
  - Aaron Patterson
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2012-03-26 00:00:00 Z
22
+ date: 2012-04-27 00:00:00 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: hoe-bundler