Strip surrounding whitespace in filenames

Such spaces are annoying enough to deal with, and break external downloaders trying to be smart (such as aria2c).
Fixes #20312.
This commit is contained in:
hseg 2019-04-11 02:30:32 +03:00 committed by GitHub
parent 118f7add3b
commit 422a413bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -509,7 +509,7 @@ def sanitize_filename(s, restricted=False, is_id=False):
if not is_id:
while '__' in result:
result = result.replace('__', '_')
result = result.strip('_')
result = result.strip(' _')
# Common case of "Foreign band name - English song title"
if restricted and result.startswith('-_'):
result = result[2:]