nokogiri 1.5.3.rc6-java → 1.5.4-java

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.

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,6 +23,7 @@ HOE = Hoe.spec 'nokogiri' do
23
23
  developer 'Aaron Patterson', 'aaronp@rubyforge.org'
24
24
  developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
25
25
  developer 'Yoko Harada', 'yokolet@gmail.com'
26
+ developer 'Tim Elliott', 'tle@holymonkey.com'
26
27
 
27
28
  self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
28
29
  self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
@@ -45,6 +46,7 @@ HOE = Hoe.spec 'nokogiri' do
45
46
  ["mini_portile", ">= 0.2.2"],
46
47
  ["minitest", "~> 2.2.2"],
47
48
  ["racc", ">= 1.4.6"],
49
+ ["rake", ">= 0.9"],
48
50
  ["rake-compiler", "= 0.8.0"],
49
51
  ["rexical", ">= 1.0.5"],
50
52
  ]
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2011:
4
+ * Copyright (c) 2008 - 2012:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -69,10 +69,19 @@ public class XmlComment extends XmlNode {
69
69
  IRubyObject doc = args[0];
70
70
  IRubyObject text = args[1];
71
71
 
72
- XmlDocument xmlDoc = (XmlDocument) doc;
73
- Document document = xmlDoc.getDocument();
74
- Node node = document.createComment(rubyStringToString(text));
75
- setNode(context, node);
72
+ XmlDocument xmlDoc = null;
73
+ if (doc instanceof XmlDocument) {
74
+ xmlDoc = (XmlDocument) doc;
75
+
76
+ } else if (doc instanceof XmlNode) {
77
+ XmlNode xmlNode = (XmlNode) doc;
78
+ xmlDoc = (XmlDocument)xmlNode.document(context);
79
+ }
80
+ if (xmlDoc != null) {
81
+ Document document = xmlDoc.getDocument();
82
+ Node node = document.createComment(rubyStringToString(text));
83
+ setNode(context, node);
84
+ }
76
85
  }
77
86
 
78
87
  @Override
@@ -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
  #ifndef __MACRUBY__
@@ -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 ? (VALUE)NULL : klass,
@@ -1320,6 +1320,7 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1320
1320
  VALUE node_cache = Qnil ;
1321
1321
  VALUE rb_node = Qnil ;
1322
1322
  nokogiriTuplePtr node_has_a_document;
1323
+ xmlDocPtr doc;
1323
1324
  void (*mark_method)(xmlNodePtr) = NULL ;
1324
1325
 
1325
1326
  assert(node);
@@ -1330,7 +1331,9 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1330
1331
  /* It's OK if the node doesn't have a fully-realized document (as in XML::Reader). */
1331
1332
  /* see https://github.com/tenderlove/nokogiri/issues/95 */
1332
1333
  /* and https://github.com/tenderlove/nokogiri/issues/439 */
1333
- node_has_a_document = DOC_RUBY_OBJECT_TEST(node->doc);
1334
+ doc = node->doc;
1335
+ if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
1336
+ node_has_a_document = DOC_RUBY_OBJECT_TEST(doc);
1334
1337
 
1335
1338
  if(node->_private && node_has_a_document)
1336
1339
  return (VALUE)node->_private;
@@ -1385,8 +1388,8 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1385
1388
  node->_private = (void *)rb_node;
1386
1389
 
1387
1390
  if (node_has_a_document) {
1388
- document = DOC_RUBY_OBJECT(node->doc);
1389
- node_cache = DOC_NODE_CACHE(node->doc);
1391
+ document = DOC_RUBY_OBJECT(doc);
1392
+ node_cache = DOC_NODE_CACHE(doc);
1390
1393
  rb_ary_push(node_cache, rb_node);
1391
1394
  rb_funcall(document, decorate, 1, rb_node);
1392
1395
  }
@@ -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);
@@ -190,7 +190,7 @@ static void xpath_generic_exception_handler(void * ctx, const char *msg, ...)
190
190
  vasprintf(&message, msg, args);
191
191
  va_end(args);
192
192
 
193
- rb_raise(rb_eRuntimeError, message);
193
+ rb_raise(rb_eRuntimeError, "%s", message);
194
194
  }
195
195
 
