Skip to content

Commit

Permalink
limit size of data to 100kb
Browse files Browse the repository at this point in the history
  • Loading branch information
pabueco committed Feb 1, 2024
1 parent df94ee7 commit aa38468
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/routes/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ pub async fn create_shortcode(mut req: Request, ctx: RouteContext<()>) -> worker
let s = serde_json::to_vec(&body)?;
let data = URL_SAFE.encode(&s);

// Limit data size to 100KB.
if data.bytes().len() > 100_000 {
return create_error_json(StatusCode::PAYLOAD_TOO_LARGE, "Payload too large");
}

let db = create_database(&ctx.env).await?;

// Generate a unique shortcode.
Expand Down

0 comments on commit aa38468

Please sign in to comment.