- $params['detectCallback'] = function ( $file ) use ( $detectorCmd ) {
- return wfShellExec( "$detectorCmd " . wfEscapeShellArg( $file ) );
+ $factory = $services->getShellCommandFactory();
+ $params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) {
+ $result = $factory->create()
+ // $wgMimeDetectorCommand can contain commands with parameters
+ ->unsafeParams( $detectorCmd )
+ ->params( $file )
+ ->execute();
+ return $result->getStdout();