mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 22:12:17 -05:00
[extractor/common] Protect against long video IDs and URLs
This commit is contained in:
parent
e3abbbe301
commit
c1bce22f23
1 changed files with 5 additions and 4 deletions
|
@ -242,10 +242,11 @@ def _download_webpage_handle(self, url_or_request, video_id, note=None, errnote=
|
||||||
url = url_or_request.get_full_url()
|
url = url_or_request.get_full_url()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
url = url_or_request
|
url = url_or_request
|
||||||
if len(url) > 200:
|
basen = video_id + '_' + url
|
||||||
h = u'___' + hashlib.md5(url.encode('utf-8')).hexdigest()
|
if len(basen) > 240:
|
||||||
url = url[:200 - len(h)] + h
|
h = u'___' + hashlib.md5(basen.encode('utf-8')).hexdigest()
|
||||||
raw_filename = ('%s_%s.dump' % (video_id, url))
|
basen = basen[:240 - len(h)] + h
|
||||||
|
raw_filename = basen + '.dump'
|
||||||
filename = sanitize_filename(raw_filename, restricted=True)
|
filename = sanitize_filename(raw_filename, restricted=True)
|
||||||
self.to_screen(u'Saving request to ' + filename)
|
self.to_screen(u'Saving request to ' + filename)
|
||||||
with open(filename, 'wb') as outf:
|
with open(filename, 'wb') as outf:
|
||||||
|
|
Loading…
Reference in a new issue