Fix issue with symlink path detection

Fixes #7627
Fixes #7664