SECURITY: Allow user to only apply protection they have right to do so via action=protect
'apierror-protect-invalidlevel' potentially wants updating at a later point as the message isn't necessarily clear what the error is; the protection may be valid but the users right to do so is not. Bug: T270713 Change-Id: I72fe67264baa4123599ec424a7d780192ca54bcc
This commit is contained in:
parent
497b53853d
commit
6b9be9c0e9
1 changed files with 5 additions and 1 deletions
|
|
@ -67,6 +67,10 @@ class ApiProtect extends ApiBase {
|
|||
}
|
||||
|
||||
$restrictionTypes = $titleObj->getRestrictionTypes();
|
||||
$levels = $this->getPermissionManager()->getNamespaceRestrictionLevels(
|
||||
$titleObj->getNamespace(),
|
||||
$user
|
||||
);
|
||||
|
||||
$protections = [];
|
||||
$expiryarray = [];
|
||||
|
|
@ -85,7 +89,7 @@ class ApiProtect extends ApiBase {
|
|||
if ( !in_array( $p[0], $restrictionTypes ) && $p[0] != 'create' ) {
|
||||
$this->dieWithError( [ 'apierror-protect-invalidaction', wfEscapeWikiText( $p[0] ) ] );
|
||||
}
|
||||
if ( !in_array( $p[1], $this->getConfig()->get( 'RestrictionLevels' ) ) && $p[1] != 'all' ) {
|
||||
if ( !in_array( $p[1], $levels ) && $p[1] != 'all' ) {
|
||||
$this->dieWithError( [ 'apierror-protect-invalidlevel', wfEscapeWikiText( $p[1] ) ] );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue