r102789 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102788‎ | r102789 | r102790 >
Date:15:19, 11 November 2011
Author:catrope
Status:resolved
Tags:
Comment:
[RL2] Use custom names and IDs for gadgets on the preferences page, and set them to something known to be safe and unique (I chose to use the md5 hash of the gadget ID). This prevents bugs where HTMLFormField::__construct() barfs on gadget IDs containing strange characters (such as spaces, see r102409)
Modified paths:
  • /branches/RL2/extensions/Gadgets/Gadgets.hooks.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/Gadgets.hooks.php
@@ -286,6 +286,9 @@
287287 'label' => $text,
288288 'section' => "gadgets$sectionCat",
289289 'default' => $gadget->isEnabledForUser( $user ),
 290+ // HTMLForm is very strict about the names/IDs it accepts
 291+ // So specify a custom name that we know is safe and won't change
 292+ 'name' => 'gadgetpref-' . md5($id),
290293 );
291294 } else {
292295 $preferences["gadget-$id"] = array(
@@ -294,6 +297,7 @@
295298 // TODO the below means source and category IDs can't contain slashes or dashes, enforce this
296299 'section' => "gadgetsshared/gadgetrepo-$repoSource$sectionCat",
297300 'cssclass' => 'mw-gadgets-shared-pref',
 301+ 'name' => 'gadgetpref-' . md5($id),
298302 // 'default' isn't in here by design: we don't want
299303 // enabledByDefault to be honored across wikis
300304 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r102790[RL2] Revert r102409, this is just getting in the way and causing underscores...catrope15:28, 11 November 2011
r102791[RL2] Followup r102789, whitespacecatrope15:29, 11 November 2011
r102796[RL2] Followup r102789, use bin2hex() instead of md5() to encode gadget IDs. ...catrope16:18, 11 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102409[RL2] Consistently use $title->getDBKey() instead of $title->getText() to bui...catrope16:10, 8 November 2011

Status & tagging log