|
|
|
@ -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)] |
|
|
|
@ -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") |
|
|
|
|