nokogiri-maglev- 1.5.3 → 1.5.4.20120815005250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.ja.rdoc CHANGED
@@ -1,4 +1,30 @@
1
- == 1.5.3 / unreleased
1
+ == 1.5.4 / unreleased
2
+
3
+ * Features
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.
9
+
10
+ * Bugfixes
11
+
12
+ * Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
13
+ * Treat '.' as xpath in at() and search(). #690
14
+
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
+
19
+ To re-enable this behavior, the configuration method `nononet` may
20
+ be called, like this:
21
+
22
+ Nokogiri::XML::Document.parse(xml) { |config| config.nononet }
23
+
24
+ Insert your own joke about double-negatives here.
25
+
26
+
27
+ == 1.5.3 / 2012-06-01
2
28
 
3
29
  * Features
4
30
 
data/CHANGELOG.rdoc CHANGED
@@ -1,4 +1,30 @@
1
- == 1.5.3 / unreleased
1
+ == 1.5.4 / unreleased
2
+
3
+ * Features
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.
9
+
10
+ * Bugfixes
11
+
12
+ * Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
13
+ * Treat '.' as xpath in at() and search(). #690
14
+
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
+
19
+ To re-enable this behavior, the configuration method `nononet` may
20
+ be called, like this:
21
+
22
+ Nokogiri::XML::Document.parse(xml) { |config| config.nononet }
23
+
24
+ Insert your own joke about double-negatives here.
25
+
26
+
27
+ == 1.5.3 / 2012-06-01
2
28
 
3
29
  * Features
4
30
 
data/C_CODING_STYLE.rdoc CHANGED
@@ -4,11 +4,17 @@ Please don't propose commits that only change whitespace. However, if your
4
4
  commit touches a function or section that is not using MRI Ruby conventions,
5
5
  feel free to update whitespace in the surrounding code.
6
6
 
7
+
7
8
  = WHITESPACE:
8
9
 
9
- indent level: 2
10
- indent type: Always spaces
11
- Line Breaks: LF
10
+ * indent level: 2
11
+ * indent type: Always spaces
12
+ * line Breaks: LF
13
+
14
+ This style can be automatically applied by running:
15
+
16
+ astyle --indent=spaces=2 --style=1tbs --keep-one-line-blocks $(ack -f --type=cpp --type=cc ext/nokogiri)
17
+
12
18
 
13
19
  = FUNCTION DECLARATION:
14
20
 
data/Rakefile CHANGED
@@ -23,10 +23,11 @@ end
23
23
 
24
24
  require 'tasks/nokogiri.org'
25
25
 
26
- HOE = Hoe.spec 'maglev-nokogiri' do
26
+ HOE = Hoe.spec 'nokogiri-maglev-' do
27
27
  developer 'Aaron Patterson', 'aaronp@rubyforge.org'
28
28
  developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
29
29
  developer 'Yoko Harada', 'yokolet@gmail.com'
30
+ developer 'Tim Elliott', 'tle@holymonkey.com'
30
31
 
31
32
  self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
32
33
  self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
@@ -49,6 +50,7 @@ HOE = Hoe.spec 'maglev-nokogiri' do
49
50
  ["mini_portile", ">= 0.2.2"],
50
51
  ["minitest", "~> 2.2.2"],
51
52
  ["racc", ">= 1.4.6"],
53
+ ["rake", ">= 0.9"],
52
54
  ["rake-compiler", "= 0.8.0"],
53
55
  ["rexical", ">= 1.0.5"],
54
56
  ]
data/bin/nokogiri CHANGED
@@ -53,7 +53,9 @@ end
53
53
  @doc = parse_class.parse(open(uri).read, nil, encoding)
54
54
 
55
55
  if @rng
56
- puts @rng.validate(@doc)
56
+ @rng.validate(@doc).each do |error|
57
+ puts error.message
58
+ end
57
59
  else
58
60
  puts "Your document is stored in @doc..."
59
61
  IRB.start
@@ -7,8 +7,8 @@ require 'mkmf'
7
7
  RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
8
8
 
9
9
  ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
10
- LIBDIR = Config::CONFIG['libdir']
11
- INCLUDEDIR = Config::CONFIG['includedir']
10
+ LIBDIR = RbConfig::CONFIG['libdir']
11
+ INCLUDEDIR = RbConfig::CONFIG['includedir']
12
12
 
13
13
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
14
14
  $LIBRUBYARG_STATIC.gsub!(/-static/, '')
@@ -99,12 +99,22 @@ def asplode(lib)
99
99
  abort "-----\n#{lib} is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.\n-----"
