From 8aa0bd5d10627ece3c1815c01d02fb8bf22847a7 Mon Sep 17 00:00:00 2001 From: bashonly Date: Sun, 29 Jan 2023 00:59:37 -0600 Subject: [PATCH] [extractor/generic] Avoid catastrophic backtracking in KVS regex Authored by: bashonly --- yt_dlp/extractor/generic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/generic.py b/yt_dlp/extractor/generic.py index 04677b23f..9e4df4cea 100644 --- a/yt_dlp/extractor/generic.py +++ b/yt_dlp/extractor/generic.py @@ -2637,11 +2637,11 @@ def _extract_embeds(self, url, webpage, *, urlh=None, info_dict={}): # Look for generic KVS player (before json-ld bc of some urls that break otherwise) found = self._search_regex(( - r']+?\bsrc\s*=\s*(["\'])https?://(?:\S+?/)+kt_player\.js\?v=(?P\d+(?:\.\d+)+)\1[^>]*>', - r'kt_player\s*\(\s*(["\'])(?:(?!\1)[\w\W])+\1\s*,\s*(["\'])https?://(?:\S+?/)+kt_player\.swf\?v=(?P\d+(?:\.\d+)+)\2\s*,', + r']+?\bsrc\s*=\s*(["\'])https?://(?:(?!\1)[^?#])+/kt_player\.js\?v=(?P\d+(?:\.\d+)+)\1[^>]*>', + r'kt_player\s*\(\s*(["\'])(?:(?!\1)[\w\W])+\1\s*,\s*(["\'])https?://(?:(?!\2)[^?#])+/kt_player\.swf\?v=(?P\d+(?:\.\d+)+)\2\s*,', ), webpage, 'KVS player', group='ver', default=False) if found: - self.report_detected('KWS Player') + self.report_detected('KVS Player') if found.split('.')[0] not in ('4', '5', '6'): self.report_warning(f'Untested major version ({found}) in player engine - download may fail.') return [self._extract_kvs(url, webpage, video_id)]