mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	[utils] Fix js_to_json
Previously, the runtime could be atrocious for longer inputs.
This commit is contained in:
		@@ -1560,8 +1560,8 @@ def js_to_json(code):
 | 
			
		||||
        return '"%s"' % v
 | 
			
		||||
 | 
			
		||||
    res = re.sub(r'''(?x)
 | 
			
		||||
        "(?:[^"\\]*(?:\\\\|\\")?)*"|
 | 
			
		||||
        '(?:[^'\\]*(?:\\\\|\\')?)*'|
 | 
			
		||||
        "(?:[^"\\]*(?:\\\\|\\['"nu]))*[^"\\]*"|
 | 
			
		||||
        '(?:[^'\\]*(?:\\\\|\\['"nu]))*[^'\\]*'|
 | 
			
		||||
        [a-zA-Z_][.a-zA-Z_0-9]*
 | 
			
		||||
        ''', fix_kv, code)
 | 
			
		||||
    res = re.sub(r',(\s*\])', lambda m: m.group(1), res)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user