]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[utils] Streap leading dots
authorPhilipp Hagemeister <phihag@phihag.de>
Mon, 2 Mar 2015 18:07:17 +0000 (19:07 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Mon, 2 Mar 2015 18:07:19 +0000 (19:07 +0100)
Fixes #2865, closes #5087

test/test_utils.py
youtube_dl/utils.py

index 3fba8ae11c3b516d86d82051bb179ac5e15b0a91..64fad58adeb056ccf2388e9be5ad853867c7300b 100644 (file)
@@ -85,8 +85,11 @@ class TestUtil(unittest.TestCase):
         self.assertEqual(
             sanitize_filename('New World record at 0:12:34'),
             'New World record at 0_12_34')
+
         self.assertEqual(sanitize_filename('--gasdgf'), '_-gasdgf')
         self.assertEqual(sanitize_filename('--gasdgf', is_id=True), '--gasdgf')
+        self.assertEqual(sanitize_filename('.gasdgf'), 'gasdgf')
+        self.assertEqual(sanitize_filename('.gasdgf', is_id=True), '.gasdgf')
 
         forbidden = '"\0\\/'
         for fc in forbidden:
index d4938ec3622742f8c62f37ddf4a0e429baa403dc..1d3401bc2d9358b38aad8635ecf7dc5c4ab7a6fa 100644 (file)
@@ -305,6 +305,7 @@ def sanitize_filename(s, restricted=False, is_id=False):
             result = result[2:]
         if result.startswith('-'):
             result = '_' + result[len('-'):]
+        result = result.lstrip('.')
         if not result:
             result = '_'
     return result