mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
77204d5391
commit
8588e7631e
3 changed files with 22 additions and 2 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
Thu Apr 15 22:33:35 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* 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@fsij.org>
|
Thu Apr 15 21:54:39 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* tool/file2lastrev.rb: use backtick for ruby 1.8.
|
* tool/file2lastrev.rb: use backtick for ruby 1.8.
|
||||||
|
|
|
@ -118,12 +118,13 @@ module URI
|
||||||
# +opaque+, +query+ and +fragment+, in that order.
|
# +opaque+, +query+ and +fragment+, in that order.
|
||||||
#
|
#
|
||||||
def initialize(*arg)
|
def initialize(*arg)
|
||||||
|
arg[5] = arg[5].sub(/^\//,'').sub(/^%2F/,'/')
|
||||||
super(*arg)
|
super(*arg)
|
||||||
@typecode = nil
|
@typecode = nil
|
||||||
tmp = @path.index(TYPECODE_PREFIX)
|
tmp = @path.index(TYPECODE_PREFIX)
|
||||||
if tmp
|
if tmp
|
||||||
typecode = @path[tmp + TYPECODE_PREFIX.size..-1]
|
typecode = @path[tmp + TYPECODE_PREFIX.size..-1]
|
||||||
self.set_path(@path[0..tmp - 1])
|
@path = @path[0..tmp - 1]
|
||||||
|
|
||||||
if arg[-1]
|
if arg[-1]
|
||||||
self.typecode = typecode
|
self.typecode = typecode
|
||||||
|
@ -185,6 +186,11 @@ module URI
|
||||||
return @path.sub(/^\//,'').sub(/^%2F/,'/')
|
return @path.sub(/^\//,'').sub(/^%2F/,'/')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_path(v)
|
||||||
|
super("/" + v.sub(/^\//, "%2F"))
|
||||||
|
end
|
||||||
|
protected :set_path
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
save_path = nil
|
save_path = nil
|
||||||
if @typecode
|
if @typecode
|
||||||
|
|
|
@ -482,7 +482,9 @@ module URI
|
||||||
"path conflicts with opaque"
|
"path conflicts with opaque"
|
||||||
end
|
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
|
if v && v != '' && parser.regexp[:ABS_PATH] !~ v
|
||||||
raise InvalidComponentError,
|
raise InvalidComponentError,
|
||||||
"bad component(expected absolute path component): #{v}"
|
"bad component(expected absolute path component): #{v}"
|
||||||
|
|
Loading…
Reference in a new issue