mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-27 17:20:01 +00:00
Add missing validation for aliases and suggestedvalues
This is not new. This was always documented to not accept anything but strings. Let's apply the same fix to aliases while we are here. Bug: T297386 Change-Id: I57e18779f28802816d5adb66cc4067df4e58b26e
This commit is contained in:
parent
3fd6b8aa61
commit
e83e3f2661
|
@ -309,12 +309,14 @@ class TemplateDataBlob {
|
|||
// Param.aliases
|
||||
if ( isset( $paramObj->aliases ) ) {
|
||||
if ( !is_array( $paramObj->aliases ) ) {
|
||||
// TODO: Validate the array values.
|
||||
return Status::newFatal(
|
||||
'templatedata-invalid-type',
|
||||
"params.{$paramName}.aliases",
|
||||
'array'
|
||||
);
|
||||
return Status::newFatal( 'templatedata-invalid-type',
|
||||
"params.{$paramName}.aliases", 'array' );
|
||||
}
|
||||
foreach ( $paramObj->aliases as $i => $alias ) {
|
||||
if ( !is_string( $alias ) ) {
|
||||
return Status::newFatal( 'templatedata-invalid-type',
|
||||
"params.{$paramName}.aliases[$i]", 'string' );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$paramObj->aliases = [];
|
||||
|
@ -376,11 +378,14 @@ class TemplateDataBlob {
|
|||
// Param.suggestedvalues
|
||||
if ( isset( $paramObj->suggestedvalues ) ) {
|
||||
if ( !is_array( $paramObj->suggestedvalues ) ) {
|
||||
return Status::newFatal(
|
||||
'templatedata-invalid-type',
|
||||
"params.{$paramName}.suggestedvalues",
|
||||
'array'
|
||||
);
|
||||
return Status::newFatal( 'templatedata-invalid-type',
|
||||
"params.{$paramName}.suggestedvalues", 'array' );
|
||||
}
|
||||
foreach ( $paramObj->suggestedvalues as $i => $value ) {
|
||||
if ( !is_string( $value ) ) {
|
||||
return Status::newFatal( 'templatedata-invalid-type',
|
||||
"params.{$paramName}.suggestedvalues[$i]", 'string' );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$paramObj->suggestedvalues = [];
|
||||
|
@ -841,7 +846,7 @@ class TemplateDataBlob {
|
|||
}
|
||||
|
||||
$suggestedValuesLine = '';
|
||||
if ( count( $paramObj->suggestedvalues ) ) {
|
||||
if ( $paramObj->suggestedvalues ) {
|
||||
$suggestedValues = '';
|
||||
foreach ( $paramObj->suggestedvalues as $suggestedValue ) {
|
||||
$suggestedValues .= wfMessage( 'word-separator' )->inLanguage( $lang )->escaped()
|
||||
|
|
Loading…
Reference in a new issue