So i'm writing a python discord bot that uses yt-dlp to download a song then send it to a discord channel. Problem is, I need to save the mp3 to a path to reupload it, but i think my code would be vulnerable to an attack where someone does a youtube video with "../../../etc/[something]" in the title, and I don't really know how I'd be able to correct that.
What I ended up doing was using 'restrictfilenames': True
in my options. That way, it restrics all non standard characters from the filename that is saved
Here's the code.
@client.command()
async def dl(ctx, arg):
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
# ydl.download([arg])
info = ydl.extract_info(arg)
await ctx.send("ok goude", file=discord.File(download_path + info['title'] + '.mp3'))
Thanks to any help!