Skip to content

Commit 00ef334

Browse files
committed
Improve check that backend is in source tree, remove use of commonprefix
1 parent 10093cd commit 00ef334

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/pyproject_hooks/_impl.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,9 @@ def norm_and_check(source_tree: str, requested: str) -> str:
117117

118118
abs_source = os.path.abspath(source_tree)
119119
abs_requested = os.path.normpath(os.path.join(abs_source, requested))
120-
# We have to use commonprefix for Python 2.7 compatibility. So we
121-
# normalise case to avoid problems because commonprefix is a character
122-
# based comparison :-(
123120
norm_source = os.path.normcase(abs_source)
124121
norm_requested = os.path.normcase(abs_requested)
125-
if os.path.commonprefix([norm_source, norm_requested]) != norm_source:
122+
if not norm_requested.startswith(norm_source + os.sep):
126123
raise ValueError("paths must be inside source tree")
127124

128125
return abs_requested

0 commit comments

Comments
 (0)