From 7ae5bc3e13a394bdac2974204cde790d522efbdc Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Thu, 9 Jun 2022 10:11:01 +0100 Subject: [PATCH] Fix yt_validate stack overflow issue https://github.com/play-dl/play-dl/issues/304 yt_validate was recursing forever because the regex for removing the 'list=xxxx' parameter was looking for one or more characters after list=, rather than 0 or more, so removed nothing if no value was provided. e.g https://www.youtube.com/playlist?list= Have tested this locally but would appreciate a second look before merging. --- play-dl/YouTube/utils/extractor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play-dl/YouTube/utils/extractor.ts b/play-dl/YouTube/utils/extractor.ts index a11216e..4ea7c0d 100644 --- a/play-dl/YouTube/utils/extractor.ts +++ b/play-dl/YouTube/utils/extractor.ts @@ -61,7 +61,7 @@ export function yt_validate(url: string): 'playlist' | 'video' | 'search' | fals else return 'search'; } } else { - if (!url_.match(playlist_pattern)) return yt_validate(url_.replace(/(\?|\&)list=[^&]+/, '')); + if (!url_.match(playlist_pattern)) return yt_validate(url_.replace(/(\?|\&)list=[^&]*/, '')); else return 'playlist'; } }