Merge pull request #1962 from onionshare/mig/encode_filenames_for_special_characters

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:
Saptak Sengupta 2025-02-10 12:12:04 +05:30 committed by GitHub
commit 137afbde52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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,
}