- if ( ! preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/",
- $wpBlockAddress ) ) {
- $this->showForm( wfMsg( "badipaddress" ) );
- return;
+ # Check for invalid specifications
+ if ( ! preg_match( "/^$rxIP$/", $this->BlockAddress ) ) {
+ if ( preg_match( "/^($rxIP)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) {
+ if ( $wgSysopRangeBans ) {
+ if ( $matches[2] > 31 || $matches[2] < 16 ) {
+ $this->showForm( wfMsg( "ip_range_invalid" ) );
+ return;
+ }
+ $this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
+ } else {
+ # Range block illegal
+ $this->showForm( wfMsg( "range_block_disabled" ) );
+ return;
+ }
+ } else {
+ # Username block
+ if ( $wgSysopUserBans ) {
+ $userId = User::idFromName( $this->BlockAddress );
+ if ( $userId == 0 ) {
+ $this->showForm( wfMsg( "nosuchuser", htmlspecialchars( $this->BlockAddress ) ) );
+ return;
+ }
+ } else {
+ $this->showForm( wfMsg( "badipaddress" ) );
+ return;
+ }
+ }