[前][次][番号順一覧][スレッド一覧]

ruby-changes:8920

From: matz <ko1@a...>
Date: Wed, 3 Dec 2008 09:42:15 +0900 (JST)
Subject: [ruby-changes:8920] Ruby:r20455 (ruby_1_8): * lib/rexml/xpath.rb (REXML::XPath.first): apply documentation

matz	2008-12-03 09:42:02 +0900 (Wed, 03 Dec 2008)

  New Revision: 20455

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20455

  Log:
    * lib/rexml/xpath.rb (REXML::XPath.first): apply documentation
      patch from Ken Bloom in [ruby-core:20213].
    * lib/rexml/xpath.rb (REXML::XPath.each): ditto.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/lib/rexml/xpath.rb

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 20454)
+++ ruby_1_8/ChangeLog	(revision 20455)
@@ -1,3 +1,10 @@
+Wed Dec  3 09:26:29 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* lib/rexml/xpath.rb (REXML::XPath.first): apply documentation
+	  patch from Ken Bloom in [ruby-core:20213].
+
+	* lib/rexml/xpath.rb (REXML::XPath.each): ditto.
+
 Tue Dec  2 18:23:33 2008  Yukihiro Matsumoto  <matz@r...>
 
 	* configure.in: detect stdio buffer pointers for uClibc.  a patch
Index: ruby_1_8/lib/rexml/xpath.rb
===================================================================
--- ruby_1_8/lib/rexml/xpath.rb	(revision 20454)
+++ ruby_1_8/lib/rexml/xpath.rb	(revision 20455)
@@ -15,10 +15,15 @@
 		# 	node matching '*'.
 		# namespaces::
 		# 	If supplied, a Hash which defines a namespace mapping.
+		# variables::
+		#       If supplied, a Hash which maps $variables in the query
+		#       to values. This can be used to avoid XPath injection attacks
+		#       or to automatically handle escaping string values.
 		#
 		#  XPath.first( node )
 		#  XPath.first( doc, "//b"} )
 		#  XPath.first( node, "a/x:b", { "x"=>"http://doofus" } )
+		#  XPath.first( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"})
     def XPath::first element, path=nil, namespaces=nil, variables={}
       raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
       raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
@@ -38,10 +43,16 @@
 		#   The xpath to search for.  If not supplied or nil, defaults to '*'
 		# namespaces::
 		# 	If supplied, a Hash which defines a namespace mapping
+		# variables::
+		#       If supplied, a Hash which maps $variables in the query
+		#       to values. This can be used to avoid XPath injection attacks
+		#       or to automatically handle escaping string values.
 		#
 		#  XPath.each( node ) { |el| ... }
 		#  XPath.each( node, '/*[@attr='v']' ) { |el| ... }
 		#  XPath.each( node, 'ancestor::x' ) { |el| ... }
+		#  XPath.each( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"}) \
+		#    {|el| ... }
 		def XPath::each element, path=nil, namespaces=nil, variables={}, &block
       raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
       raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]