File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -303,6 +303,19 @@ export async function submitQuiltPixels({
303303 if ( quilt . endsAt . getTime ( ) <= Date . now ( ) ) {
304304 throw new BadRequestError ( "This quilt has ended." ) ;
305305 }
306+ const existingPending = await db . quiltSubmission . findFirst ( {
307+ where : {
308+ quiltId : quilt . id ,
309+ authorId : actor . id ,
310+ status : QuiltSubmissionStatus . PENDING ,
311+ } ,
312+ select : { id : true } ,
313+ } ) ;
314+ if ( existingPending ) {
315+ throw new BadRequestError (
316+ "You already have a pending quilt change. Edit it instead of submitting another one." ,
317+ ) ;
318+ }
306319 const unique = new Map < string , QuiltPixel > ( ) ;
307320 for ( const pixel of input . pixels ) {
308321 if ( pixel . x >= quilt . width || pixel . y >= quilt . height ) {
Original file line number Diff line number Diff line change 11import { appConfig } from "../../config/app.js" ;
22import { env } from "../../config/env.js" ;
33
4+ function isUploadApiPath ( pathname : string ) {
5+ const apiBasePath = appConfig . uploads . apiBasePath . replace ( / \/ $ / , "" ) ;
6+ return (
7+ pathname . startsWith (
8+ `${ apiBasePath } /${ appConfig . uploads . imageRoute } /` ,
9+ ) ||
10+ pathname . startsWith (
11+ `${ apiBasePath } /${ appConfig . uploads . profileImageRoute } /` ,
12+ )
13+ ) ;
14+ }
15+
416export function isAllowedAssetUrl ( value : unknown ) : boolean {
517 if ( value === null || value === undefined || value === "" ) return true ;
618 if ( typeof value !== "string" ) return false ;
19+ if ( isUploadApiPath ( value ) ) return true ;
720 if ( value . startsWith ( appConfig . uploads . staticImagesPath ) ) {
821 return true ;
922 }
23+ try {
24+ const parsed = new URL ( value ) ;
25+ if (
26+ ( parsed . protocol === "http:" || parsed . protocol === "https:" ) &&
27+ isUploadApiPath ( parsed . pathname )
28+ ) {
29+ return true ;
30+ }
31+ } catch {
32+ // Relative URLs are handled above.
33+ }
1034 if ( value . startsWith ( `${ appConfig . publicOrigin } ${ appConfig . uploads . staticImagesPath } ` ) ) {
1135 return true ;
1236 }
You can’t perform that action at this time.
0 commit comments