100
100
  end
101
101
 
102
- pkg_config('libxslt') if RUBY_PLATFORM =~ /mingw/
102
+ pkg_config('libxslt')
103
+ pkg_config('libxml-2.0')
104
+ pkg_config('libiconv')
105
+
106
+ def have_iconv?
107
+ %w{ iconv_open libiconv_open }.any? do |method|
108
+ have_func(method, 'iconv.h') or
109
+ have_library('iconv', method, 'iconv.h') or
110
+ find_library('iconv', method, 'iconv.h')
111
+ end
112
+ end
103
113
 
104
114
  asplode "libxml2" unless find_header('libxml/parser.h')
105
115
  asplode "libxslt" unless find_header('libxslt/xslt.h')
106
116
  asplode "libexslt" unless find_header('libexslt/exslt.h')
107
- # asplode "libiconv" unless have_func('iconv_open', 'iconv.h') or have_library('iconv', 'iconv_open', 'iconv.h') or find_library('iconv', 'iconv_open', 'iconv.h')
117
+ # asplode "libiconv" unless have_iconv?
108
118
  asplode "libxml2" unless find_library("#{lib_prefix}xml2", 'xmlParseDoc')
109
119
  asplode "libxslt" unless find_library("#{lib_prefix}xslt", 'xsltParseStylesheetDoc')
110
120
  asplode "libexslt" unless find_library("#{lib_prefix}exslt", 'exsltFuncRegister')
@@ -43,6 +43,26 @@ void vasprintf_free (void *p)
43
43
  #endif
44
44
  #endif
45
45
 
46
+ void nokogiri_root_node(xmlNodePtr node)
47
+ {
48
+ xmlDocPtr doc;
49
+ nokogiriTuplePtr tuple;
50
+
51
+ doc = node->doc;
52
+ if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
53
+ tuple = (nokogiriTuplePtr)doc->_private;
54
+ st_insert(tuple->unlinkedNodes, (st_data_t)node, (st_data_t)node);
55
+ }
56
+
57
+ void nokogiri_root_nsdef(xmlNsPtr ns, xmlDocPtr doc)
58
+ {
59
+ nokogiriTuplePtr tuple;
60
+
61
+ if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
62
+ tuple = (nokogiriTuplePtr)doc->_private;
63
+ st_insert(tuple->unlinkedNodes, (st_data_t)ns, (st_data_t)ns);
64
+ }
65
+
46
66
  void Init_nokogiri()
47
67
  {
48
68
  #if !defined(__MACRUBY__) && !defined(MAGLEV)
@@ -120,11 +120,8 @@ extern VALUE mNokogiriHtml ;
120
120
  extern VALUE mNokogiriHtmlSax ;
121
121
  extern VALUE mNokogiriXslt ;
122
122
 
123
- #define NOKOGIRI_ROOT_NODE(_node) \
124
- st_insert(((nokogiriTuplePtr)(_node)->doc->_private)->unlinkedNodes, (st_data_t)(_node), (st_data_t)(_node))
125
-
126
- #define NOKOGIRI_ROOT_NSDEF(_nsDef, _doc) \
127
- st_insert(((nokogiriTuplePtr)(_doc)->_private)->unlinkedNodes, (st_data_t)(_nsDef), (st_data_t)(_nsDef))
123
+ void nokogiri_root_node(xmlNodePtr);
124
+ void nokogiri_root_nsdef(xmlNsPtr, xmlDocPtr);
128
125
 
129
126
  #ifdef DEBUG
130
127
 
@@ -65,7 +65,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
65
65
  NULL
66
66
  );
67
67
 
68
- NOKOGIRI_ROOT_NODE((xmlNodePtr)node);
68
+ nokogiri_root_node((xmlNodePtr)node);
69
69
 
70
70
  rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)node);
71
71
  rb_obj_call_init(rb_node, argc, argv);
@@ -25,7 +25,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
25
25
  NIL_P(content) ? 0 : (int)RSTRING_LEN(content)
26
26
  );
27
27
 
28
- NOKOGIRI_ROOT_NODE(node);
28
+ nokogiri_root_node(node);
29
29
 
30
30
  rb_node = Nokogiri_wrap_xml_node(klass, node);
31
31
  rb_obj_call_init(rb_node, argc, argv);
@@ -27,7 +27,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
27
27
  rb_node = Nokogiri_wrap_xml_node(klass, node);
28
28
  rb_obj_call_init(rb_node, argc, argv);
29
29
 
