(bug 40124) allow arbitrary user preferences prefixed with 'userjs-'
authorMatmaRex <matma.rex@gmail.com>
Fri, 7 Dec 2012 21:10:12 +0000 (22:10 +0100)
committerMatmaRex <matma.rex@gmail.com>
Sun, 13 Jan 2013 18:08:56 +0000 (19:08 +0100)
commit733d19d0d0d460b07ddda68fedce26cbf609c38f
tree8824db24dde2771ecba5b22c6657fc1a75cc4293
parenta1af4d7cdbb9fea271d7785f47f47ecf26b1990f
(bug 40124) allow arbitrary user preferences prefixed with 'userjs-'

Before change I98df55f2 it was possible to set arbitrary preferences (ie.
with anything as the key) using the action=options API. That change
removed this ability by enforcing full validation of the preferences, also
introducing several regressions which were fixed by follow-ups.

Per the discussion on bug 40124, this changeset aims to restore this
ability, but in a slightly restricted way: arbitrary preferences' names
must start with userjs- prefix, to avoid any possibility of conflicting
with new MediaWiki versions or extensions.

The contents of these preferences is not escaped, sanitized nor validated
in any way; script authors are expected to sanitize them themselves to
prevent XSS attacks and other security vulnerabilities.

This commit also adds the User::getOptionsKinds() method (to determine
whether given preference keys are used by MediaWiki itself or an extension,
intended to be used via the API, or entirely unknown) and enhances the
User::resetOptions() method to allow for resetting only preferences of
chosen kinds.

These changes allow for fixing of Special:Preferences not to clear those
additional fields when saving user settings.

Change-Id: I5f9ba5b0dfe7c2ea5458d836f03429cf6d93969d
RELEASE-NOTES-1.21
includes/Preferences.php
includes/User.php
includes/api/ApiOptions.php
includes/specials/SpecialPreferences.php
tests/phpunit/includes/api/ApiOptionsTest.php