r55824 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55823‎ | r55824 | r55825 >
Date:15:30, 4 September 2009
Author:dale
Status:deferred
Tags:
Comment:
* escaped a few more values
Modified paths:
  • /trunk/phase3/js2/mwEmbed/jsScriptLoader.php (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/jsScriptLoader.php
@@ -46,9 +46,9 @@
4747 }
4848
4949 // setup script loader header info
50 - $this->jsout .= 'var mwSlScript = "' . $_SERVER['SCRIPT_NAME'] . '";' . "\n";
 50+ $this->jsout .= 'var mwSlScript = "' . htmlspecialchars( $_SERVER['SCRIPT_NAME'] ) . '";' . "\n";
5151 $this->jsout .= 'var mwSlGenISODate = "' . date( 'c' ) . '";' ."\n";
52 - $this->jsout .= 'var mwSlURID = "' . $this->urid . '";' ."\n";
 52+ $this->jsout .= 'var mwSlURID = "' . htmlspecialchars( $this->urid ) . '";' ."\n";
5353 // Build the output:
5454 // swap in the appropriate language per js_file
5555 foreach( $this->jsFileList as $classKey => $file_name ){
@@ -79,6 +79,11 @@
8080 continue;
8181 }
8282 } else {
 83+ //make sure the wiki title ends with .js
 84+ if( substr( $title_block, -3 ) != '.js'){
 85+ $this->error_msg .= 'WikiTitle includes should end with .js';
 86+ continue;
 87+ }
8388 // it's a wikiTitle append the output of the wikitext:
8489 $t = Title::newFromText( $title_block );
8590 $a = new Article( $t );
@@ -92,11 +97,11 @@
9398 //dealing with files::
9499 //check that the filename ends with .js and does not include ../ traversing
95100 if( substr( $file_name, -3 ) != '.js'){
96 - $this->jsout .= "\nError file name must end with .js: ". htmlspecialchars( $file_name ) . " \n ";
 101+ $this->error_msg .= "\nError file name must end with .js: ". htmlspecialchars( $file_name ) . " \n ";
97102 continue;
98103 }
99104 if( strpos($file_name, '../') !== false ){
100 - $this->jsout .= "\nError file name must not traverse paths: ". htmlspecialchars( $file_name ) . " \n ";
 105+ $this->error_msg .= "\nError file name must not traverse paths: ". htmlspecialchars( $file_name ) . " \n ";
101106 continue;
102107 }
103108
@@ -205,7 +210,7 @@
206211 $this->jsFileList[$reqClass] = $wgJSAutoloadClasses[$reqClass];
207212 $this->rKey.= $reqClass;
208213 } else {
209 - $this->error_msg.= 'Requested class: ' . $reqClass . ' not found' . "\n";
 214+ $this->error_msg.= 'Requested class: ' . htmlspecialchars( $reqClass ) . ' not found' . "\n";
210215 }
211216 }
212217 }
@@ -288,7 +293,7 @@
289294 return 'loadGM( ' . json_encode( $jmsg ) . ')';
290295 } else {
291296 $this->error_msg.= "Could not parse JSON language msg in File:\n" .
292 - $this->cur_file . "\n";
 297+ htmlspecialchars ( $this->cur_file ) . "\n";
293298 }
294299 // could not parse json (throw error?)
295300 return $jvar[0];

Status & tagging log