Created
November 14, 2012 00:30
-
-
Save eam/4069375 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'pathname' | |
system "rm -rf /tmp/x /tmp/foo" | |
Dir.mkdir "/tmp/x" | |
Dir.mkdir "/tmp/x/y" | |
File.open "/tmp/x/y/z", "w" do |f| | |
f.puts "hello world" | |
end | |
Dir.chdir "/tmp" | |
File.symlink "/tmp/x/y", "foo" | |
orig_path = "/tmp/foo/../y/z" | |
File.stat "/tmp/foo/z" # works | |
File.stat orig_path # works | |
puts "all these work so far, now let's cleanpath it" | |
clean_path = Pathname.new(orig_path).cleanpath | |
File.stat clean_path # fails, because of a faulty path cleaning algorithm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment