aboutsummaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>2021-02-19 15:52:53 +0100
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>2021-02-19 17:04:35 +0100
commit47171f7b94c5623ce175d9544e88bc12f7819502 (patch)
treecc4f3769ce7e67dfe3a95fc75f38f67129a4ad3c /includes
parent09d2fd495e2d2c0af5c1aee1fc99d2dd0932698d (diff)
downloadmediawikicore-47171f7b94c5623ce175d9544e88bc12f7819502.tar.gz
mediawikicore-47171f7b94c5623ce175d9544e88bc12f7819502.zip
Don't accept empty option group names for dropdown elements
When this code parses a string that looks like this: * ** A ** B It creates an option group with 2 options, but the name of the group is an empty string. This makes the OOUI DropdownInputWidget fail later. Since the empty group name is useless anyway, drop it. This makes the code behave as if the parsed string looked like this: * A * B Live example for the issue: https://el.wikipedia.org/wiki/MediaWiki:Protect-dropdown Bug: T275125 Change-Id: I780c1be27740b0ed3b35aa569b5a528112d7238f
Diffstat (limited to 'includes')
-rw-r--r--includes/xml/Xml.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/includes/xml/Xml.php b/includes/xml/Xml.php
index 4462f1a55165..f07e35859444 100644
--- a/includes/xml/Xml.php
+++ b/includes/xml/Xml.php
@@ -557,10 +557,14 @@ class Xml {
} elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
# A new group is starting...
$value = trim( substr( $value, 1 ) );
- # Do not use the value for 'other' as option group - T251351
- $optgroup = isset( $params['other'] ) && $params['other'] === $value
- ? false
- : $value;
+ if ( $value !== '' &&
+ // Do not use the value for 'other' as option group - T251351
+ ( !isset( $params['other'] ) || $value !== $params['other'] )
+ ) {
+ $optgroup = $value;
+ } else {
+ $optgroup = false;
+ }
} elseif ( substr( $value, 0, 2 ) == '**' ) {
# groupmember
$opt = trim( substr( $value, 2 ) );