196
196
  /*
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.7
3
+ # This file is automatically generated by Racc 1.4.8
4
4
  # from Racc grammer file "".
5
5
  #
6
6
 
Binary file
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.5.3.rc6'
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,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 1.5.3.rc6
4
+ prerelease:
5
+ version: 1.5.4
6
6
  platform: java
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: []
14
15
 
15
- date: 2012-05-30 00:00:00 Z
16
+ date: 2012-06-11 00:00:00 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: hoe-bundler
@@ -92,47 +93,58 @@ dependencies:
92
93
  prerelease: false
93
94
  type: :development
94
95
  - !ruby/object:Gem::Dependency
95
- name: rake-compiler
96
+ name: rake
96
97
  version_requirements: &id008 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: "0.9"
103
+ requirement: *id008
104
+ prerelease: false
105
+ type: :development
106
+ - !ruby/object:Gem::Dependency
107
+ name: rake-compiler
108
+ version_requirements: &id009 !ruby/object:Gem::Requirement
97
109
  none: false
98
110
  requirements:
99
111
  - - "="
100
112
  - !ruby/object:Gem::Version
101
113
  version: 0.8.0
102
- requirement: *id008
114
+ requirement: *id009
103
115
  prerelease: false
104
116
  type: :development
105
117
  - !ruby/object:Gem::Dependency
106
118
  name: rexical
107
- version_requirements: &id009 !ruby/object:Gem::Requirement
119
+ version_requirements: &id010 !ruby/object:Gem::Requirement
108
120
  none: false
109
121
  requirements:
110
122
  - - ">="
111
123
  - !ruby/object:Gem::Version
112
124
  version: 1.0.5
113
- requirement: *id009
125
+ requirement: *id010
114
126
  prerelease: false
115
127
  type: :development
116
128
  - !ruby/object:Gem::Dependency
117
129
  name: rdoc
118
- version_requirements: &id010 !ruby/object:Gem::Requirement
130
+ version_requirements: &id011 !ruby/object:Gem::Requirement
119
131
  none: false
120
132
  requirements:
121
133
  - - ~>
122
134
  - !ruby/object:Gem::Version
123
135
  version: "3.10"
124
- requirement: *id010
136
+ requirement: *id011
125
137
  prerelease: false
126
138
  type: :development
127
139
  - !ruby/object:Gem::Dependency
128
140
  name: hoe
129
- version_requirements: &id011 !ruby/object:Gem::Requirement
141
+ version_requirements: &id012 !ruby/object:Gem::Requirement
130
142
  none: false
131
143
  requirements:
132
144
  - - ~>
133
145
  - !ruby/object:Gem::Version
134
- version: "2.13"
135
- requirement: *id011
146
+ version: "2.16"
147
+ requirement: *id012
136
148
  prerelease: false
137
149
  type: :development
138
150
  description: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser. Among Nokogiri's\n\
@@ -143,17 +155,18 @@ email:
143
155
  - aaronp@rubyforge.org
144
156
  - mike.dalessio@gmail.com
145
157
  - yokolet@gmail.com
158
+ - tle@holymonkey.com
146
159
  executables:
147
160
  - nokogiri
148
161
  extensions: []
149
162
 
150
163
  extra_rdoc_files:
151
- - Manifest.txt
152
164
  - CHANGELOG.ja.rdoc
165
+ - CHANGELOG.rdoc
166
+ - C_CODING_STYLE.rdoc
167
+ - Manifest.txt
153
168
  - README.ja.rdoc
154
169
  - README.rdoc
155
- - C_CODING_STYLE.rdoc
156
- - CHANGELOG.rdoc
157
170
  - ext/nokogiri/xml_encoding_handler.c
158
171
  - ext/nokogiri/html_sax_push_parser.c
159
172
  - ext/nokogiri/xml_processing_instruction.c
@@ -506,9 +519,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
506
519
  required_rubygems_version: !ruby/object:Gem::Requirement
507
520
  none: false
508
521
  requirements:
509
- - - ">"
522
+ - - ">="
510
523
  - !ruby/object:Gem::Version
511
- version: 1.3.1
524
+ version: "0"
512
525
  requirements: []
513
526
 
514
527
  rubyforge_project: nokogiri