36 private const SAFE_XML_ENCODINGS = [
67 private MimeAnalyzer $mimeAnalyzer,
68 private LoggerInterface $logger,
82 private function verifyMimeType( $mime ) {
84 if ( $verifyMimeType ) {
85 $mimeTypeExclusions = $this->config
87 if ( in_array( strtolower( $mime ), $mimeTypeExclusions,
true ) ) {
88 return [
'filetype-badmime', $mime ];
109 $config = $this->config;
113 if ( $status !==
true ) {
117 $mime = $fileProps[
'mime'];
119 if ( $verifyMimeType ) {
124 return [
'filetype-mime-mismatch', $ext, $mime ];
129 if ( !$disableUploadScriptChecks ) {
130 if ( $ext ===
'svg' || $mime ===
'image/svg+xml' ) {
131 $svgStatus = $this->detectScriptInSvg(
$path,
false );
132 if ( $svgStatus !==
false ) {
138 $handler = $mime !==
null ? MediaHandler::getHandler( $mime ) :
null;
140 $handlerStatus = $handler->verifyUpload(
$path );
141 if ( !$handlerStatus->isOK() ) {
142 $errors = $handlerStatus->getErrorsArray();
144 return reset( $errors );
152 $this->logger->debug(
'verifyFile: all clear; passing.' );
173 $config = $this->config;
177 $mime = $fileProps[
'file-mime'];
178 $status = $this->verifyMimeType( $mime );
179 $this->logger->debug(
'verifyMimeType: {mime} {status}',
180 [
'mime' => $mime,
'status' => $status ===
true ?
'OK' :
'bad' ] );
181 if ( $status !==
true ) {
186 if ( !$disableUploadScriptChecks ) {
188 return [
'uploadscripted' ];
190 if ( $ext ===
'svg' || $mime ===
'image/svg+xml' ) {
191 $svgStatus = $this->detectScriptInSvg(
$path,
true );
192 if ( $svgStatus !==
false ) {
201 return [
'uploadvirus', $virus ];
216 $magic = $this->mimeAnalyzer;
217 $logContext = [
'mime' => $mime,
'extension' => $extension ];
219 if ( !$mime || $mime ===
'unknown' || $mime ===
'unknown/unknown' ) {
220 if ( !$magic->isRecognizableExtension( $extension ) ) {
221 $this->logger->debug(
222 'verifyExtension: passing file with unknown detected MIME type; ' .
223 "unrecognized extension '{extension}', can't verify",
230 $this->logger->debug(
231 'verifyExtension: rejecting file with unknown detected MIME type; ' .
232 'recognized extension "{extension}", so probably invalid file',
238 $match = $magic->isMatchingExtension( $extension, $mime );
240 if ( $match ===
null ) {
241 if ( $magic->getMimeTypesFromExtension( $extension ) !== [] ) {
242 $this->logger->debug(
243 'verifyExtension: No extension known for {mime}, but we ' .
244 'know a MIME for {extension}',
250 $this->logger->debug(
251 'verifyExtension: no file extension known for MIME type {mime}, passing file',
258 $this->logger->debug(
259 'verifyExtension: MIME type {mime} matches extension {extension}, passing file',
265 $this->logger->debug(
266 'verifyExtension: MIME type {mime} mismatches file extension {extension}, ' .
293 if ( str_starts_with( $mime ??
'',
'text/' ) ) {
294 $chunk = file_get_contents( $file );
296 $fp = fopen( $file,
'rb' );
300 $chunk = fread( $fp, 1024 );
304 $chunk = strtolower( $chunk );
311 if ( str_starts_with( $chunk,
"\xfe\xff" ) ) {
313 } elseif ( str_starts_with( $chunk,
"\xff\xfe" ) ) {
319 if ( $enc !==
null ) {
321 $chunk = @iconv( $enc,
"ASCII//IGNORE", $chunk );
324 $chunk = trim( $chunk );
327 if ( preg_match(
"/<!DOCTYPE *X?HTML/i", $chunk ) ) {
328 $this->logger->debug(
'detectScript: found doctype html' );
334 if ( $extension ===
'svg' || str_starts_with( $mime ??
'',
'image/svg' ) ) {
335 if ( $this->checkXMLEncodingMismatch( $file ) ) {
336 $this->logger->debug(
'detectScript: found SVG encoding mismatch' );
351 foreach ( $tags as $tag ) {
352 if ( str_contains( $chunk, $tag ) ) {
353 $this->logger->debug(
'detectScript: found HTML tag "{tag}"', [
'tag' => $tag ] );
361 $chunk = Sanitizer::decodeCharReferences( $chunk );
364 if ( preg_match(
'!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!im', $chunk ) ) {
365 $this->logger->debug(
'detectScript: found script types' );
370 if ( preg_match(
'!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!im', $chunk ) ) {
371 $this->logger->debug(
'detectScript: found HTML-style script URLs' );
376 if ( preg_match(
'!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!im', $chunk ) ) {
377 $this->logger->debug(
'detectScript: found CSS-style script URLs' );
381 $this->logger->debug(
'detectScript: no scripts found' );
392 private function checkXMLEncodingMismatch( $file ) {
397 $contents = file_get_contents( $file,
false,
null, 0, 4096 );
398 $encodingRegex =
'!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si';
400 if ( preg_match(
"!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) {
401 if ( preg_match( $encodingRegex, $matches[1], $encMatch )
402 && !in_array( strtoupper( $encMatch[1] ), self::SAFE_XML_ENCODINGS )
404 $this->logger->debug(
405 'checkXMLEncodingMismatch: Found unsafe XML encoding "{encoding}"',
406 [
'encoding' => $encMatch[1] ]
410 } elseif ( preg_match(
"!<\?xml\b!i", $contents ) ) {
413 $this->logger->debug(
'checkXMLEncodingMismatch: Unmatched XML declaration start' );
415 } elseif ( str_starts_with( $contents,
"\x4C\x6F\xA7\x94" ) ) {
417 $this->logger->debug(
'checkXMLEncodingMismatch: EBCDIC Encoded XML' );
424 $attemptEncodings = [
'UTF-16',
'UTF-16BE',
'UTF-32',
'UTF-32BE' ];
425 foreach ( $attemptEncodings as $encoding ) {
427 $str = @iconv( $encoding,
'UTF-8', $contents );
428 if ( $str !=
'' && preg_match(
"!<\?xml\b(.*?)\?>!si", $str, $matches ) ) {
429 if ( preg_match( $encodingRegex, $matches[1], $encMatch )
430 && !in_array( strtoupper( $encMatch[1] ), self::SAFE_XML_ENCODINGS )
432 $this->logger->debug(
433 'checkXMLEncodingMismatch: Found unsafe XML encoding "{encoding}"',
434 [
'encoding' => $encMatch[1] ]
438 } elseif ( $str !=
'' && preg_match(
"!<\?xml\b!i", $str ) ) {
441 $this->logger->debug(
'checkXMLEncodingMismatch: Unmatched XML declaration start' );
458 private function detectScriptInSvg( $filename, $partial ) {
459 $check =
new XmlTypeCheck(
461 $this->checkSvgScriptCallback( ... ),
464 'processing_instruction_handler' => $this->checkSvgPICallback( ... ),
465 'external_dtd_handler' => $this->checkSvgExternalDTD( ... ),
468 if ( $check->wellFormed !==
true ) {
471 return $partial ? false : [
'uploadinvalidxml' ];
474 if ( $check->filterMatch ) {
475 return $check->filterMatchType;
487 private function checkSvgPICallback( $target ) {
489 if ( preg_match(
'/xml-stylesheet/i', $target ) ) {
490 return [
'upload-scripted-pi-callback' ];
508 private function checkSvgExternalDTD( $type, $publicId, $systemId ) {
511 static $allowedDTDs = [
512 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd',
513 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd',
514 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd',
515 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd',
517 'http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd',
519 if ( $type !==
'PUBLIC'
520 || !in_array( $systemId, $allowedDTDs )
521 || !str_starts_with( $publicId,
"-//W3C//" )
523 return [
'upload-scripted-dtd' ];
537 private function checkSvgScriptCallback( $element, $attribs, $data =
null ) {
538 [ $namespace, $strippedElement ] = self::splitXmlNamespace( $element );
541 'element' => $element,
542 'namespace' => $namespace,
543 'localPart' => $strippedElement
548 static $validNamespaces = [
552 'http://c2pa.org/manifest',
553 'http://cipa.jp/exif/1.0/',
554 'http://creativecommons.org/ns#',
555 'http://developer.sonyericsson.com/cell/1.0/',
556 'http://inkscape.sourceforge.net/dtd/sodipodi-0.dtd',
557 'http://iptc.org/std/iptc4xmpcore/1.0/xmlns/',
558 'http://iptc.org/std/iptc4xmpext/2008-02-29/',
559 'http://leica-camera.com/digital-shift-assistant/1.0/',
560 'http://ns.acdsee.com/iptc/1.0/',
561 'http://ns.acdsee.com/regions/',
562 'http://ns.adobe.com/adobeillustrator/10.0/',
563 'http://ns.adobe.com/adobesvgviewerextensions/3.0/',
564 'http://ns.adobe.com/album/1.0/',
565 'http://ns.adobe.com/camera-raw-defaults/1.0/',
566 'http://ns.adobe.com/camera-raw-embedded-lens-profile/1.0/',
567 'http://ns.adobe.com/camera-raw-saved-settings/1.0/',
568 'http://ns.adobe.com/camera-raw-settings/1.0/',
569 'http://ns.adobe.com/creatoratom/1.0/',
570 'http://ns.adobe.com/dicom/',
571 'http://ns.adobe.com/exif/1.0/',
572 'http://ns.adobe.com/exif/1.0/aux/',
573 'http://ns.adobe.com/extensibility/1.0/',
574 'http://ns.adobe.com/flows/1.0/',
575 'http://ns.adobe.com/hdr-gain-map/1.0/',
576 'http://ns.adobe.com/hdr-metadata/1.0/',
577 'http://ns.adobe.com/ix/1.0/',
578 'http://ns.adobe.com/lightroom/1.0/',
579 'http://ns.adobe.com/illustrator/1.0/',
580 'http://ns.adobe.com/imagereplacement/1.0/',
581 'http://ns.adobe.com/pdf/1.3/',
582 'http://ns.adobe.com/pdfx/1.3/',
583 'http://ns.adobe.com/photoshop/1.0/',
584 'http://ns.adobe.com/photoshop/1.0/camera-profile',
585 'http://ns.adobe.com/photoshop/1.0/panorama-profile',
586 'http://ns.adobe.com/raw/1.0/',
587 'http://ns.adobe.com/swf/1.0/',
588 'http://ns.adobe.com/saveforweb/1.0/',
589 'http://ns.adobe.com/tiff/1.0/',
590 'http://ns.adobe.com/variables/1.0/',
591 'http://ns.adobe.com/xap/1.0/',
592 'http://ns.adobe.com/xap/1.0/bj/',
593 'http://ns.adobe.com/xap/1.0/g/',
594 'http://ns.adobe.com/xap/1.0/g/img/',
595 'http://ns.adobe.com/xap/1.0/mm/',
596 'http://ns.adobe.com/xap/1.0/plus/',
597 'http://ns.adobe.com/xap/1.0/rights/',
598 'http://ns.adobe.com/xap/1.0/stype/dimensions#',
599 'http://ns.adobe.com/xap/1.0/stype/font#',
600 'http://ns.adobe.com/xap/1.0/stype/manifestitem#',
601 'http://ns.adobe.com/xap/1.0/stype/resourceevent#',
602 'http://ns.adobe.com/xap/1.0/stype/resourceref#',
603 'http://ns.adobe.com/xap/1.0/stype/version#',
604 'http://ns.adobe.com/xap/1.0/t/pg/',
605 'http://ns.adobe.com/xmp/1.0/dynamicmedia/',
606 'http://ns.adobe.com/xmp/identifier/qual/1.0/',
607 'http://ns.adobe.com/xmp/note/',
608 'http://ns.adobe.com/xmp/stype/area#',
609 'http://ns.apple.com/adjustment-settings/1.0/',
610 'http://ns.apple.com/faceinfo/1.0/',
611 'http://ns.apple.com/hdrgainmap/1.0/',
612 'http://ns.apple.com/pixeldatainfo/1.0/',
613 'http://ns.exiftool.org/1.0/',
614 'http://ns.extensis.com/extensis/1.0/',
615 'http://ns.fastpictureviewer.com/fpv/1.0/',
616 'http://ns.google.com/photos/1.0/audio/',
617 'http://ns.google.com/photos/1.0/camera/',
618 'http://ns.google.com/photos/1.0/container/',
619 'http://ns.google.com/photos/1.0/creations/',
620 'http://ns.google.com/photos/1.0/depthmap/',
621 'http://ns.google.com/photos/1.0/focus/',
622 'http://ns.google.com/photos/1.0/image/',
623 'http://ns.google.com/photos/1.0/panorama/',
624 'http://ns.google.com/photos/dd/1.0/profile/',
625 'http://ns.google.com/videos/1.0/spherical/',
626 'http://ns.idimager.com/ics/1.0/',
627 'http://ns.iview-multimedia.com/mediapro/1.0/',
628 'http://ns.leiainc.com/photos/1.0/image/',
629 'http://ns.microsoft.com/expressionmedia/1.0/',
630 'http://ns.microsoft.com/photo/1.0',
631 'http://ns.microsoft.com/photo/1.1',
632 'http://ns.microsoft.com/photo/1.2/',
633 'http://ns.microsoft.com/photo/1.2/t/region#',
634 'http://ns.microsoft.com/photo/1.2/t/regioninfo#',
635 'http://ns.nikon.com/asteroid/1.0/',
636 'http://ns.nikon.com/nine/1.0/',
637 'http://ns.nikon.com/sdc/1.0/',
638 'http://ns.optimasc.com/dex/1.0/',
639 'http://ns.seal/2024/1.0/',
640 'http://ns.useplus.org/ldf/xmp/1.0/',
641 'http://prismstandard.org/namespaces/basic/2.0/',
642 'http://prismstandard.org/namespaces/pmi/2.2/',
643 'http://prismstandard.org/namespaces/prismusagerights/2.1/',
644 'http://prismstandard.org/namespaces/prl/2.1/',
645 'http://prismstandard.org/namespaces/prm/3.0/',
646 'http://purl.org/dc/elements/1.1/',
647 'http://purl.org/dc/elements/1.1',
648 'http://rs.tdwg.org/dwc/index.htm',
649 'http://schemas.microsoft.com/visio/2003/svgextensions/',
650 'http://sodipodi.sourceforge.net/dtd/sodipodi-0.dtd',
651 'http://taptrix.com/inkpad/svg_extensions',
652 'http://www.digikam.org/ns/1.0/',
653 'http://www.dji.com/drone-dji/1.0/',
654 'http://www.metadataworkinggroup.com/schemas/collections/',
655 'http://www.metadataworkinggroup.com/schemas/keywords/',
656 'http://www.metadataworkinggroup.com/schemas/regions/',
657 'http://web.resource.org/cc/',
658 'http://www.freesoftware.fsf.org/bkchem/cdml',
659 'http://www.inkscape.org/namespaces/inkscape',
660 'http://www.opengis.net/gml',
661 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
662 'http://www.w3.org/2000/01/rdf-schema#',
663 'http://www.w3.org/2000/svg',
664 'http://www.w3.org/2000/02/svg/testsuite/description/',
665 'http://www.w3.org/tr/rec-rdf-syntax/',
666 'http://xmp.gettyimages.com/gift/1.0/',
671 $isBuggyInkscape = preg_match(
'/^&(#38;)*ns_[a-z_]+;$/', $namespace );
673 if ( !( $isBuggyInkscape || in_array( $namespace, $validNamespaces ) ) ) {
674 $this->logger->debug(
675 'detectScriptInSvg: Non-SVG namespace "{namespace}" in uploaded file.',
678 return [
'uploadscriptednamespace', $namespace ];
682 if ( $strippedElement ===
'script' ) {
683 $this->logger->debug(
684 'detectScriptInSvg: Found script element "{element}" in uploaded file.',
687 return [
'uploaded-script-svg', $strippedElement ];
692 if ( $strippedElement ===
'handler' ) {
693 $this->logger->debug(
694 'detectScriptInSvg: Found scriptable element "{element}" in uploaded file.',
697 return [
'uploaded-script-svg', $strippedElement ];
701 if ( $strippedElement ===
'stylesheet' ) {
702 $this->logger->debug(
703 'detectScriptInSvg: Found scriptable element "{element}" in uploaded file.',
706 return [
'uploaded-script-svg', $strippedElement ];
710 if ( $strippedElement ===
'iframe' ) {
711 $this->logger->debug(
"detectScriptInSvg: iframe in uploaded file.", $logContext );
712 return [
'uploaded-script-svg', $strippedElement ];
716 if ( $strippedElement ===
'style' ) {
717 $cssCheck = $this->svgCssChecker->checkStyleTag( $data );
718 if ( $cssCheck !==
true ) {
719 $this->logger->debug(
720 "detectScriptInSvg: hostile CSS in style element. {tag}",
721 [
'tag' => $cssCheck[0] ]
723 return [
'uploaded-hostile-svg', $cssCheck[0], $cssCheck[1], $cssCheck[2] ];
727 static $cssAttrs = [
'font',
'clip-path',
'fill',
'filter',
'marker',
728 'marker-end',
'marker-mid',
'marker-start',
'mask',
'stroke',
'cursor' ];
730 foreach ( $attribs as $attrib => $value ) {
732 [ $attributeNamespace, $stripped ] = self::splitXmlNamespace( $attrib );
733 $value = strtolower( $value );
734 $attribLogContext = [
'attrib' => $attrib,
'value' => $value ] + $logContext;
741 $namespace ===
'http://www.inkscape.org/namespaces/inkscape' &&
742 $attributeNamespace ===
''
743 ) && str_starts_with( $stripped,
'on' )
745 $this->logger->debug(
746 'detectScriptInSvg: Found event-handler attribute ' .
747 '{attrib}="{value}" in uploaded file.',
750 return [
'uploaded-event-handler-on-svg', $attrib, $value ];
760 && !str_starts_with( $value,
'data:' )
761 && !str_starts_with( $value,
'#' )
762 && !( $strippedElement ===
'a' && preg_match(
'!^https?://!i', $value ) )
764 $this->logger->debug(
765 'detectScriptInSvg: Found href attribute <{localPart} {attrib}="{value}"> ' .
769 return [
'uploaded-href-attribute-svg', $strippedElement, $attrib, $value ];
775 if ( $stripped ===
'href' && strncasecmp(
'data:', $value, 5 ) === 0 ) {
777 $dataUriRegex = <<<
'REGEX'
779image / (gif|jpeg|jpg|a?png|webp|avif)
780# mediatype parameters (once-only subpattern)
784 [a-zA-Z0-9\!#$&
'*+.^_`{|}~-]+
789 [a-zA-Z0-9\!#$&'*+.^_`{|}~-]+ |
790 # quoted-string (discouraged by RFC 2045)
792 [\0-\x0c\x0e-\x21\x23-\x5b\x5d-\x7f]+ |
797# data URI parameter (non-capturing)
802 if ( !preg_match( $dataUriRegex, $value ) ) {
803 $this->logger->debug(
804 'detectScriptInSvg: Found href with data URI with MIME type that is not ' .
805 'allowed: <{localPart} {attrib}="{value}"> in uploaded file.',
808 return [
'uploaded-href-unsafe-target-svg', $strippedElement, $attrib, $value ];
813 if ( $stripped ===
'attributename'
814 && $strippedElement ===
'animate'
815 && $this->stripXmlNamespace( $value ) ===
'href'
817 $this->logger->debug(
818 'detectScriptInSvg: Found animate that might be changing href using "from": ' .
819 '<{localPart} {attrib}="{value}"> in uploaded file.',
822 return [
'uploaded-animate-svg', $strippedElement, $attrib, $value ];
826 if ( ( $strippedElement ===
'set' || $strippedElement ===
'animate' )
827 && $stripped ===
'attributename'
828 && str_starts_with( $value,
'on' )
830 $this->logger->debug(
831 'detectScriptInSvg: Found SVG setting event-handler attribute with ' .
832 '<{localPart} {attrib}="{value}"> in uploaded file.',
835 return [
'uploaded-setting-event-handler-svg',
836 $strippedElement, $stripped, $value ];
840 if ( $strippedElement ===
'set'
841 && $stripped ===
'attributename'
842 && str_contains( $value,
'href' )
844 $this->logger->debug(
845 'detectScriptInSvg: Found SVG setting href attribute "{value}" ' .
849 return [
'uploaded-setting-href-svg' ];
853 if ( $strippedElement ===
'set'
854 && $stripped ===
'to'
855 && preg_match(
'!(http|https|data|script):!im', $value )
857 $this->logger->debug(
858 'detectScriptInSvg: Found SVG setting attribute to "{value}" in uploaded file.',
861 return [
'uploaded-wrong-setting-svg', $value ];
865 if ( $stripped ===
'handler'
866 && preg_match(
'!(http|https|data|script):!im', $value )
868 $this->logger->debug(
869 'detectScriptInSvg: Found SVG setting handler with remote/data/script ' .
870 '{attrib}="value" in uploaded file.',
873 return [
'uploaded-setting-handler-svg', $attrib, $value ];
877 if ( $stripped ===
'style'
878 && $this->svgCssChecker->checkStyleAttribute( $value ) !==
true
880 $this->logger->debug(
881 'detectScriptInSvg: Found SVG setting a style with remote url ' .
882 '{attrib}="{value}" in uploaded file.',
885 return [
'uploaded-remote-url-svg', $attrib, $value ];
889 if ( in_array( $stripped, $cssAttrs,
true )
890 && $this->svgCssChecker->checkPresentationalAttribute( $value ) !==
true
892 $this->logger->debug(
893 'detectScriptInSvg: Found SVG setting a style with ' .
894 '{attrib}="{value}" in uploaded file.',
897 return [
'uploaded-remote-url-svg', $attrib, $value ];
904 if ( $strippedElement ===
'image'
905 && $stripped ===
'filter'
906 && preg_match(
'!url\s*\(\s*["\']?[^#]!im', $value )
908 $this->logger->debug(
909 'detectScriptInSvg: Found image filter with URL: ' .
910 '<{localPart} {attrib}="{value}"> in uploaded file.',
913 return [
'uploaded-image-filter-svg', $strippedElement, $stripped, $value ];
926 private function splitXmlNamespace( $element ) {
928 $parts = explode(
':', strtolower( $element ) );
929 $name = array_pop( $parts );
930 $ns = implode(
':', $parts );
932 return [ $ns, $name ];
939 private function stripXmlNamespace( $element ) {
941 return self::splitXmlNamespace( $element )[1];
957 $mainConfig = $this->config;
962 $this->logger->debug(
'detectVirus: virus scanner disabled' );
966 if ( !( $antivirusSetup[$antivirus] ??
false ) ) {
971 $command = $antivirusSetup[$antivirus][
'command'];
972 $exitCodeMap = $antivirusSetup[$antivirus][
'codemap'];
973 $msgPattern = $antivirusSetup[$antivirus][
'messagepattern'] ??
null;
975 if ( !str_contains( $command,
"%f" ) ) {
977 $command .=
" " . Shell::escape( $file );
980 $command = str_replace(
"%f", Shell::escape( $file ), $command );
983 $this->logger->debug(
'detectVirus: running virus scan: {command}',
984 [
'command' => $command ] );
988 $output = Shell::command()->unsafeCommand( $command )->includeStderr()->execute();
989 $exitCode = $output->getExitCode();
992 $mappedCode = $exitCode;
993 if ( $exitCodeMap ) {
994 if ( isset( $exitCodeMap[$exitCode] ) ) {
995 $mappedCode = $exitCodeMap[$exitCode];
996 } elseif ( isset( $exitCodeMap[
"*"] ) ) {
997 $mappedCode = $exitCodeMap[
"*"];
1005 $this->logger->debug(
'detectVirus: failed to scan {file} (code {exitCode}).',
1006 [
'file' => $file,
'exitCode' => $exitCode ] );
1008 $output = $antivirusRequired
1009 ?
wfMessage(
'virus-scanfailed', [ $exitCode ] )->text()
1013 $this->logger->debug(
'detectVirus: unsupported file type {file} (code {exitCode}).',
1014 [
'file' => $file,
'exitCode' => $exitCode ] );
1018 $this->logger->debug(
'detectVirus: file passed virus scan.' );
1021 $output = trim( $output->getStdout() );
1025 } elseif ( $msgPattern ) {
1027 if ( preg_match( $msgPattern, $output, $groups ) && $groups[1] ) {
1028 $output = $groups[1];
1032 $this->logger->debug(
'detectVirus: FOUND VIRUS! scanner feedback: {output}',
1033 [
'output' => $output ] );