|
|
|
@ -7,8 +7,8 @@ use std::env; |
|
|
|
|
use std::fmt; |
|
|
|
|
use std::path::Path; |
|
|
|
|
|
|
|
|
|
use rocket::request::FromFormValue; |
|
|
|
|
use rocket::http::RawStr; |
|
|
|
|
use rocket::request::FromFormValue; |
|
|
|
|
|
|
|
|
|
use rocket::http::uri::Absolute; |
|
|
|
|
use rocket::request::Form; |
|
|
|
@ -18,7 +18,7 @@ use std::process::Command; |
|
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
|
struct Link { |
|
|
|
|
uri: String |
|
|
|
|
uri: String, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(FromForm)] |
|
|
|
@ -31,8 +31,8 @@ const LIMIT: u64 = 1024; |
|
|
|
|
|
|
|
|
|
impl fmt::Display for Link { |
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
|
|
|
|
write!(f, "{}", self.uri) |
|
|
|
|
} |
|
|
|
|
write!(f, "{}", self.uri) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl<'v> FromFormValue<'v> for Link { |
|
|
|
@ -42,7 +42,7 @@ impl<'v> FromFormValue<'v> for Link { |
|
|
|
|
// Decode form data into string
|
|
|
|
|
let string = match form_value.url_decode() { |
|
|
|
|
Ok(string) => string, |
|
|
|
|
Err(_) => return Err(form_value) |
|
|
|
|
Err(_) => return Err(form_value), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Try to parse a hyperlink from the string
|
|
|
|
@ -58,8 +58,10 @@ impl<'v> FromFormValue<'v> for Link { |
|
|
|
|
|
|
|
|
|
// Check for success
|
|
|
|
|
let result = match abs_uri { |
|
|
|
|
Some(abs_uri) => Link{uri: abs_uri.to_string()}, |
|
|
|
|
_ => return Err(form_value) |
|
|
|
|
Some(abs_uri) => Link { |
|
|
|
|
uri: abs_uri.to_string(), |
|
|
|
|
}, |
|
|
|
|
_ => return Err(form_value), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Return successfully.
|
|
|
|
@ -67,7 +69,6 @@ impl<'v> FromFormValue<'v> for Link { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[post("/new", data = "<video>")] |
|
|
|
|
fn new(video: Form<Video>) -> Redirect { |
|
|
|
|
Command::new("/bin/env") |
|
|
|
|