diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index 70bdb495c5ff48489570ab45557601664cdd37f5..6d26553bead151a0173202239af1ee51ef6b5fde 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -1402,12 +1402,18 @@ def parse_args(): def split_restricted_path(path): - elements = [] - while path != "/": - path, el = os.path.split(path) - if el != "": - elements.insert(0, el) - return elements + """ + Split a path string into components separated by slashes or other os.path.sep. + Empty elements will be removed. + """ + # This implementation leads to infinite loops + # for "ill-posed" paths (see test_utilities.py"): + # elements = [] + # while path != "/": + # path, el = os.path.split(path) + # if el != "": + # elements.insert(0, el) + return [i for i in path.split(os.path.sep) if i != ""] def main():