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