Tzahi12345 / YoutubeDL-Material

Self-hosted YouTube downloader built on Material Design
MIT License
2.61k stars 269 forks source link

[BUG] Thumbnails don't load if their path contains a "%" character #1117

Open Kramoule opened 4 months ago

Kramoule commented 4 months ago

Describe the bug Thumbnails don't load if their filename contains a "%" character. I have also investigated the issue.

The docker logs are:

0|YoutubeDL-Material  | URIError: URI malformed
0|YoutubeDL-Material  |     at decodeURIComponent (<anonymous>)
0|YoutubeDL-Material  |     at /app/app.js:1684:21
...(truncated)

The error apparently comes when it's trying to decode the URI path parameter. https://github.com/Tzahi12345/YoutubeDL-Material/blob/58f4313e500cfcb17aa801934163f474e7be6172/backend/app.js#L1620-L1621 (The line number in app.js inside the container doesn't correspond with the line in the repo)

But the Express documentation says that req.params is already decoded:

NOTE: Express automatically decodes the values in req.params (using decodeURIComponent).

(Source: https://expressjs.com/en/4x/api.html#req.params)

So the backend here is actually trying to decode an already valid filepath. For example with a filepath audio/100%Bug.webp: decodeURIComponent("audio/100%Bug.webp") will return an error.

A solution is to simply remove the decodeURIComponent function if it served no purpose.

To Reproduce Steps to reproduce the behavior:

  1. Download any video that has a % character or set a custom output name which contains a "%" ("100%Bug" for example)
  2. Go to the main page and see your files

Expected behavior Your files should display the thumbnail, as usual.

Screenshots Window-2024-05-16 03_06_04

Environment

Kramoule commented 4 months ago

Of course, if you download a single video and put a custom output name which doesn't have any "%" in it, everything work fine, but you can't always do that with subscriptions.