Redirect on invalid UTF-8 in /p/

Previously, uploading a paste with invalid UTF-8 and then viewing it
with the pretty URL would cause a panic.
With this change, it simply redirects to the raw URL.
This commit is contained in:
Leonora Tindall 2022-01-31 20:49:05 -06:00 committed by Leonora Tindall
commit 460e0ac022
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,20 @@
use rocket::{response::Redirect, Responder};
use rocket_dyn_templates::Template;
#[derive(Responder)]
pub enum MaybeRedirect {
Redirect(Redirect),
Template(Template),
}
impl From<Redirect> for MaybeRedirect {
fn from(other: Redirect) -> Self {
Self::Redirect(other)
}
}
impl From<Template> for MaybeRedirect {
fn from(other: Template) -> Self {
Self::Template(other)
}
}

View file

@ -1,3 +1,4 @@
pub mod maybe_redirect;
pub mod paste_id; pub mod paste_id;
pub mod pretty; pub mod pretty;
pub mod pretty_syntax; pub mod pretty_syntax;