mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-22 16:44:32 +01:00
[utils] Keep dot and dotdot unmodified (Closes #5171)
This commit is contained in:
parent
f5d8f58a17
commit
2ebfeacabc
@ -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.../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):
|
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([1, 1, 2, 3, 4, 4, 5, 6, 7, 3, 5]), [1, 2, 3, 4, 5, 6, 7])
|
||||||
self.assertEqual(orderedSet([]), [])
|
self.assertEqual(orderedSet([]), [])
|
||||||
|
@ -319,7 +319,7 @@ def sanitize_path(s):
|
|||||||
if unc_or_drive:
|
if unc_or_drive:
|
||||||
norm_path.pop(0)
|
norm_path.pop(0)
|
||||||
sanitized_path = [
|
sanitized_path = [
|
||||||
re.sub('(?:[/<>:"\\|\\\\?\\*]|\.$)', '#', path_part)
|
path_part if path_part in ['.', '..'] else re.sub('(?:[/<>:"\\|\\\\?\\*]|\.$)', '#', path_part)
|
||||||
for path_part in norm_path]
|
for path_part in norm_path]
|
||||||
if unc_or_drive:
|
if unc_or_drive:
|
||||||
sanitized_path.insert(0, unc_or_drive + os.path.sep)
|
sanitized_path.insert(0, unc_or_drive + os.path.sep)
|
||||||
|
Loading…
Reference in New Issue
Block a user