Skip to content

Commit

Permalink
Normalize both paths for check
Browse files Browse the repository at this point in the history
  • Loading branch information
sjagoe committed Dec 3, 2023
1 parent 1fe77a7 commit d0b9174
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions haas/plugins/discoverer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ def test_error(self):


def get_relpath(top_level_directory, fullpath):
normalized_top_level = os.path.normpath(top_level_directory)
normalized = os.path.normpath(fullpath)
logger.debug('Determine if %r is within %r',
normalized, top_level_directory)
relpath = os.path.relpath(normalized, top_level_directory)
normalized, normalized_top_level)
relpath = os.path.relpath(normalized, normalized_top_level)
logger.debug('Relative path is %r', relpath)
if os.path.isabs(relpath) or relpath.startswith('..'):
raise ValueError('Path not within project: {0}'.format(fullpath))
Expand Down

0 comments on commit d0b9174

Please sign in to comment.