-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filename character sequence with tilde sometimes causes false error on Linux #152
Comments
That's certainly quite odd — does it reproduce if you simply run https://github.com/python/cpython/blob/3.8/Lib/posixpath.py#L228-L271 |
I modified your test slightly, it confirms the problem. I changed it to The original command you posted does not throw an error but also doesn't print anything.
I don't have an explanation for the issue, but somehow these 4 characters together expand on RHEL anyway. |
Ah, I missed that and it explains the problem: I'm wondering whether we want to remove that part of #88 on the theory that this is being overzealous. I do not want to be in the business of having to try to maintain a separate implementation of |
It looks like it's slightly more subtle -- the sequence "$_-" also causes the problem
while just "$_" does not
and similarly for just "~$_"
So it appears the hyphen helps trigger this. But that makes me think there are other cases lurking. Regarding the bagit.py source code, I'm not sure what the correct choice would be. I suppose you could put some guard around the But I'm not sure specifically what you would do, because you are currently matching a possibly expanded filename against the real one. Probably better to discuss with regular contributors, and ask whether to back out the BTW, a Windows user verified this issue does not occur there, which makes sense because this is a Linux expansion. |
I was thinking that it might be good to discuss this with @runderwood to see whether we have a compelling reason to keep This variable is set by at least the popular Bourne shells and ones like Fish which try to be compatible so I suppose we could purge |
I don't really recall why the While I can see the reasoning that it's safer to disallow potentially dangerous variable expansion, I believe it's system-dependent so you don't really enforce a meaningful universal policy doing it this way. I don't have a compelling argument for keeping it there if it's causing problems. |
Observed on Linux, a failure at line 931 of bagit.py in git commit hash code
bff20d2
RHEL 7.5 (Maipo), Linux 3.10.0-1160.15.2.el7.x86_64 GNU/Linux
Python 3.7.4
using miniconda3File names containing this 4-character sequence cause an "is unsafe" false error due to expansion of the tilde:
~$_-
To reproduce, create a file name such as
data/blah/~$_-expect_fail.doc
In Python v3, do this
A similar test with filename that does not have the hyphen after the underscore
data/blah/~$_expect_success.doc
works OK, i.e. without unwanted expansion of the tilde.
The text was updated successfully, but these errors were encountered: