What’s the best way to defend against a path traversal attack?
NOTE: This answer to another similar question on StackOverflow may be the best approach. Otherwise, the following may help. It compares the canonical and absolute paths, and if they differ, then it’ll fail. Only tested on a mac/linux system (ie no windows). This is for the case where you want to allow the user to … Read more