From 8bba7dd4e2918e9f5996c6f561a7ed0236e143e2 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 12 Mar 2025 09:51:46 +1100 Subject: block: Fix failure to sanitize a range blocked with ApiBlock Bug: T388097 Change-Id: I89baf1b190cf9adefba9a232f57c957a2345f8e5 --- tests/phpunit/includes/api/ApiBlockTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/phpunit/includes/api/ApiBlockTest.php') diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php index 7f15985a9c6f..3c4334d5fd2e 100644 --- a/tests/phpunit/includes/api/ApiBlockTest.php +++ b/tests/phpunit/includes/api/ApiBlockTest.php @@ -348,6 +348,22 @@ class ApiBlockTest extends ApiTestCase { $this->doBlock(); } + public function testNonNormalizedRangeBlock() { + $params = [ + 'action' => 'block', + 'user' => '128.0.0.1/16', + 'reason' => 'Some reason', + ]; + $res = $this->doApiRequestWithToken( $params ); + $this->assertSame( '128.0.0.0/16', $res[0]['block']['user'] ); + $this->newSelectQueryBuilder() + ->select( 'bt_address' ) + ->from( 'block_target' ) + ->join( 'block', null, 'bl_target=bt_id' ) + ->where( [ 'bl_id' => $res[0]['block']['id'] ] ) + ->assertFieldValue( '128.0.0.0/16' ); + } + public function testBlockByIdReturns() { // See T189073 and Ifdced735b694b85116cb0e43dadbfa8e4cdb8cab for context $userId = $this->mUser->getId(); -- cgit v1.2.3