]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[utils] Keep dot and dotdot unmodified (Closes #5171)
authorSergey M․ <dstftw@gmail.com>
Mon, 9 Mar 2015 18:50:11 +0000 (00:50 +0600)
committerSergey M․ <dstftw@gmail.com>
Mon, 9 Mar 2015 18:50:11 +0000 (00:50 +0600)
test/test_utils.py
youtube_dl/utils.py

index 28bda654e2bc88a41d7145b73c59a621cb0d94cc..8f790bf0a7853e4fd3ed391a5169e50da2600a5b 100644 (file)
@@ -163,6 +163,11 @@ class TestUtil(unittest.TestCase):
         self.assertEqual(sanitize_path('abc.../def'), 'abc..#\\def')
         self.assertEqual(sanitize_path('abc.../def...'), 'abc..#\\def..#')
 
+        self.assertEqual(sanitize_path('../abc'), '..\\abc')
+        self.assertEqual(sanitize_path('../../abc'), '..\\..\\abc')
+        self.assertEqual(sanitize_path('./abc'), 'abc')
+        self.assertEqual(sanitize_path('./../abc'), '..\\abc')
+
     def test_ordered_set(self):
         self.assertEqual(orderedSet([1, 1, 2, 3, 4, 4, 5, 6, 7, 3, 5]), [1, 2, 3, 4, 5, 6, 7])
         self.assertEqual(orderedSet([]), [])
index d5597d514dc502f73fb71ed8456017e4d1a2848b..c3135effc18d0df51982787933c06ceaa851e666 100644 (file)
@@ -319,7 +319,7 @@ def sanitize_path(s):
     if unc_or_drive:
         norm_path.pop(0)
     sanitized_path = [
-        re.sub('(?:[/<>:"\\|\\\\?\\*]|\.$)', '#', path_part)
+        path_part if path_part in ['.', '..'] else re.sub('(?:[/<>:"\\|\\\\?\\*]|\.$)', '#', path_part)
         for path_part in norm_path]
     if unc_or_drive:
         sanitized_path.insert(0, unc_or_drive + os.path.sep)