eregon/epath — pull request #6 by blambeau (2012-01-11 10:14:48+00:00)
Title: Path#< (through Comparable)

My main aim here is to provide a quick and dirty way to check whether a path is outside or inside another one. Typically useful to check whether someone tries to cheat:

project_dir = Path.backfind('.[config.ru]')
requested = project_dir/non_trustworthy_input
if requested < project_dir
403 # forbidden
else
send_file requested
end

Now, I must admit that this is probably not the adequate way to go. Probably Path#child_of?, Path#outside?, Path#inside? In any case, as Path#<=> exists, it makes sense to include Comparable.

What do you think?