[issue43810] os.path.abspath returns invalid path (resolves symbolic link)

2021-04-13 Thread Rene Visser

Rene Visser  added the comment:

Thanks Eryk for your fast response. Apparently I somehow skipped the remark
about symbolic links in combination with abspath. Thank you for pointing
this out and apologies for wasting some of your time!!
Best wishes, Rene Visser

On Mon, Apr 12, 2021 at 7:40 AM Eryk Sun  wrote:

>
> Eryk Sun  added the comment:
>
> In POSIX, os.path.abspath(p) is normpath(join(os.getcwd(), p)). normpath()
> doesn't touch the filesystem, and it's documented that its "string
> manipulation may change the meaning of a path that contains symbolic
> links". You can use os.path.realpath() to resolve symbolic links in a path.
>
> --
> nosy: +eryksun
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> <https://bugs.python.org/issue43810>
> ___
>

-- 

---

René Visser
Stuttgart, Germany
email: renevis...@gmail.com

---

--

___
Python tracker 
<https://bugs.python.org/issue43810>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43810] os.path.abspath returns invalid path (resolves symbolic link)

2021-04-11 Thread Rene Visser


New submission from Rene Visser :

According to the python documentation os.path.abspath() does *not* resolve 
symbolic links. This however does not always seem to be true causing an invalid 
path return by abspath. This could potentially be exploited to crash python 
applications.

Example for bug reproduction on a linux terminal:
1. create a sub-directory "bug_abspath"
2. enter the sub-dir "bug_abspath"
3. create a symbolic link "local_link" onto the current dir using: "ln -s . 
local_link"
4. open python session and import os and enter the following:
5. path_correct = os.path.abspath('./../bug_abspath')  # returns correct path
6. path_invalid = os.path.abspath('local_link/../bug_abspath')  # returns 
invalid path with wrongly resolved "local_link"

>From step 5 the correct/valid path is returned, from step 6 abspath returns an 
>invalid path that is non-existing (contains non-existing 
>"bug_abspath/bug_abspath" string. 
I consider this behavior incorrect and interpret it as a bug in the abspath 
routine which is not allowed to resolve the symbolic link "local_link".
(Note os.path.realpath works as expected but is unwanted by me).

Tested on
OS: linux ubuntu 20.04, CentOS 7.8
PY: python 3.7 and 3.8

Thanks for any help, best wishes, Rene

--
components: IO
messages: 390818
nosy: rvisser
priority: normal
severity: normal
status: open
title: os.path.abspath returns invalid path (resolves symbolic link)
type: behavior
versions: Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue43810>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com