Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Checklist
Description
Consider a JavaScript dictionary that has a key-value pair like this:
utils.js_to_jsonis not able to escape this value correctly. The expected result would be:However, the actual result is:
As the value is not enclosed in
', the value gets split into two seperate parts, which is not valid JSON anymore. But as the input was valid JavaScript,js_to_jsonshould be able to produce valid JSON from it as well.I think, the regex in youtube_dl/utils.py#L4022 could be adapted to parse a single word bevor a
:as a key, and anything after the:until the next,as a value. This would allow parsing of JavaScript like this and similar cases, and maybe even simplify the regex a bit.I tried implementing such a fix for the past hour now, but I guess, I'm not enough of a regex magician for that. (although I'll keep looking into it). What do you think?
Any other ideas? How can
js_to_jsonbe improved to cover JavaScript like this?