Merge pull request #4 from pastebinrun/disable-strict-parsing-for-api-paste

Disable strict parsing for api paste submissions
This commit is contained in:
Konrad Borowski 2022-05-29 00:16:16 +02:00 committed by GitHub
commit 3c42e3842e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,7 @@ use crate::models::paste::{self, ExtraPasteParameters, InsertionError};
use crate::Db; use crate::Db;
use chrono::Duration; use chrono::Duration;
use chrono::Utc; use chrono::Utc;
use rocket::form::{self, Form, FromFormField, Strict, ValueField}; use rocket::form::{self, Form, FromFormField, ValueField};
use rocket::http::hyper::header::ACCESS_CONTROL_ALLOW_ORIGIN; use rocket::http::hyper::header::ACCESS_CONTROL_ALLOW_ORIGIN;
use rocket::http::Header; use rocket::http::Header;
use rocket::request::Request; use rocket::request::Request;
@ -57,10 +57,7 @@ impl<'r> Responder<'r, 'static> for CorsString {
} }
#[post("/api/v1/pastes", data = "<form>")] #[post("/api/v1/pastes", data = "<form>")]
pub async fn api_insert_paste( pub async fn api_insert_paste(db: Db, form: Form<PasteForm>) -> Result<CorsString, InsertionError> {
db: Db,
form: Form<Strict<PasteForm>>,
) -> Result<CorsString, InsertionError> {
let identifier = db let identifier = db
.run(move |conn| { .run(move |conn| {
paste::insert( paste::insert(