Skip to content

Instantly share code, notes, and snippets.

@simonjodet
Created December 13, 2011 12:28
Show Gist options
  • Save simonjodet/1471967 to your computer and use it in GitHub Desktop.
Save simonjodet/1471967 to your computer and use it in GitHub Desktop.
Check file path doesn't go up too much
path = ".."
rootpath = File.expand_path(".")
realpath = File.expand_path(rootpath + "/" + path)
if realpath == rootpath or realpath.index(rootpath).nil?
puts "You went too far up"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment