From 4a72de903fed3457426319718056117e1d2d707f Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Wed, 9 Sep 2009 23:18:42 +0000 Subject: [PATCH] the rest of 56116 --- js2/mwEmbed/jsScriptLoader.php | 38 ++++++++++++++++++++-------------- js2/mwEmbed/mv_embed.js | 12 ++++------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/js2/mwEmbed/jsScriptLoader.php b/js2/mwEmbed/jsScriptLoader.php index 0dc7758e71..c60afb55ab 100644 --- a/js2/mwEmbed/jsScriptLoader.php +++ b/js2/mwEmbed/jsScriptLoader.php @@ -42,7 +42,7 @@ class jsScriptLoader { } // Setup script loader header info - $this->jsout .= 'var mwSlScript = "' . htmlspecialchars( $_SERVER['SCRIPT_NAME'] ) . '";' . "\n"; + $this->jsout .= 'var mwSlScript = "' . $_SERVER['SCRIPT_NAME'] . '";' . "\n"; $this->jsout .= 'var mwSlGenISODate = "' . date( 'c' ) . '";' . "\n"; $this->jsout .= 'var mwSlURID = "' . htmlspecialchars( $this->urid ) . '";' . "\n"; // Build the output @@ -91,7 +91,7 @@ class jsScriptLoader { } // Dealing with files - + // Check that the filename ends with .js and does not include ../ traversing if ( substr( $file_name, - 3 ) != '.js' ) { $this->error_msg .= "\nError file name must end with .js: " . htmlspecialchars( $file_name ) . " \n "; @@ -139,7 +139,7 @@ class jsScriptLoader { header( 'Content-Type: ' . $wgJsMimeType ); header( 'Pragma: public' ); // Cache forever - // The point is we never have to revalidate, since we should always change the request URL + // The point is we never have to revalidate, since we should always change the request URL // based on the SVN or article version. $one_year = 60 * 60 * 24 * 365; header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $one_year ) . " GM" ); @@ -201,14 +201,12 @@ class jsScriptLoader { $reqClass = preg_replace( "/[^A-Za-z0-9_\-\.]/", '', $reqClass ); - if ( isset( $wgJSAutoloadLocalClasses[$reqClass] ) ) { - $this->jsFileList[$reqClass] = $wgJSAutoloadLocalClasses[$reqClass]; - $this->rKey .= $reqClass; - } else if ( isset( $wgJSAutoloadClasses[$reqClass] ) ) { - $this->jsFileList[$reqClass] = $wgJSAutoloadClasses[$reqClass]; - $this->rKey .= $reqClass; - } else { + $jsFilePath = self::getJsPathFromClass( $reqClass ); + if(!$jsFilePath){ $this->error_msg .= 'Requested class: ' . htmlspecialchars( $reqClass ) . ' not found' . "\n"; + }else{ + $this->jsFileList[ $reqClass ] = $jsFilePath; + $this->rKey .= $reqClass; } } } @@ -248,7 +246,16 @@ class jsScriptLoader { $this->rKey .= '_min'; } } - + public static function getJsPathFromClass( $reqClass ){ + global $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses; + if ( isset( $wgJSAutoloadLocalClasses[$reqClass] ) ) { + return $wgJSAutoloadLocalClasses[$reqClass]; + } else if ( isset( $wgJSAutoloadClasses[$reqClass] ) ) { + return $wgJSAutoloadClasses[$reqClass]; + } else { + return false; + } + } function doProcessJsFile( $file_name ) { global $IP, $wgEnableScriptLocalization, $IP; @@ -270,7 +277,7 @@ class jsScriptLoader { if ( $wgEnableScriptLocalization ) $str = preg_replace_callback( // @@todo fix: will break down if someone does }) in their msg text - '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', + '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', array( $this, 'languageMsgReplace' ), $str ); @@ -282,14 +289,15 @@ class jsScriptLoader { if ( !isset( $jvar[1] ) ) return; - $jmsg = json_decode( '{' . $jvar[1] . '}', true ); + $jmsg = FormatJson::decode( '{' . $jvar[1] . '}', true ); + // Do the language lookup if ( $jmsg ) { foreach ( $jmsg as $msgKey => $default_en_value ) { $jmsg[$msgKey] = wfMsgNoTrans( $msgKey ); } // Return the updated loadGM JSON with fixed new lines - return 'loadGM( ' . json_encode( $jmsg ) . ')'; + return 'loadGM( ' . FormatJson::encode( $jmsg ) . ')'; } else { $this->error_msg .= "Could not parse JSON language msg in File:\n" . htmlspecialchars ( $this->cur_file ) . "\n"; @@ -343,7 +351,7 @@ class simpleFileCache { readfile( $this->filename ); } else { /* Send uncompressed. Check if fileCache is in compressed state (ends with .gz) - * We're unlikely to execute this since $wgUseGzip would have created a new file + * We're unlikely to execute this since $wgUseGzip would have created a new file * above, but just in case. */ if ( substr( $this->filename, - 3 ) == '.gz' ) { diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index a88298d4d1..cc9320c8f0 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -441,6 +441,7 @@ var mvJsLoader = { }else{ var scriptPath = puri.path; } + js_log('scriptServer Path is: ' + scriptPath + "\n host script path:" + getMvEmbedURL() ); var dbug_attr = ( puri.queryKey['debug'] ) ? '&debug=true' : ''; this.libs[ last_class ] = scriptPath + '?class=' + class_set + '&urid=' + getMvUniqueReqId() + dbug_attr; @@ -474,7 +475,7 @@ var mvJsLoader = { } } else { //js_log('checkLoading passed. Running callbacks...'); - // Only do callbacks if we are in the same instance (weird concurency issue) + // Only do callbacks if we are in the same instance (weird concurrency issue) var cb_count=0; for( var i = 0; i < this.callbacks.length; i++ ) cb_count++; @@ -1356,13 +1357,8 @@ function getMvEmbedURL() { ( src.indexOf( 'mwScriptLoader.php' ) != -1 || src.indexOf('jsScriptLoader.php') != -1 ) && src.indexOf('mv_embed') != -1) ) //(check for class=mv_embed script_loader call) { - if(typeof wgScriptPath != 'undefined' && src.indexOf( 'mwScriptLoader.php' ) != -1 ){ - _global['mv_embed_url'] = wgScriptPath + '/mwScriptLoader.php'; - return _global['mv_embed_url'] - }else{ - _global['mv_embed_url'] = src; - return src; - } + _global['mv_embed_url'] = src; + return src; } } } -- 2.20.1