44 verifyImageSignature , 
55 resizeImage , 
66 CloudflareImageOptions , 
7-  checkIsSizableImageURL , 
87 imagesResizingSignVersion , 
8+  checkIsSizableImageURL , 
99}  from  '@/lib/images' ; 
1010import  {  parseImageAPIURL  }  from  '@/lib/urls' ; 
1111
@@ -28,8 +28,10 @@ export async function GET(request: NextRequest) {
2828
2929 const  url  =  parseImageAPIURL ( urlParam ) ; 
3030
31-  // Prevent infinite loops 
32-  if  ( url . includes ( '/~gitbook/image' ) )  { 
31+  // Check again if the image can be sized, even though we checked when rendering the Image component 
32+  // Otherwise, it's possible to pass just any link to this endpoint and trigger HTML injection on the domain 
33+  // Also prevent infinite redirects. 
34+  if  ( ! checkIsSizableImageURL ( url ) )  { 
3335 return  new  Response ( 'Invalid url parameter' ,  {  status : 400  } ) ; 
3436 } 
3537
@@ -38,12 +40,6 @@ export async function GET(request: NextRequest) {
3840 return  Response . redirect ( url ,  302 ) ; 
3941 } 
4042
41-  // Check again if the image can be sized, even though we checked when rendering the Image component 
42-  // Otherwise, it's possible to pass just any link to this endpoint and trigger HTML injection on the domain 
43-  if  ( ! checkIsSizableImageURL ( url ) )  { 
44-  return  new  Response ( 'Invalid url parameter' ,  {  status : 400  } ) ; 
45-  } 
46- 
4743 // Verify the signature 
4844 const  verified  =  await  verifyImageSignature ( url ,  {  signature } ) ; 
4945 if  ( ! verified )  { 
0 commit comments