30
- NOKOGIRI_ROOT_NODE(node);
30
+ nokogiri_root_node(node);
31
31
 
32
32
  if(rb_block_given_p()) rb_yield(rb_node);
33
33
 
@@ -102,7 +102,7 @@ static VALUE set_root(VALUE self, VALUE root)
102
102
 
103
103
  if(old_root) {
104
104
  xmlUnlinkNode(old_root);
105
- NOKOGIRI_ROOT_NODE(old_root);
105
+ nokogiri_root_node(old_root);
106
106
  }
107
107
 
108
108
  return root;
@@ -121,7 +121,7 @@ static VALUE set_root(VALUE self, VALUE root)
121
121
  }
122
122
 
123
123
  xmlDocSetRootElement(doc, new_root);
124
- if(old_root) NOKOGIRI_ROOT_NODE(old_root);
124
+ if(old_root) nokogiri_root_node(old_root);
125
125
  return root;
126
126
  }
127
127
 
@@ -20,7 +20,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
20
20
 
21
21
  node = xmlNewDocFragment(xml_doc->doc);
22
22
 
23
- NOKOGIRI_ROOT_NODE(node);
23
+ nokogiri_root_node(node);
24
24
 
25
25
  rb_node = Nokogiri_wrap_xml_node(klass, node);
26
26
  rb_obj_call_init(rb_node, argc, argv);
@@ -24,7 +24,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
24
24
  (const xmlChar *)StringValuePtr(name)
25
25
  );
26
26
 
27
- NOKOGIRI_ROOT_NODE(node);
27
+ nokogiri_root_node(node);
28
28
 
29
29
  rb_node = Nokogiri_wrap_xml_node(klass, node);
30
30
  rb_obj_call_init(rb_node, argc, argv);
@@ -51,7 +51,7 @@ static void relink_namespace(xmlNodePtr reparented)
51
51
  } else {
52
52
  reparented->nsDef = curr->next;
53
53
  }
54
- NOKOGIRI_ROOT_NSDEF(curr, reparented->doc);
54
+ nokogiri_root_nsdef(curr, reparented->doc);
55
55
  } else {
56
56
  prev = curr;
57
57
  }
@@ -132,7 +132,7 @@ static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_rep
132
132
  * uninteresting libxml2 implementation detail). as a result, we cannot
133
133
  * reparent the actual reparentee, so we reparent a duplicate.
134
134
  */
135
- NOKOGIRI_ROOT_NODE(reparentee);
135
+ nokogiri_root_node(reparentee);
136
136
  if (!(reparentee = xmlDocCopyNode(reparentee, pivot->doc, 1))) {
137
137
  rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
138
138
  }
@@ -162,7 +162,7 @@ static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_rep
162
162
  new_next_text = xmlDocCopyNode(next_text, pivot->doc, 1) ;
163
163
 
164
164
  xmlUnlinkNode(next_text);
165
- NOKOGIRI_ROOT_NODE(next_text);
165
+ nokogiri_root_node(next_text);
166
166
 
167
167
  xmlAddNextSibling(pivot, new_next_text);
168
168
  }
@@ -375,7 +375,7 @@ static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
375
375
  dup = xmlDocCopyNode(node, node->doc, (int)NUM2INT(level));
376
376
  if(dup == NULL) return Qnil;
377
377
 
378
- NOKOGIRI_ROOT_NODE(dup);
378
+ nokogiri_root_node(dup);
379
379
 
380
380
  return Nokogiri_wrap_xml_node(rb_obj_class(self), dup);
381
381
  }
@@ -391,7 +391,7 @@ static VALUE unlink_node(VALUE self)
391
391
  xmlNodePtr node;
392
392
  Data_Get_Struct(self, xmlNode, node);
393
393
  xmlUnlinkNode(node);
394
- NOKOGIRI_ROOT_NODE(node);
394
+ nokogiri_root_node(node);
395
395
  return self;
396
396
  }
397
397
 
@@ -489,7 +489,7 @@ static VALUE replace(VALUE self, VALUE new_node)
489
489
 
490
490
  xmlNodePtr pivot;
491
491
  Data_Get_Struct(self, xmlNode, pivot);
492
- NOKOGIRI_ROOT_NODE(pivot);
492
+ nokogiri_root_node(pivot);
493
493
 
494
494
  return reparent;
495
495
  }
