* ext/pathname/lib/pathname.rb (cleanpath_aggressive): make all
separators File::SEPARATOR from File::ALT_SEPARATOR. Reported by Daniel Rikowski. Fixed by Nobuyoshi Nakada. [Bug #9618] * ext/pathname/lib/pathname.rb (cleanpath_conservative): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
391fc2eeec
commit
edacb3a94a
@ -1,3 +1,12 @@
|
|||||||
|
Mon May 5 21:52:35 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/pathname/lib/pathname.rb (cleanpath_aggressive): make all
|
||||||
|
separators File::SEPARATOR from File::ALT_SEPARATOR.
|
||||||
|
Reported by Daniel Rikowski.
|
||||||
|
Fixed by Nobuyoshi Nakada. [Bug #9618]
|
||||||
|
|
||||||
|
* ext/pathname/lib/pathname.rb (cleanpath_conservative): ditto.
|
||||||
|
|
||||||
Mon May 5 21:48:04 2014 Tanaka Akira <akr@fsij.org>
|
Mon May 5 21:48:04 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/pathname/lib/pathname.rb (Pathname#/): Aliased to Pathname#+.
|
* ext/pathname/lib/pathname.rb (Pathname#/): Aliased to Pathname#+.
|
||||||
|
@ -113,6 +113,7 @@ class Pathname
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
||||||
if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
|
if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
|
||||||
names.shift while names[0] == '..'
|
names.shift while names[0] == '..'
|
||||||
end
|
end
|
||||||
@ -161,6 +162,7 @@ class Pathname
|
|||||||
pre, base = r
|
pre, base = r
|
||||||
names.unshift base if base != '.'
|
names.unshift base if base != '.'
|
||||||
end
|
end
|
||||||
|
pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
||||||
if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
|
if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
|
||||||
names.shift while names[0] == '..'
|
names.shift while names[0] == '..'
|
||||||
end
|
end
|
||||||
|
@ -88,6 +88,10 @@ class TestPathname < Test::Unit::TestCase
|
|||||||
defassert(:cleanpath_aggressive, '/', '///a/../..')
|
defassert(:cleanpath_aggressive, '/', '///a/../..')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if DOSISH
|
||||||
|
defassert(:cleanpath_aggressive, 'c:/foo/bar', 'c:\\foo\\bar')
|
||||||
|
end
|
||||||
|
|
||||||
def cleanpath_conservative(path)
|
def cleanpath_conservative(path)
|
||||||
Pathname.new(path).cleanpath(true).to_s
|
Pathname.new(path).cleanpath(true).to_s
|
||||||
end
|
end
|
||||||
@ -124,6 +128,10 @@ class TestPathname < Test::Unit::TestCase
|
|||||||
defassert(:cleanpath_conservative, '/a', '/../.././../a')
|
defassert(:cleanpath_conservative, '/a', '/../.././../a')
|
||||||
defassert(:cleanpath_conservative, 'a/b/../../../../c/../d', 'a/b/../../../../c/../d')
|
defassert(:cleanpath_conservative, 'a/b/../../../../c/../d', 'a/b/../../../../c/../d')
|
||||||
|
|
||||||
|
if DOSISH
|
||||||
|
defassert(:cleanpath_conservative, 'c:/foo/bar', 'c:\\foo\\bar')
|
||||||
|
end
|
||||||
|
|
||||||
if DOSISH_UNC
|
if DOSISH_UNC
|
||||||
defassert(:cleanpath_conservative, '//', '//')
|
defassert(:cleanpath_conservative, '//', '//')
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user