That is odd, perhaps there is a paste error?
$ cat test.py ``` import os def is_safe_path(basedir, path, follow_symlinks=True): # resolves symbolic links if follow_symlinks: return os.path.realpath(path).startswith(basedir) return os.path.abspath(path).startswith(basedir) print(is_safe_path("/home/ad", "../admin/.ssh/id_rsa")) ``` $ python test.py False $ python -V Python 3.7.3
That is odd, perhaps there is a paste error?
$ cat test.py path(basedir, path, follow_ symlinks= True): realpath( path).startswit h(basedir) abspath( path).startswit h(basedir) safe_path( "/home/ ad", "../admin/ .ssh/id_ rsa"))
```
import os
def is_safe_
# resolves symbolic links
if follow_symlinks:
return os.path.
return os.path.
print(is_
```
$ python test.py
False
$ python -V
Python 3.7.3