mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 10:41:29 -05:00
[utils] Disallow trailing dot in sanitize_path for a path part
This commit is contained in:
parent
1bb5c511a5
commit
f18ef2d144
2 changed files with 12 additions and 1 deletions
|
@ -152,6 +152,17 @@ def test_sanitize_path(self):
|
||||||
self.assertEqual(sanitize_path('\\\\?\\C:\\ab?c\\de:f'), '\\\\?\\C:\\ab#c\\de#f')
|
self.assertEqual(sanitize_path('\\\\?\\C:\\ab?c\\de:f'), '\\\\?\\C:\\ab#c\\de#f')
|
||||||
self.assertEqual(sanitize_path('\\\\?\\C:\\abc'), '\\\\?\\C:\\abc')
|
self.assertEqual(sanitize_path('\\\\?\\C:\\abc'), '\\\\?\\C:\\abc')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
sanitize_path('youtube/%(uploader)s/%(autonumber)s-%(title)s-%(upload_date)s.%(ext)s'),
|
||||||
|
'youtube\\%(uploader)s\\%(autonumber)s-%(title)s-%(upload_date)s.%(ext)s')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
sanitize_path('youtube/TheWreckingYard ./00001-Not bad, Especially for Free! (1987 Yamaha 700)-20141116.mp4.part'),
|
||||||
|
'youtube\\TheWreckingYard #\\00001-Not bad, Especially for Free! (1987 Yamaha 700)-20141116.mp4.part')
|
||||||
|
self.assertEqual(sanitize_path('abc/def...'), 'abc\\def..#')
|
||||||
|
self.assertEqual(sanitize_path('abc.../def'), 'abc..#\\def')
|
||||||
|
self.assertEqual(sanitize_path('abc.../def...'), 'abc..#\\def..#')
|
||||||
|
|
||||||
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)
|
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 a new issue