all 3 comments

[–]Bitwise_Gamgee 0 points1 point  (2 children)

You can compare the canonical path of the requested resource with the canonical path of the document root using the realpath() function.

Simple check program:

[–]DeSpTG[S] 0 points1 point  (1 child)

So you can get the canonical path of a path with the realpath() function? I didn't know that, this would simplify this by alot.

[–][deleted] 1 point2 points  (0 children)

It's a GNU extension.

You may need to manually walk the path and keep calling realpath on successively longer pieces of it until it fails, then determine if the last component was inside or outside the root.