Skip to content

Commit e5659cd

Browse files
committed
Address PR feedback: add moderation anchor and email-like identifier tests
- Add #moderation anchor to settings link for direct navigation. - Wrap Moderation section with ID for anchor targeting. - Add tests confirming email-like identifiers are gracefully skipped.
1 parent 64b24b8 commit e5659cd

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

includes/wp-admin/class-settings-fields.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public static function register_settings_fields() {
5959
'activitypub_moderation',
6060
\esc_html__( 'Moderation', 'activitypub' ),
6161
array( self::class, 'render_moderation_section_description' ),
62-
'activitypub_settings'
62+
'activitypub_settings',
63+
array(
64+
'before_section' => '<div id="moderation">',
65+
'after_section' => '</div>',
66+
)
6367
);
6468

6569
// Add settings fields.

includes/wp-admin/import/class-blocklist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private static function import( $domains ) {
281281

282282
\printf(
283283
'<p><a href="%s">%s</a></p>',
284-
\esc_url( \admin_url( 'options-general.php?page=activitypub&tab=settings' ) ),
284+
\esc_url( \admin_url( 'options-general.php?page=activitypub&tab=settings#moderation' ) ),
285285
\esc_html__( 'View blocked domains in settings', 'activitypub' )
286286
);
287287
}

tests/phpunit/tests/includes/wp-admin/import/class-test-blocklist.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,38 @@ public function test_parse_csv_rejects_domain_starting_with_hyphen() {
352352
$this->assertContains( 'valid.com', $domains );
353353
$this->assertNotContains( '-invalid.com', $domains );
354354
}
355+
356+
/**
357+
* Test that email-like identifiers are skipped gracefully.
358+
*
359+
* @covers ::parse_csv
360+
*/
361+
public function test_parse_csv_skips_email_like_identifiers() {
362+
$csv_content = "[email protected]\n";
363+
$csv_content .= "[email protected]\n";
364+
$csv_content .= "valid.org\n";
365+
$csv_content .= "@invalid.net\n";
366+
367+
$file = $this->create_temp_csv( $csv_content );
368+
$domains = Blocklist::parse_csv( $file );
369+
370+
$this->assertSame( array( 'valid.org' ), $domains );
371+
}
372+
373+
/**
374+
* Test that email-like identifiers in Mastodon CSV format are skipped gracefully.
375+
*
376+
* @covers ::parse_csv
377+
*/
378+
public function test_parse_csv_mastodon_format_skips_email_like_identifiers() {
379+
$csv_content = "#domain,#severity,#public_comment\n";
380+
$csv_content .= "[email protected],suspend,\"Test\"\n";
381+
$csv_content .= "valid.org,silence,\"Test\"\n";
382+
$csv_content .= "[email protected],suspend,\"Test\"\n";
383+
384+
$file = $this->create_temp_csv( $csv_content );
385+
$domains = Blocklist::parse_csv( $file );
386+
387+
$this->assertSame( array( 'valid.org' ), $domains );
388+
}
355389
}

0 commit comments

Comments
 (0)