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

ruby-changes:15451

From: mame <ko1@a...>
Date: Thu, 15 Apr 2010 22:42:19 +0900 (JST)
Subject: [ruby-changes:15451] Ruby:r27350 (trunk): * lib/uri/ftp.rb (URI::FTP#set_path): added to correct handling of

mame	2010-04-15 22:41:19 +0900 (Thu, 15 Apr 2010)

  New Revision: 27350

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

  Log:
    * lib/uri/ftp.rb (URI::FTP#set_path): added to correct handling of
      special case where path of ftp is relative.  This converts relative
      path to absolute one, because external representation of ftp path is
      relative and internal representation is absolute.  [ruby-core:24077]
    
    * lib/uri/ftp.rb (URI::FTP#initialize): converts absolute to relative.
    
    * lib/uri/generic.rb (URI::Generic#check_path): allow relative path
      when scheme is ftp.

  Modified files:
    trunk/ChangeLog
    trunk/lib/uri/ftp.rb
    trunk/lib/uri/generic.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27349)
+++ ChangeLog	(revision 27350)
@@ -1,3 +1,15 @@
+Thu Apr 15 22:33:35 2010  Yusuke Endoh  <mame@t...>
+
+	* lib/uri/ftp.rb (URI::FTP#set_path): added to correct handling of
+	  special case where path of ftp is relative.  This converts relative
+	  path to absolute one, because external representation of ftp path is
+	  relative and internal representation is absolute.  [ruby-core:24077]
+
+	* lib/uri/ftp.rb (URI::FTP#initialize): converts absolute to relative.
+
+	* lib/uri/generic.rb (URI::Generic#check_path): allow relative path
+	  when scheme is ftp.
+
 Thu Apr 15 21:54:39 2010  Tanaka Akira  <akr@f...>
 
 	* tool/file2lastrev.rb: use backtick for ruby 1.8.
Index: lib/uri/ftp.rb
===================================================================
--- lib/uri/ftp.rb	(revision 27349)
+++ lib/uri/ftp.rb	(revision 27350)
@@ -118,12 +118,13 @@
     # +opaque+, +query+ and +fragment+, in that order.
     #
     def initialize(*arg)
+      arg[5] = arg[5].sub(/^\//,'').sub(/^%2F/,'/')
       super(*arg)
       @typecode = nil
       tmp = @path.index(TYPECODE_PREFIX)
       if tmp
         typecode = @path[tmp + TYPECODE_PREFIX.size..-1]
-        self.set_path(@path[0..tmp - 1])
+        @path = @path[0..tmp - 1]
 
         if arg[-1]
           self.typecode = typecode
@@ -185,6 +186,11 @@
       return @path.sub(/^\//,'').sub(/^%2F/,'/')
     end
 
+    def set_path(v)
+      super("/" + v.sub(/^\//, "%2F"))
+    end
+    protected :set_path
+
     def to_s
       save_path = nil
       if @typecode
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 27349)
+++ lib/uri/generic.rb	(revision 27350)
@@ -482,7 +482,9 @@
           "path conflicts with opaque"
       end
 
-      if @scheme
+      # If scheme is ftp, path may be relative.
+      # See RFC 1738 section 3.2.2, and RFC 2396.
+      if @scheme && @scheme != "ftp"
         if v && v != '' && parser.regexp[:ABS_PATH] !~ v
           raise InvalidComponentError,
             "bad component(expected absolute path component): #{v}"

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

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