use unsafe file names

because who the fuck cares its for shitposting anyway

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-10-30 13:39:55 +05:30
parent 04e008826f
commit 8902d63b5a
2 changed files with 7 additions and 11 deletions

3
README
View File

@@ -1 +1,4 @@
even simpler filehost for personal use even simpler filehost for personal use
to increase the upload size limit use something like
ROCKET_LIMITS='{file="50MiB",data-form="50MiB"}'

View File

@@ -24,19 +24,12 @@ async fn post_file(mut upload: Form<Upload<'_>>) -> status::Custom<String> {
); );
} }
if let Some(name) = upload.file.name() { if let Some(name) = upload.file.raw_name() {
let extension = upload
.file
.content_type()
.unwrap()
.extension()
.unwrap_or("file".into());
let new_name = format!( let new_name = format!(
"{}-{}.{}", "{}-{}",
Alphanumeric.sample_string(&mut thread_rng(), 4), Alphanumeric.sample_string(&mut thread_rng(), 4),
name, name.dangerous_unsafe_unsanitized_raw()
extension
); );
let uploaded = upload let uploaded = upload
@@ -71,7 +64,7 @@ fn index() -> String {
"Use curl to upload:\n\ "Use curl to upload:\n\
curl -F file=@\"[file]\" {url}\n\ curl -F file=@\"[file]\" {url}\n\
If key is enabled then a field \"key\" might be required in which case it would be\n\ If key is enabled then a field \"key\" might be required in which case it would be\n\
curl -F file=@\"[file]\" --F \"key=[key]\" {url}", curl -F file=@\"[file]\" -F \"key=[key]\" {url}",
url = env_user_url() url = env_user_url()
) )
} }