File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
wcfsetup/install/files/lib Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1717final class GenerateThumbnail implements IPsr14Event
1818{
1919 private string $ pathname ;
20+ private bool $ sourceIsDamaged = false ;
2021
2122 public function __construct (
2223 public readonly File $ file ,
@@ -50,4 +51,18 @@ public function getPathname(): ?string
5051 {
5152 return $ this ->pathname ?? null ;
5253 }
54+
55+ /**
56+ * Flags the source image as damaged which should stop further processing
57+ * of this file.
58+ */
59+ public function markSourceAsDamaged (): void
60+ {
61+ $ this ->sourceIsDamaged = true ;
62+ }
63+
64+ public function sourceIsMarkedAsDamaged (): bool
65+ {
66+ return $ this ->sourceIsDamaged ;
67+ }
5368}
Original file line number Diff line number Diff line change 1717final class GenerateWebpVariant implements IPsr14Event
1818{
1919 private string $ pathname ;
20+ private bool $ sourceIsDamaged = false ;
2021
2122 public function __construct (
2223 public readonly File $ file
@@ -49,4 +50,18 @@ public function getPathname(): ?string
4950 {
5051 return $ this ->pathname ?? null ;
5152 }
53+
54+ /**
55+ * Flags the source image as damaged which should stop further processing
56+ * of this file.
57+ */
58+ public function markSourceAsDamaged (): void
59+ {
60+ $ this ->sourceIsDamaged = true ;
61+ }
62+
63+ public function sourceIsMarkedAsDamaged (): bool
64+ {
65+ return $ this ->sourceIsDamaged ;
66+ }
5267}
Original file line number Diff line number Diff line change @@ -164,6 +164,9 @@ public function generateWebpVariant(File $file): void
164164
165165 $ event = new GenerateWebpVariant ($ file );
166166 EventHandler::getInstance ()->fire ($ event );
167+ if ($ event ->sourceIsMarkedAsDamaged ()) {
168+ throw new DamagedImage ($ file ->fileID );
169+ }
167170
168171 $ filename = $ event ->getPathname ();
169172 if ($ filename === null ) {
@@ -262,6 +265,9 @@ public function generateThumbnails(File $file): void
262265
263266 $ event = new GenerateThumbnail ($ file , $ format );
264267 EventHandler::getInstance ()->fire ($ event );
268+ if ($ event ->sourceIsMarkedAsDamaged ()) {
269+ throw new DamagedImage ($ file ->fileID );
270+ }
265271
266272 $ filename = $ event ->getPathname ();
267273 if ($ filename === null ) {
You can’t perform that action at this time.
0 commit comments