Encode the file name when adding it to the 'link' attribute of each file.

This lets the file be downloaded if it has a special character e.g #.
This commit is contained in:
Miguel Jacq 2025-02-10 16:42:28 +11:00
parent 6e05ee4426
commit e425c643f5
No known key found for this signature in database
GPG Key ID: 59B3F0C24135C6A9

View File

@ -170,18 +170,18 @@ class SendBaseModeWeb:
if is_dir:
if add_trailing_slash:
dirs.append(
{"link": os.path.join(f"/{path}", filename, ""), "basename": filename}
{"link": os.path.join(f"/{path}", quote(filename), ""), "basename": filename}
)
else:
dirs.append(
{"link": os.path.join(f"/{path}", filename), "basename": filename}
{"link": os.path.join(f"/{path}", quote(filename)), "basename": filename}
)
else:
size = os.path.getsize(this_filesystem_path)
size_human = self.common.human_readable_filesize(size)
files.append(
{
"link": os.path.join(f"/{path}", filename),
"link": os.path.join(f"/{path}", quote(filename)),
"basename": filename,
"size_human": size_human,
}