Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #253
Some old distributions were built with archive member names that carry a leading
/./or./— medifile 2.1 from the issue is one, every member starts with./. Those names can never be browsed: the listing links to the raw member name, URL handling removes the dot segments, and the file view then looks the cleaned-up path up by exact name, misses, and returns a 404. Every file in such a distribution is unreadable in inspector today.This normalizes member names inside
TarGzDistributionandZipDistributioninstead:.and empty segments and resolves..against the preceding segments, clamped at the archive root, so a listed name can never point outside the distribution.namelist()returns canonical names, andcontents()applies the same normalization to the requested path before looking up the original member name. Files from broken distributions render like any other file; names that were already clean are unchanged (normalization is the identity for them).On the options from the issue: I went with making the files linkable rather than showing a warning and hiding them, since the contents can be served safely — inspector only ever reads members in memory, nothing is extracted to disk. A warning banner could still be added later if knowing a distribution is malformed is useful on its own.
Tests:
tests/test_distribution.pycovers/./,./, and mid-path.members for both tar and zip distributions, unchanged behavior for clean names, and..members/requests staying inside the archive root. Verified against the real medifile 2.1 sdist: all 9 files returned 404 before, all 9 resolve after.