mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-23 23:43:54 +00:00
Merge "Fix parameter auto-detection picking up syntax elements"
This commit is contained in:
commit
da2077d5bc
|
@ -959,7 +959,7 @@ class TemplateDataBlob {
|
||||||
$wikitext = preg_replace( '/<nowiki\s*>.*?<\/nowiki\s*>/s', '', $wikitext );
|
$wikitext = preg_replace( '/<nowiki\s*>.*?<\/nowiki\s*>/s', '', $wikitext );
|
||||||
|
|
||||||
// This regex matches the one in ext.TemplateDataGenerator.sourceHandler.js
|
// This regex matches the one in ext.TemplateDataGenerator.sourceHandler.js
|
||||||
preg_match_all( '/{{3,}([^#]*?)([<|]|}{3,})/m', $wikitext, $rawParams );
|
preg_match_all( '/{{3,}([^\n#={|}]*?)([<|]|}{3,})/m', $wikitext, $rawParams );
|
||||||
$params = [];
|
$params = [];
|
||||||
$normalizedParams = [];
|
$normalizedParams = [];
|
||||||
if ( isset( $rawParams[1] ) ) {
|
if ( isset( $rawParams[1] ) ) {
|
||||||
|
|
|
@ -171,7 +171,7 @@ SourceHandler.prototype.extractParametersFromTemplateCode = function ( templateC
|
||||||
var paramNames = [],
|
var paramNames = [],
|
||||||
normalizedParamNames = [],
|
normalizedParamNames = [],
|
||||||
// This regex matches the one in TemplateDataBlob.php
|
// This regex matches the one in TemplateDataBlob.php
|
||||||
paramExtractor = /{{3,}([^#]*?)([<|]|}{3,})/mg;
|
paramExtractor = /{{3,}([^\n#={|}]*?)([<|]|}{3,})/mg;
|
||||||
|
|
||||||
// Strip everything in nowiki tags and HTML comments
|
// Strip everything in nowiki tags and HTML comments
|
||||||
templateCode = templateCode.replace( /<!--[\s\S]*?-->/g, '' )
|
templateCode = templateCode.replace( /<!--[\s\S]*?-->/g, '' )
|
||||||
|
|
|
@ -1396,6 +1396,18 @@ class TemplateDataBlobTest extends MediaWikiIntegrationTestCase {
|
||||||
'{{ {{{|safesubst:}}}#invoke:…|{{{1}}}|{{{ 1 }}}}}',
|
'{{ {{{|safesubst:}}}#invoke:…|{{{1}}}|{{{ 1 }}}}}',
|
||||||
[ '1' => [] ]
|
[ '1' => [] ]
|
||||||
],
|
],
|
||||||
|
'Characters impossible in parameter names' => [
|
||||||
|
'{{test|a|b=c|d=e=f}} {{{a|b}}} {{{d=e}}}',
|
||||||
|
[ 'a' => [] ]
|
||||||
|
],
|
||||||
|
'Characters that are, while technically possible, almost certainly a mistake' => [
|
||||||
|
"{{{a{a}}} {{{b}b}}} {{{c\nc}}}",
|
||||||
|
[]
|
||||||
|
],
|
||||||
|
'Table syntax escaped with {{!}}' => [
|
||||||
|
'{{{!}}\n! This is table syntax\n{{!}}}',
|
||||||
|
[]
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue