Skip to content

Commit 76ff354

Browse files
authored
Fix security vulnerability reported via MSRC
1 parent f0feee1 commit 76ff354

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

PandocUpload/PandocUpload.hooks.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @licence GNU General Public Licence 2.0 or later
99
*/
1010

11+
use MediaWiki\Shell\Shell;
12+
1113
class PandocUploadHooks {
1214

1315
private static $conversionArray = array(
@@ -85,15 +87,14 @@ public static function onUploadComplete( &$image ) {
8587
throw new MWException(wfMessage("pandocupload-warning-unsupported-format")->params( $ext )->plain());
8688
}
8789

88-
$output = array();
89-
$command = sprintf(
90-
'"%s" --from=%s --to=%s "%s" 2>&1',
90+
$res = Shell::command(
9191
$wgPandocExecutablePath,
92-
self::$conversionArray[$ext],
93-
"mediawiki",
92+
'--from=' . self::$conversionArray[$ext],
93+
'--to=mediawiki',
9494
$file->getLocalRefPath()
95-
);
96-
exec( $command, $output );
95+
)->includeStderr()
96+
->execute();
97+
$output = explode( "\n", $res->getStdout() );
9798
// post processing: transform regular tables to wikitables
9899
foreach ( $output as &$line ) {
99100
if ( $line == "{|" ) {

0 commit comments

Comments
 (0)