@@ -681,7 +681,7 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
681
681
  if (prop && prop->children) {
682
682
  for (cur = prop->children; cur; cur = cur->next) {
683
683
  if (cur->_private) {
684
- NOKOGIRI_ROOT_NODE(cur);
684
+ nokogiri_root_node(cur);
685
685
  xmlUnlinkNode(cur);
686
686
  }
687
687
  }
@@ -901,7 +901,7 @@ static VALUE set_content(VALUE self, VALUE content)
901
901
  while (NULL != child) {
902
902
  next = child->next ;
903
903
  xmlUnlinkNode(child) ;
904
- NOKOGIRI_ROOT_NODE(child) ;
904
+ nokogiri_root_node(child);
905
905
  child = next ;
906
906
  }
907
907
 
@@ -1133,7 +1133,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
1133
1133
 
1134
1134
  node = xmlNewNode(NULL, (xmlChar *)StringValuePtr(name));
1135
1135
  node->doc = doc->doc;
1136
- NOKOGIRI_ROOT_NODE(node);
1136
+ nokogiri_root_node(node);
1137
1137
 
1138
1138
  rb_node = Nokogiri_wrap_xml_node(
1139
1139
  klass == cNokogiriXmlNode ? Qnil : klass,
@@ -1322,6 +1322,7 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1322
1322
  VALUE node_cache = Qnil ;
1323
1323
  VALUE rb_node = Qnil ;
1324
1324
  nokogiriTuplePtr node_has_a_document;
1325
+ xmlDocPtr doc;
1325
1326
  void (*mark_method)(xmlNodePtr) = NULL ;
1326
1327
 
1327
1328
  assert(node);
@@ -1332,7 +1333,9 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1332
1333
  /* It's OK if the node doesn't have a fully-realized document (as in XML::Reader). */
1333
1334
  /* see https://github.com/tenderlove/nokogiri/issues/95 */
1334
1335
  /* and https://github.com/tenderlove/nokogiri/issues/439 */
1335
- node_has_a_document = DOC_RUBY_OBJECT_TEST(node->doc);
1336
+ doc = node->doc;
1337
+ if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
1338
+ node_has_a_document = DOC_RUBY_OBJECT_TEST(doc);
1336
1339
 
1337
1340
  if(node->_private && node_has_a_document)
1338
1341
  return (VALUE)node->_private;
@@ -1397,8 +1400,8 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1397
1400
  node->_private = (void *)rb_node;
1398
1401
 
1399
1402
  if (node_has_a_document) {
1400
- document = DOC_RUBY_OBJECT(node->doc);
1401
- node_cache = DOC_NODE_CACHE(node->doc);
1403
+ document = DOC_RUBY_OBJECT(doc);
1404
+ node_cache = DOC_NODE_CACHE(doc);
1402
1405
  rb_ary_push(node_cache, rb_node);
1403
1406
  rb_funcall(document, decorate, 1, rb_node);
1404
1407
  }
@@ -27,7 +27,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
27
27
  (const xmlChar *)StringValuePtr(content)
28
28
  );
29
29
 
30
- NOKOGIRI_ROOT_NODE(node);
30
+ nokogiri_root_node(node);
31
31
 
32
32
  rb_node = Nokogiri_wrap_xml_node(klass, node);
33
33
  rb_obj_call_init(rb_node, argc, argv);
@@ -22,7 +22,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
22
22
  node = xmlNewText((xmlChar *)StringValuePtr(string));
23
23
  node->doc = doc->doc;
24
24
 
25
- NOKOGIRI_ROOT_NODE(node);
25
+ nokogiri_root_node(node);
26
26
 
27
27
  rb_node = Nokogiri_wrap_xml_node(klass, node) ;
28
28
  rb_obj_call_init(rb_node, argc, argv);
@@ -196,7 +196,7 @@ static void xpath_generic_exception_handler(void * ctx, const char *msg, ...)
196
196
  vasprintf(&message, msg, args);
197
197
  va_end(args);
198
198
 
199
- rb_raise(rb_eRuntimeError, message);
199
+ rb_raise(rb_eRuntimeError, "%s", message);
200
200
  }
201
201
 
