mirror of
https://github.com/pypiserver/pypiserver
synced 2024-11-09 16:45:51 +01:00
Check if a file is a proper package before showing it
In case the package repository contains several file types, the server exposes all by default. For instance, it exposes html files as package files...
This commit is contained in:
parent
39316bb56a
commit
e7e34471c1
@ -69,7 +69,8 @@ def guess_pkgname_and_version(path):
|
||||
path = os.path.basename(path)
|
||||
if path.endswith(".whl"):
|
||||
return _guess_pkgname_and_version_wheel(path)
|
||||
|
||||
if not _archive_suffix_rx.search(path):
|
||||
return
|
||||
path = _archive_suffix_rx.sub('', path)
|
||||
if '-' not in path:
|
||||
pkgname, version = path, ''
|
||||
@ -111,7 +112,11 @@ def listdir(root):
|
||||
fn = os.path.join(root, dirpath, x)
|
||||
if not is_allowed_path(x) or not os.path.isfile(fn):
|
||||
continue
|
||||
pkgname, version = guess_pkgname_and_version(x)
|
||||
res = guess_pkgname_and_version(x)
|
||||
if not res:
|
||||
##Seems the current file isn't a proper package
|
||||
continue
|
||||
pkgname, version = res
|
||||
if pkgname:
|
||||
yield pkgfile(fn=fn, root=root, relfn=fn[len(root) + 1:],
|
||||
pkgname=pkgname,
|
||||
|
Loading…
Reference in New Issue
Block a user