fent / node-ytdl-core

YouTube video downloader in javascript.
MIT License
4.51k stars 798 forks source link

cutAfterJSON failing with escaped backslashes #861

Closed TimeForANinja closed 3 years ago

TimeForANinja commented 3 years ago

stumbled into some problems with ytsr narrowed it down to the cutAfterJSON function, which is based on ytdl-core's utils#cutAfterJSON function

the function only does a simple lookup if the previous character is a backslash when it checks for the end of strings if e.g. the channelname ends with a backslash that translates to "xxx\\" which lets the cutAfterJSON function fail

low priority issue tried the ytdl-core#getInfo on one of the channels videos and it succeeded guess the function is not always used to retrieve the json

problematic line: https://github.com/fent/node-ytdl-core/blob/master/lib/utils.js#L81

code to reproduce:

require('./lib/utils.js').cutAfterJSON('{"text": "\\\\"};');

opening this issue instead of a pr since i feel like using a regex like [^\\]\\(\\\\)* or even a backwards loop suck performance wise and i am unable to come up with sth better

Channel that Errors: https://www.youtube.com/channel/UC7Dk-eKv2KB7EO28UsFzqdg Related issue: https://github.com/TimeForANinja/node-ytsr/issues/98

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 4.4.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: