r109748 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109747‎ | r109748 | r109749 >
Date:19:32, 22 January 2012
Author:gwicke
Status:deferred
Tags:
Comment:
A few parser function fixes and maximum template expansion in environment
config.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/ext.core.TemplateHandler.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.environment.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/parse.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js
@@ -959,9 +959,9 @@
960960 * @method
961961 * @param {String} Title to check.
962962 */
963 -LoopAndDepthCheck.prototype.check = function ( title ) {
 963+LoopAndDepthCheck.prototype.check = function ( title, maxDepth ) {
964964 // XXX: set limit really low for testing!
965 - if ( this.depth > 40 ) {
 965+ if ( this.depth > maxDepth ) {
966966 // too deep
967967 //console.log( 'Loopcheck: ' + JSON.stringify( this, null, 2 ) );
968968 return 'Error: Expansion depth limit exceeded at ';
Index: trunk/extensions/VisualEditor/modules/parser/parse.js
@@ -22,6 +22,11 @@
2323 description: 'Debug mode',
2424 'boolean': true,
2525 'default': false
 26+ },
 27+ 'maxdepth': {
 28+ description: 'Maximum expansion depth',
 29+ 'boolean': false,
 30+ 'default': 40
2631 }
2732 }).argv;
2833
@@ -32,7 +37,8 @@
3338 wgScriptExtension: ".php",
3439 fetchTemplates: true,
3540 // enable/disable debug output using this switch
36 - debug: argv.debug
 41+ debug: argv.debug,
 42+ maxDepth: argv.maxdepth
3743 } ),
3844 parser = new ParserPipeline( env );
3945
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.TemplateHandler.js
@@ -189,7 +189,7 @@
190190 // now normalize the target before template processing
191191 target = this.manager.env.normalizeTitle( target );
192192
193 - var checkRes = this.manager.loopAndDepthCheck.check( target );
 193+ var checkRes = this.manager.loopAndDepthCheck.check( target, this.manager.env.maxDepth );
194194 if( checkRes ) {
195195 // Loop detected or depth limit exceeded, abort!
196196 res = [
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.environment.js
@@ -6,7 +6,8 @@
77 debug: false,
88 wgScriptPath: "http://en.wikipedia.org/w",
99 wgScriptExtension: ".php",
10 - fetchTemplates: false
 10+ fetchTemplates: false,
 11+ maxDepth: 40
1112 };
1213 $.extend(options, opts);
1314 $.extend(this, options);

Status & tagging log