fix: harden CHRNX editor lifecycle

This commit is contained in:
chrnx committed 2026-08-11 15:06:50 -05:00
1 parent a5b94123a8
commit 835fb74ebf
12 files changed
+512 -95

No files matched your search

+15 -3
View File
@@ -5,6 +5,9 @@
* @package CHRNX
*/
define( 'CHRNX_MAX_EPISODE_PARTICIPANTS', 50 );
define( 'CHRNX_MAX_EPISODE_PARTICIPANT_LENGTH', 100 );
/**
* Sanitize an episode number.
*
@@ -39,7 +42,7 @@ function chrnx_sanitize_episode_duration( $value ) {
* Sanitize participant names while preserving their order.
*
* @param mixed $value Submitted value.
* @return string[] Sanitized participant names.
* @return string[] Up to 50 sanitized names of up to 100 Unicode characters each.
*/
function chrnx_sanitize_episode_participants( $value ) {
if ( ! is_array( $value ) ) {
@@ -48,11 +51,16 @@ function chrnx_sanitize_episode_participants( $value ) {
$participants = array();
foreach ( $value as $participant ) {
if ( count( $participants ) >= CHRNX_MAX_EPISODE_PARTICIPANTS ) {
break;
}
if ( ! is_scalar( $participant ) ) {
continue;
}
$name = trim( sanitize_text_field( (string) $participant ) );
$name = mb_substr( $name, 0, CHRNX_MAX_EPISODE_PARTICIPANT_LENGTH, 'UTF-8' );
if ( '' !== $name ) {
$participants[] = $name;
}
@@ -113,8 +121,12 @@ function chrnx_register_podcast_meta() {
'type' => 'array',
'sanitize_callback' => 'chrnx_sanitize_episode_participants',
'schema' => array(
'type' => 'array',
'items' => array( 'type' => 'string' ),
'type' => 'array',
'maxItems' => CHRNX_MAX_EPISODE_PARTICIPANTS,
'items' => array(
'type' => 'string',
'maxLength' => CHRNX_MAX_EPISODE_PARTICIPANT_LENGTH,
),
),
),
'canonical_episode_url' => array(