only try to use uris starting with http{,s}

master
CptCaptain 3 years ago
parent 004887799e
commit a309d19e61
  1. 8
      src/main.rs

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

Loading…
Cancel
Save