Issue 20761: os.path.join doesn't strip LF or CR (original) (raw)

Created on 2014-02-24 14:10 by ExtraVeral, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg212099 - (view) Author: Tiberiu Dragulinescu (ExtraVeral) Date: 2014-02-24 14:10
>>>d="asdasd"+chr(10) >>>print os.path.normpath(os.path.join('a/b',d,'d')) a\b\asdasd \d LF or CR cannot be part of a URI (rfc1738)
msg212106 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2014-02-24 15:03
> LF or CR cannot be part of a URI But they can be part of a filename, at least on POSIX systems. Are you proposing that only the Windows version of os.path.join strip LF/CR? I don't think that it up to the join function to validate the path, and certainly not to modify the substrings. Would you expect it to complain about this? os.path.join('/', 'AUX')? (AUX is a reserved name and forbidden for file names under Windows.) I don't think it is up to join to validate that the path generated is legal, so I don't think this is a bug in join.
msg212109 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-02-24 15:49
This doesn't sound like a bug. File paths are not URIs: almost all characters are valid in a POSIX filename. Also, sanity checking of user input is up to the caller. I recommend closing this issue.
msg212110 - (view) Author: Tiberiu Dragulinescu (ExtraVeral) Date: 2014-02-24 15:51
The join function should know that it will compose a path with the provided string, so I think it should complain or ignore ilegal path/filename components, in regard to the host OS. But if it is not a valid point of view python-wise, one can check his own path :P On Mon, Feb 24, 2014 at 4:03 PM, Steven D'Aprano <report@bugs.python.org>wrote: > > Steven D'Aprano added the comment: > > > LF or CR cannot be part of a URI > > But they can be part of a filename, at least on POSIX systems. Are you > proposing that only the Windows version of os.path.join strip LF/CR? > > I don't think that it up to the join function to validate the path, and > certainly not to modify the substrings. Would you expect it to complain > about this? os.path.join('/', 'AUX')? (AUX is a reserved name and forbidden > for file names under Windows.) > > I don't think it is up to join to validate that the path generated is > legal, so I don't think this is a bug in join. > > ---------- > nosy: +stevenjd > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue20761> > _______________________________________ >
msg212865 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2014-03-07 09:16
Agreed.
History
Date User Action Args
2022-04-11 14:57:59 admin set github: 64960
2014-03-07 09:16:22 georg.brandl set status: open -> closednosy: + georg.brandlmessages: +
2014-02-24 15:51:29 ExtraVeral set messages: +
2014-02-24 15:49:01 pitrou set resolution: not a bugmessages: + nosy: + pitrou
2014-02-24 15:03:12 steven.daprano set nosy: + steven.dapranomessages: +
2014-02-24 14:10:29 ExtraVeral create