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:
parent
1e0e3b319c
commit
460e0ac022
2 changed files with 21 additions and 0 deletions
20
src/models/maybe_redirect.rs
Normal file
20
src/models/maybe_redirect.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue