gh-111791: delegating extraction to zipfile module's extractall() method #111824
gh-111791: delegating extraction to zipfile module's extractall() method #111824sepastian wants to merge 10 commits into
Conversation
…to zipfile shutil.unpack_archive fails, if file name contains '..'; zipfile handles everything correctly, i.e. in the same way than 'unzip'; let zipfile unpack archives, instead of reinventing the wheel here
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Filenames containing two dots ".." do not necessarily indicate relative path components. Only "../" identify a relative path component.
|
This is a bug that needs to be fixed. Any progress on this? |
|
This PR is stale because it has been open for 30 days with no activity. |
|
Thank you for your contribution @sepastian and sorry for missing your PR. Similar solution was applied in #146591. I have noticed that your PR fixes also a part of the docs which I missed. We will fix it too. |
|
I detected this problem and provided a fix for this 3 years ago. I asked you specifically, @serhiy-storchaka, about the status of this, that was two years ago. You never replied to me. Although you referenced my PR elsewhere. See #111824 (comment), for example. And now you are merging a copy of my solution, which is only 2 months old, and make this an official contribution? What's going on here? |
|
I admit my guilt. That issue looked like an ordinary bug affecting not many people, until a security issue was reported few months ago, to which this was the simplest solution. I completely forgot about your PR! It seems my memory is failing me. I reviewed almost 2000 PRs in the last 3 years, have more than 100 PRs in my backlog, and add new PRs to it every day. Add to this that some issues need several days to work. It's inevitable that I'll fail many reviews. My apologies. |
What does that mean exactly? I take it for granted that you will apply my PR here, at least. |
Thank you for your time and all the work you put into Python - seriously! My PR is not even tiny compared to that. Still, I put in a lot of work. If my PR had been found not good enough for merging, I would totally understand. If I had received some feedback at the very least, also good. But I have been ignored for three years, even after asking several times. Just silence. Today I have to learn that my idea and solution has been taken and merged under a different name. I understand what you are saying and, among all the things you are doing, this happened. Again, highly appreciate what you do for this project. This is not about blaming someone, I'm just wondering how this can be fixed. Because the way it is now, I'm mad and disappointed. From what you wrote above, I get the impression you are even updating the docs with what I wrote, without mentioning me. This is not acceptable. |
|
Your PR was not not good enough. It just fell out of the attention span. Bad luck. For now, there are 2000 open PRs and 69000 closed PRs. Almost 1000 new PRs created each month, 70% of them are closed in the first month, 90% are closed in the first year, but there are PRs waiting for several years. I try to clean languishing PRs. Your PR somehow fell through my filters. This is a sad lesson for me. I updating the docs in different way: #149994. |

shutil.unpack_archive: deletage extracting ZIP files to
zipfile(#111791)As reported in #111791, if the path of a file inside a ZIP file contains
"..", e.g.myfile..txt(probably misspelled),shutil.unpack_archivewill silently skip extracting the file, because it wrongly assumes a relative path.This is problematic for two reasons:
shutil.unpack_archivewrongly identifies relative path components. Scanning for".."does not tell whether a path contains relative components, or not; one must scan for"../"instead.Python's own
zipfilemodule and theunzipare handling relative path components"../"and names containins".."correctly. For reference, theman unzippage says:Solution: delegate extracting ZIP archives to Python's own
zipfile.extractallmethod.Appendix
The following example shows, how extracting a ZIP archive containing paths containing relative components
"../"and files with names containing".."differs inshutil.unpack_archive,zipfile.extractalland the Linux toolunzip.