202
202
  /*
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.5.3'
3
+ VERSION = '1.5.4'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -3,10 +3,11 @@ module Nokogiri
3
3
  ##
4
4
  # Nokogiri::XML::Document is the main entry point for dealing with
5
5
  # XML documents. The Document is created by parsing an XML document.
6
- # See Nokogiri.XML()
6
+ # See Nokogiri::XML::Document.parse() for more information on parsing.
7
7
  #
8
8
  # For searching a Document, see Nokogiri::XML::Node#css and
9
9
  # Nokogiri::XML::Node#xpath
10
+ #
10
11
  class Document < Nokogiri::XML::Node
11
12
  # I'm ignoring unicode characters here.
12
13
  # See http://www.w3.org/TR/REC-xml-names/#ns-decl for more details.
@@ -15,13 +16,30 @@ module Nokogiri
15
16
  NCNAME_RE = /^xmlns(:[#{NCNAME_START_CHAR}][#{NCNAME_CHAR}]*)?$/
16
17
 
17
18
  ##
18
- # Parse an XML file. +string_or_io+ may be a String, or any object that
19
- # responds to _read_ and _close_ such as an IO, or StringIO.
20
- # +url+ is resource where this document is located. +encoding+ is the
21
- # encoding that should be used when processing the document. +options+
22
- # is a number that sets options in the parser, such as
23
- # Nokogiri::XML::ParseOptions::RECOVER. See the constants in
24
- # Nokogiri::XML::ParseOptions.
19
+ # Parse an XML file.
20
+ #
21
+ # +string_or_io+ may be a String, or any object that responds to
22
+ # _read_ and _close_ such as an IO, or StringIO.
23
+ #
24
+ # +url+ (optional) is the URI where this document is located.
25
+ #
26
+ # +encoding+ (optional) is the encoding that should be used when processing
27
+ # the document.
28
+ #
29
+ # +options+ (optional) is a configuration object that sets options during
30
+ # parsing, such as Nokogiri::XML::ParseOptions::RECOVER. See the
31
+ # Nokogiri::XML::ParseOptions for more information.
32
+ #
33
+ # +block+ (optional) is passed a configuration object on which
34
+ # parse options may be set.
35
+ #
36
+ # When parsing untrusted documents, it's recommended that the
37
+ # +nonet+ option be used, as shown in this example code:
38
+ #
39
+ # Nokogiri::XML::Document.parse(xml_string) { |config| config.nonet }
40
+ #
41
+ # Nokogiri.XML() is a convenience method which will call this method.
42
+ #
25
43
  def self.parse string_or_io, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML, &block
26
44
  options = Nokogiri::XML::ParseOptions.new(options) if Fixnum === options
27
45
  # Give the options to the user
@@ -103,7 +103,7 @@ module Nokogiri
103
103
 
104
104
  xpath(*(paths.map { |path|
105
105
  path = path.to_s
106
- path =~ /^(\.\/|\/|\.\.)/ ? path : CSS.xpath_for(
106
+ path =~ /^(\.\/|\/|\.\.|\.$)/ ? path : CSS.xpath_for(
107
107
  path,
108
108
  :prefix => prefix,
109
109
  :ns => ns
@@ -79,7 +79,7 @@ module Nokogiri
79
79
 
80
80
  paths.each do |path|
81
81
  sub_set += send(
82
- path =~ /^(\.\/|\/)/ ? :xpath : :css,
82
+ path =~ /^(\.\/|\/|\.\.|\.$)/ ? :xpath : :css,
83
83
  *(paths + [ns, handler]).compact
84
84
  )
85
85
  end
@@ -27,7 +27,7 @@ module Nokogiri
27
27
  SAX1 = 1 << 9
28
28
  # Implement XInclude substitution
29
29
  XINCLUDE = 1 << 10
30
- # Forbid network access
30
+ # Forbid network access. Recommended for dealing with untrusted documents.
31
31
  NONET = 1 << 11
32
32
  # Do not reuse the context dictionary
33
33
  NODICT = 1 << 12
@@ -47,7 +47,7 @@ module Nokogiri
47
47
  HUGE = 1 << 19
48
48
 
49
49
  # the default options used for parsing XML documents
50
- DEFAULT_XML = RECOVER
50
+ DEFAULT_XML = RECOVER | NONET
51
51
  # the default options used for parsing HTML documents
52
52
  DEFAULT_HTML = RECOVER | NOERROR | NOWARNING | NONET
53
53
 
@@ -64,6 +64,11 @@ module Nokogiri
64
64
  self
65
65
  end
66
66
 
67
+ def no#{constant.downcase}
68
+ @options &= ~#{constant}
69
+ self
70
+ end
71
+
67
72
  def #{constant.downcase}?
68
73
  #{constant} & @options == #{constant}
69
74
  end
@@ -176,6 +176,11 @@ module Nokogiri
176
176
  assert fragment.children.respond_to?(:awesome!), fragment.children.class
177
177
  end
178
178
 
179
+ def test_add_node_to_doc_fragment_segfault
180
+ frag = Nokogiri::XML::DocumentFragment.new(@xml, '<p>hello world</p>')
181
+ Nokogiri::XML::Comment.new(frag,'moo')
182
+ end
183
+
179
184
  if Nokogiri.uses_libxml?
180
185
  def test_for_libxml_in_context_fragment_parsing_bug_workaround
181
186
  10.times do
@@ -454,6 +454,11 @@ module Nokogiri
454
454
  assert_equal node, @xml.xpath('//address').first
455
455
  end
456
456
 
457
+ def test_at_self
458
+ node = @xml.at('address')
459
+ assert_equal node, node.at('.')
460
+ end
461
+
457
462
  def test_at_xpath
458
463
  node = @xml.at_xpath('//address')
459
464
  nodes = @xml.xpath('//address')
@@ -740,6 +745,11 @@ module Nokogiri
740
745
  assert_equal node.parent, parent_node
741
746
  end
742
747
 
748
+ def test_search_self
749
+ node = @xml.at('//employee')
750
+ assert_equal node.search('.').to_a, [node]
751
+ end
752
+
743
753
  def test_search_by_symbol
744
754
  assert set = @xml.search(:employee)
745
755
  assert 5, set.length
@@ -146,6 +146,11 @@ module Nokogiri
146
146
  assert_equal @xml.xpath('//employee'), custom_employees
147
147
  end
148
148
 
149
+ def test_search_self
150
+ set = @xml.xpath('//staff')
151
+ assert_equal set.to_a, set.search('.').to_a
152
+ end
153
+
149
154
  def test_search_with_custom_object
150
155
  set = @xml.xpath('//staff')
151
156
  custom_employees = set.search('//*[awesome(.)]', Class.new {
@@ -35,6 +35,18 @@ module Nokogiri
35
35
  assert_equal 1 << 1, options.options
36
36
  end
37
37
 
38
+ def test_unsetting
39
+ options = Nokogiri::XML::ParseOptions.new Nokogiri::XML::ParseOptions::DEFAULT_HTML
40
+ assert options.nonet?
41
+ assert options.recover?
42
+ options.nononet.norecover
43
+ assert ! options.nonet?
44
+ assert ! options.recover?
45
+ options.nonet.recover
46
+ assert options.nonet?
47
+ assert options.recover?
48
+ end
49
+
38
50
  def test_chaining
39
51
  options = Nokogiri::XML::ParseOptions.new.recover.noent
40
52
  assert options.recover?
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri-maglev-
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4.20120815005250
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Aaron Patterson
9
9
  - Mike Dalessio
10
10
  - Yoko Harada
11
+ - Tim Elliott
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
@@ -15,7 +16,7 @@ date: 2012-08-14 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: hoe-bundler
18
- requirement: &70236346758540 !ruby/object:Gem::Requirement
19
+ requirement: &70249603047560 !ruby/object:Gem::Requirement
19
20
  none: false
20
21
  requirements:
21
22
  - - ! '>='
@@ -23,10 +24,10 @@ dependencies:
23
24
  version: '1.1'
24
25
  type: :development
25
26
  prerelease: false
26
- version_requirements: *70236346758540
27
+ version_requirements: *70249603047560
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: hoe-debugging
29
- requirement: &70236346757900 !ruby/object:Gem::Requirement
30
+ requirement: &70249603045740 !ruby/object:Gem::Requirement
30
31
  none: false
31
32
  requirements:
32
33
  - - ! '>='
@@ -34,10 +35,10 @@ dependencies:
34
35
  version: 1.0.3
35
36
  type: :development
36
37
  prerelease: false
37
- version_requirements: *70236346757900
38
+ version_requirements: *70249603045740
38
39
  - !ruby/object:Gem::Dependency
39
40
  name: hoe-gemspec
40
- requirement: &70236346774720 !ruby/object:Gem::Requirement
41
+ requirement: &70249603044800 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
43
44
  - - ! '>='
@@ -45,10 +46,10 @@ dependencies:
45
46
  version: '1.0'
46
47
  type: :development
47
48
  prerelease: false
48
- version_requirements: *70236346774720
49
+ version_requirements: *70249603044800
49
50
  - !ruby/object:Gem::Dependency
50
51
  name: hoe-git
51
- requirement: &70236346773040 !ruby/object:Gem::Requirement
52
+ requirement: &70249603043820 !ruby/object:Gem::Requirement
52
53
  none: false
53
54
  requirements:
54
55
  - - ! '>='
@@ -56,10 +57,10 @@ dependencies:
56
57
  version: '1.4'
57
58
  type: :development
58
59
  prerelease: false
59
- version_requirements: *70236346773040
60
+ version_requirements: *70249603043820
60
61
  - !ruby/object:Gem::Dependency
61
62
  name: mini_portile
62
- requirement: &70236346771480 !ruby/object:Gem::Requirement
63
+ requirement: &70249603042500 !ruby/object:Gem::Requirement
63
64
  none: false
64
65
  requirements:
65
66
  - - ! '>='
@@ -67,10 +68,10 @@ dependencies:
67
68
  version: 0.2.2
68
69
  type: :development
69
70
  prerelease: false
70
- version_requirements: *70236346771480
71
+ version_requirements: *70249603042500
71
72
  - !ruby/object:Gem::Dependency
72
73
  name: minitest
73
- requirement: &70236346770640 !ruby/object:Gem::Requirement
74
+ requirement: &70249603041740 !ruby/object:Gem::Requirement
74
75
  none: false
75
76
  requirements:
76
77
  - - ~>
@@ -78,10 +79,10 @@ dependencies:
78
79
  version: 2.2.2
79
80
  type: :development
80
81
  prerelease: false
81
- version_requirements: *70236346770640
82
+ version_requirements: *70249603041740
82
83
  - !ruby/object:Gem::Dependency
83
84
  name: racc
84
- requirement: &70236346769920 !ruby/object:Gem::Requirement
85
+ requirement: &70249603040980 !ruby/object:Gem::Requirement
85
86
  none: false
86
87
  requirements:
87
88
  - - ! '>='
@@ -89,10 +90,21 @@ dependencies:
89
90
  version: 1.4.6
90
91
  type: :development
91
92
  prerelease: false
92
- version_requirements: *70236346769920
93
+ version_requirements: *70249603040980
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: &70249603040300 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0.9'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: *70249603040300
93
105
  - !ruby/object:Gem::Dependency
94
106
  name: rake-compiler
95
- requirement: &70236346768900 !ruby/object:Gem::Requirement
107
+ requirement: &70249603101660 !ruby/object:Gem::Requirement
96
108
  none: false
97
109
  requirements:
98
110
  - - =
@@ -100,10 +112,10 @@ dependencies:
100
112
  version: 0.8.0
101
113
  type: :development
102
114
  prerelease: false
103
- version_requirements: *70236346768900
115
+ version_requirements: *70249603101660
104
116
  - !ruby/object:Gem::Dependency
105
117
  name: rexical
106
- requirement: &70236346832320 !ruby/object:Gem::Requirement
118
+ requirement: &70249603100880 !ruby/object:Gem::Requirement
107
119
  none: false
108
120
  requirements:
109
121
  - - ! '>='
@@ -111,10 +123,10 @@ dependencies:
111
123
  version: 1.0.5
112
124
  type: :development
113
125
  prerelease: false
114
- version_requirements: *70236346832320
126
+ version_requirements: *70249603100880
115
127
  - !ruby/object:Gem::Dependency
116
128
  name: rdoc
117
- requirement: &70236346831540 !ruby/object:Gem::Requirement
129
+ requirement: &70249603100140 !ruby/object:Gem::Requirement
118
130
  none: false
119
131
  requirements:
120
132
  - - ~>
@@ -122,10 +134,10 @@ dependencies:
122
134
  version: '3.10'
123
135
  type: :development
124
136
  prerelease: false
125
- version_requirements: *70236346831540
137
+ version_requirements: *70249603100140
126
138
  - !ruby/object:Gem::Dependency
127
139
  name: hoe
128
- requirement: &70236346830780 !ruby/object:Gem::Requirement
140
+ requirement: &70249603099380 !ruby/object:Gem::Requirement
129
141
  none: false
130
142
  requirements:
131
143
  - - ~>
@@ -133,7 +145,7 @@ dependencies:
133
145
  version: '2.16'
134
146
  type: :development
135
147
  prerelease: false
136
- version_requirements: *70236346830780
148
+ version_requirements: *70249603099380
137
149
  description: ! 'Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among Nokogiri''s
138
150
 
139
151
  many features is the ability to search documents via XPath or CSS3 selectors.
@@ -146,6 +158,7 @@ email:
146
158
  - aaronp@rubyforge.org
147
159
  - mike.dalessio@gmail.com
148
160
  - yokolet@gmail.com
161
+ - tle@holymonkey.com
149
162
  executables:
150
163
  - nokogiri
151
164
  extensions:
@@ -159,19 +172,13 @@ extra_rdoc_files:
159
172
  - README.rdoc
160
173
  - ext/nokogiri/html_element_description.c
161
174
  - ext/nokogiri/html_entity_lookup.c
162
- - ext/nokogiri/xml_attr.c
163
175
  - ext/nokogiri/xml_attribute_decl.c
164
- - ext/nokogiri/xml_cdata.c
165
- - ext/nokogiri/xml_comment.c
166
- - ext/nokogiri/xml_document_fragment.c
167
176
  - ext/nokogiri/xml_dtd.c
168
177
  - ext/nokogiri/xml_element_content.c
169
178
  - ext/nokogiri/xml_element_decl.c
170
179
  - ext/nokogiri/xml_encoding_handler.c
171
180
  - ext/nokogiri/xml_entity_decl.c
172
- - ext/nokogiri/xml_entity_reference.c
173
181
  - ext/nokogiri/xml_libxml2_hacks.c
174
- - ext/nokogiri/xml_processing_instruction.c
175
182
  - ext/nokogiri/xml_sax_parser.c
176
183
  - ext/nokogiri/st.c
177
184
  - ext/nokogiri/xml_reader.c
@@ -181,17 +188,23 @@ extra_rdoc_files:
181
188
  - ext/nokogiri/xml_syntax_error.c
182
189
  - ext/nokogiri/html_document.c
183
190
  - ext/nokogiri/html_sax_push_parser.c
184
- - ext/nokogiri/nokogiri.c
185
191
  - ext/nokogiri/xml_io.c
186
192
  - ext/nokogiri/xml_namespace.c
187
- - ext/nokogiri/xml_text.c
188
193
  - ext/nokogiri/xslt_stylesheet.c
189
- - ext/nokogiri/xml_xpath_context.c
190
194
  - ext/nokogiri/xml_sax_parser_context.c
191
195
  - ext/nokogiri/xml_node_set.c
196
+ - ext/nokogiri/html_sax_parser_context.c
197
+ - ext/nokogiri/xml_attr.c
198
+ - ext/nokogiri/xml_cdata.c
199
+ - ext/nokogiri/xml_comment.c
200
+ - ext/nokogiri/xml_document_fragment.c
201
+ - ext/nokogiri/xml_entity_reference.c
202
+ - ext/nokogiri/xml_processing_instruction.c
203
+ - ext/nokogiri/xml_text.c
204
+ - ext/nokogiri/xml_xpath_context.c
192
205
  - ext/nokogiri/xml_node.c
193
206
  - ext/nokogiri/xml_document.c
194
- - ext/nokogiri/html_sax_parser_context.c
207
+ - ext/nokogiri/nokogiri.c
195
208
  files:
196
209
  - .autotest
197
210
  - .gemtest
@@ -451,7 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
451
464
  - !ruby/object:Gem::Version
452
465
  version: '0'
453
466
  requirements: []
454
- rubyforge_project: maglev-nokogiri
467
+ rubyforge_project: nokogiri-maglev-
455
468
  rubygems_version: 1.8.11
456
469
  signing_key:
457
470
  specification_version: 3
@@ -490,7 +503,6 @@ test_files:
490
503
  - test/xml/test_entity_decl.rb
491
504
  - test/xml/test_entity_reference.rb
492
505
  - test/xml/test_node_encoding.rb
493
- - test/xml/test_parse_options.rb
494
506
  - test/xml/test_processing_instruction.rb
495
507
  - test/xml/test_relax_ng.rb
496
508
  - test/xml/test_schema.rb
@@ -500,19 +512,20 @@ test_files:
500
512
  - test/xml/test_c14n.rb
501
513
  - test/xml/test_cdata.rb
502
514
  - test/xml/test_document_encoding.rb
503
- - test/xml/test_document_fragment.rb
504
515
  - test/xml/test_namespace.rb
505
516
  - test/xml/test_node_attributes.rb
506
517
  - test/xml/test_node_inheritance.rb
507
518
  - test/xml/test_node_reparenting.rb
508
- - test/xml/test_node_set.rb
509
519
  - test/xml/test_reader_encoding.rb
510
520
  - test/xml/test_text.rb
511
521
  - test/xml/test_unparented_node.rb
512
522
  - test/xml/test_xinclude.rb
513
523
  - test/xml/test_xpath.rb
514
- - test/xml/test_node.rb
515
524
  - test/xml/test_document.rb
525
+ - test/xml/test_document_fragment.rb
526
+ - test/xml/test_node_set.rb
527
+ - test/xml/test_parse_options.rb
528
+ - test/xml/test_node.rb
516
529
  - test/xslt/test_exception_handling.rb
517
530
  - test/xslt/test_custom_functions.rb
518
531
  - test/test_nokogiri.rb