r51425 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51424‎ | r51425 | r51426 >
Date:17:13, 3 June 2009
Author:tstarling
Status:deferred
Tags:
Comment:
Reverted r49586, shell injection vulnerability noted on CodeReview.
Modified paths:
  • /trunk/extensions/SyntaxHighlight_vim/Syntax.php (modified) (history)
  • /trunk/extensions/SyntaxHighlight_vim/SyntaxHook.php (modified) (history)
  • /trunk/extensions/SyntaxHighlight_vim/vimrc.vim (modified) (history)

Diff [purge]

Index: trunk/extensions/SyntaxHighlight_vim/vimrc.vim
@@ -4,6 +4,6 @@
55
66 set uc=0 " Disable swap files
77
8 -set background=light
 8+set background=dark
99
1010 colorscheme pablo
Index: trunk/extensions/SyntaxHighlight_vim/Syntax.php
@@ -19,10 +19,9 @@
2020 function wfSyntax() {
2121 wfUsePHP( 5.1 );
2222 wfUseMW( '1.6alpha' );
23 -
 23+
2424 class Syntax {
2525 private $mIn;
26 - private $mInFormat, $mColorscheme;
2726 private $mInFile, $mOutFile;
2827 private $mVimrc;
2928
@@ -30,13 +29,11 @@
3130 $this->mVimrc = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'vimrc.vim';
3231
3332 $this->mIn = $in;
34 - $this->mInFormat = $format;
35 - $this->mColorscheme = $colorscheme;
3633 }
3734
3835 public function getOut() {
3936 $this->genTemp();
40 -
 37+
4138 if ( ! $handle = fopen( $this->mInFile, 'a' ) )
4239 die( 'AAAAAAA' );
4340 if ( fwrite( $handle, $this->mIn ) === false )
@@ -48,7 +45,7 @@
4946 $html = preg_replace( '~</p>\s*</body>.*?$~s', '</style>', $html );
5047
5148 $this->rmTemp();
52 -
 49+
5350 return $html;
5451 }
5552
@@ -56,22 +53,19 @@
5754 $this->mInFile = $this->mktemp();
5855 $this->mOutFile = $this->mktemp();
5956 }
60 -
 57+
6158 private static function mktemp() {
6259 return rtrim( shell_exec( 'mktemp -u' ), "\n" );
6360 }
64 -
 61+
6562 private function rmTemp() {
6663 unlink( $this->mInFile );
6764 unlink( $this->mOutFile );
6865 }
6966
7067 private function run() {
71 - $commands = '';
72 - if( $this->mInFormat ) { $commands .= "+'set filetype={$this->mInFormat}' "; }
73 - if( $this->mColorscheme ) { $commands .= "+'colorscheme {$this->mColorscheme}' "; }
74 - shell_exec( "vim -u {$this->mVimrc} -e {$commands} +'run! syntax/2html.vim' +':w {$this->mOutFile}' +':qa!' {$this->mInFile}" );
75 -
 68+ shell_exec( "vim -u {$this->mVimrc} -e +'run! syntax/2html.vim' +':w {$this->mOutFile}' +':qa!' {$this->mInFile}" );
 69+
7670 return file_get_contents( $this->mOutFile );
7771 }
7872 }
Index: trunk/extensions/SyntaxHighlight_vim/SyntaxHook.php
@@ -33,13 +33,8 @@
3434
3535 public function hook( $in, array $argv ) {
3636 $in = ltrim( $in, "\n" );
 37+ $syntax = new Syntax( $in );
3738
38 - $format = $colorscheme = null;
39 - if( isset( $argv['lang'] ) ) { $format = $argv['lang']; }
40 - if( isset( $argv['colorscheme'] ) ) { $colorscheme = $argv['colorscheme']; }
41 -
42 - $syntax = new Syntax( $in, $format, $colorscheme );
43 -
4439 return $syntax->getOut();
4540 }
4641 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49586(bug 17949) Add support to chose language and colorscheme to SyntaxHighlight_...siebrand23:42, 16 April 2009

Status & tagging log