From bd801b35d9310102a68e84a22447cfef92d8c3b1 Mon Sep 17 00:00:00 2001 From: etomm Date: Tue, 22 Nov 2016 04:07:57 +0100 Subject: [PATCH] File names that has a : in position 1 makes guessit split_path to infinite loop --- libs/guessit/fileutils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/guessit/fileutils.py b/libs/guessit/fileutils.py index de30b8d..993952a 100755 --- a/libs/guessit/fileutils.py +++ b/libs/guessit/fileutils.py @@ -23,6 +23,7 @@ from guessit import s, u import os.path import zipfile import io +import re def split_path(path): @@ -45,6 +46,13 @@ def split_path(path): while True: head, tail = os.path.split(path) headlen = len(head) + + # if a string has a : in position 1 it gets splitted in everycase, also if + # there is not a valid drive letter and also if : is not followed by \ + if headlen >= 2 and headlen <= 3 and head[1] == ':' and ( head + tail == path ) and ( head[1:] != ':\\' or not re.match("^[a-zA-Z]:\\\\", head) ): + tail = path + head = '' + headlen = 0 # on Unix systems, the root folder is '/' if head and head == '/'*headlen and tail == '':