@@ -606,16 +606,26 @@ public function testcasesAction(Request $request, int $probId): Response
606
606
}
607
607
$ content = file_get_contents ($ file ->getRealPath ());
608
608
if ($ type === 'image ' ) {
609
- $ imageType = Utils::getImageType ($ content , $ error );
610
- if ($ imageType === false ) {
611
- $ this ->addFlash ('danger ' , sprintf ('image: %s ' , $ error ));
612
- return $ this ->redirectToRoute ('jury_problem_testcases ' , ['probId ' => $ probId ]);
613
- }
614
- $ thumb = Utils::getImageThumb ($ content , $ thumbnailSize ,
615
- $ this ->dj ->getDomjudgeTmpDir (), $ error );
616
- if ($ thumb === false ) {
617
- $ this ->addFlash ('danger ' , sprintf ('image: %s ' , $ error ));
618
- return $ this ->redirectToRoute ('jury_problem_testcases ' , ['probId ' => $ probId ]);
609
+ if (mime_content_type ($ file ->getRealPath ()) === 'image/svg+xml ' ) {
610
+ $ content = Utils::sanitizeSvg ($ content );
611
+ if ($ content === false ) {
612
+ $ this ->addFlash ('danger ' , sprintf ('image: %s ' , $ error ));
613
+ return $ this ->redirectToRoute ('jury_problem_testcases ' , ['probId ' => $ probId ]);
614
+ }
615
+ $ thumb = $ content ;
616
+ $ imageType = 'svg ' ;
617
+ } else {
618
+ $ imageType = Utils::getImageType ($ content , $ error );
619
+ if ($ imageType === false ) {
620
+ $ this ->addFlash ('danger ' , sprintf ('image: %s ' , $ error ));
621
+ return $ this ->redirectToRoute ('jury_problem_testcases ' , ['probId ' => $ probId ]);
622
+ }
623
+ $ thumb = Utils::getImageThumb ($ content , $ thumbnailSize ,
624
+ $ this ->dj ->getDomjudgeTmpDir (), $ error );
625
+ if ($ thumb === false ) {
626
+ $ this ->addFlash ('danger ' , sprintf ('image: %s ' , $ error ));
627
+ return $ this ->redirectToRoute ('jury_problem_testcases ' , ['probId ' => $ probId ]);
628
+ }
619
629
}
620
630
621
631
$ testcase ->setImageType ($ imageType );
0 commit comments