Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js |
— | — | @@ -959,9 +959,9 @@ |
960 | 960 | * @method |
961 | 961 | * @param {String} Title to check. |
962 | 962 | */ |
963 | | -LoopAndDepthCheck.prototype.check = function ( title ) { |
| 963 | +LoopAndDepthCheck.prototype.check = function ( title, maxDepth ) { |
964 | 964 | // XXX: set limit really low for testing! |
965 | | - if ( this.depth > 40 ) { |
| 965 | + if ( this.depth > maxDepth ) { |
966 | 966 | // too deep |
967 | 967 | //console.log( 'Loopcheck: ' + JSON.stringify( this, null, 2 ) ); |
968 | 968 | return 'Error: Expansion depth limit exceeded at '; |
Index: trunk/extensions/VisualEditor/modules/parser/parse.js |
— | — | @@ -22,6 +22,11 @@ |
23 | 23 | description: 'Debug mode', |
24 | 24 | 'boolean': true, |
25 | 25 | 'default': false |
| 26 | + }, |
| 27 | + 'maxdepth': { |
| 28 | + description: 'Maximum expansion depth', |
| 29 | + 'boolean': false, |
| 30 | + 'default': 40 |
26 | 31 | } |
27 | 32 | }).argv; |
28 | 33 | |
— | — | @@ -32,7 +37,8 @@ |
33 | 38 | wgScriptExtension: ".php", |
34 | 39 | fetchTemplates: true, |
35 | 40 | // enable/disable debug output using this switch |
36 | | - debug: argv.debug |
| 41 | + debug: argv.debug, |
| 42 | + maxDepth: argv.maxdepth |
37 | 43 | } ), |
38 | 44 | parser = new ParserPipeline( env ); |
39 | 45 | |
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.TemplateHandler.js |
— | — | @@ -189,7 +189,7 @@ |
190 | 190 | // now normalize the target before template processing |
191 | 191 | target = this.manager.env.normalizeTitle( target ); |
192 | 192 | |
193 | | - var checkRes = this.manager.loopAndDepthCheck.check( target ); |
| 193 | + var checkRes = this.manager.loopAndDepthCheck.check( target, this.manager.env.maxDepth ); |
194 | 194 | if( checkRes ) { |
195 | 195 | // Loop detected or depth limit exceeded, abort! |
196 | 196 | res = [ |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.environment.js |
— | — | @@ -6,7 +6,8 @@ |
7 | 7 | debug: false, |
8 | 8 | wgScriptPath: "http://en.wikipedia.org/w", |
9 | 9 | wgScriptExtension: ".php", |
10 | | - fetchTemplates: false |
| 10 | + fetchTemplates: false, |
| 11 | + maxDepth: 40 |
11 | 12 | }; |
12 | 13 | $.extend(options, opts); |
13 | 14 | $.extend(this, options); |