|
|
|
@ -26,9 +26,6 @@ struct Video { |
|
|
|
|
link: Link, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Always use a limit to prevent DoS attacks.
|
|
|
|
|
const LIMIT: u64 = 1024; |
|
|
|
|
|
|
|
|
|
impl fmt::Display for Link { |
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
|
|
|
|
write!(f, "{}", self.uri) |
|
|
|
@ -53,8 +50,12 @@ impl<'v> FromFormValue<'v> for Link { |
|
|
|
|
Ok(abs_uri) => Some(abs_uri), |
|
|
|
|
Err(_) => continue, |
|
|
|
|
}; |
|
|
|
|
if abs_uri.as_ref().unwrap().scheme() == "http" |
|
|
|
|
|| abs_uri.as_ref().unwrap().scheme() == "https" |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Check for success
|
|
|
|
|
let result = match abs_uri { |
|
|
|
@ -71,6 +72,7 @@ impl<'v> FromFormValue<'v> for Link { |
|
|
|
|
|
|
|
|
|
#[post("/new", data = "<video>")] |
|
|
|
|
fn new(video: Form<Video>) -> Redirect { |
|
|
|
|
dbg!(&video.link); |
|
|
|
|
Command::new("/bin/env") |
|
|
|
|
.args(&[ |
|
|
|
|
"DISPLAY=:0", |
|
|
|
|