Skip to content

Commit 0f8482a

Browse files
committed
Add additional check for project.license.file
1 parent 5f8c75f commit 0f8482a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

flit_core/flit_core/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,13 @@ def read_pep621_metadata(proj, path) -> LoadedConfig:
608608
raise ConfigError(
609609
f"License file path ({license_f}) cannot be an absolute path"
610610
)
611+
if ".." in license_f:
612+
raise ConfigError(
613+
f"License file path ({license_f}) cannot contain '..'"
614+
)
611615
if not (path.parent / license_f).is_file():
612616
raise ConfigError(f"License file {license_f} does not exist")
613-
license_files.add(license_tbl['file'])
617+
license_files.add(license_f)
614618
elif 'text' in license_tbl:
615619
pass
616620
else:

flit_core/tests_core/test_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import re
23
import sys
34
from pathlib import Path
45
import pytest
@@ -139,6 +140,14 @@ def test_bad_include_paths(path, err_match):
139140
({'version': 1}, r'\bstr\b'),
140141
({'license': {'fromage': 2}}, '[Uu]nrecognised'),
141142
({'license': {'file': 'LICENSE', 'text': 'xyz'}}, 'both'),
143+
(
144+
{'license': {'file': '/LICENSE'}},
145+
re.escape("License file path (/LICENSE) cannot be an absolute path"),
146+
),
147+
(
148+
{'license': {'file': '../LICENSE'}},
149+
re.escape("License file path (../LICENSE) cannot contain '..'"),
150+
),
142151
({'license': {}}, 'required'),
143152
({'license': 1}, "license field should be <class 'str'> or <class 'dict'>, not <class 'int'>"),
144153
# ({'license': "MIT License"}, "Invalid license expression: 'MIT License'"), # TODO

0 commit comments

Comments
 (0)