-
-
Notifications
You must be signed in to change notification settings - Fork 37.2k
is_allowed_path() incorrectly returning False #12807
Copy link
Copy link
Closed
Description
This function is returning False for valid paths as raised in #12788. I've extracted the responsible code below to illustrate:
path = '/Users/robincole/.homeassistant' # Assume this is whitelisted
pathlib.Path(path).is_dir() # Returns True
parent = pathlib.Path(path).parent
parent.relative_to(path)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-29-e4a2522c8d67> in <module>()
1 path = '/Users/robincole/.homeassistant' # Assume this is whitelisted
2 parent = pathlib.Path(path).parent
----> 3 parent.relative_to(path)
/anaconda3/lib/python3.6/pathlib.py in relative_to(self, *other)
868 formatted = self._format_parsed_parts(to_drv, to_root, to_parts)
869 raise ValueError("{!r} does not start with {!r}"
--> 870 .format(str(self), str(formatted)))
871 return self._from_parsed_parts('', root if n == 1 else '',
872 abs_parts[n:])
ValueError: '/Users/robincole' does not start with '/Users/robincole/.homeassistant'
I believe @pvizeli last edited this code.
Cheers
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.