Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/stream/build/admin.asset.php
+++ b/stream/build/admin.asset.php
@@ -2,5 +2,5 @@
'dependencies' => array(
'jquery'
),
- 'version' => '177c8f1cf64dc8373d62'
+ 'version' => 'fc189a302345540c4a02'
);
--- a/stream/classes/class-list-table-column-renderer.php
+++ b/stream/classes/class-list-table-column-renderer.php
@@ -55,7 +55,7 @@
break;
case 'summary':
- $out = $record->summary;
+ $out = esc_html( (string) $record->summary );
$object_title = $record->get_object_title();
/* translators: %s: the title of any object, like a Post (e.g. "Hello World") */
$view_all_text = $object_title ? sprintf( esc_html__( 'View all activity for "%s"', 'stream' ), esc_attr( $object_title ) ) : esc_html__( 'View all activity for this object', 'stream' );
--- a/stream/classes/class-list-table.php
+++ b/stream/classes/class-list-table.php
@@ -327,11 +327,19 @@
public function column_default( $item, $column_name ) {
$out = $this->column_renderer->render( $item, $column_name );
- $allowed_tags = wp_kses_allowed_html( 'post' );
- $allowed_tags['time'] = array(
- 'datetime' => true,
- 'class' => true,
- );
+ $allowed_tags = wp_kses_allowed_html( 'post' );
+
+ // The date column is the only cell that emits a timestamp element.
+ // WordPress already allows time in the post context, so other columns drop it.
+ if ( 'date' === $column_name ) {
+ $allowed_tags['time'] = array(
+ 'datetime' => true,
+ 'class' => true,
+ );
+ } else {
+ unset( $allowed_tags['time'] );
+ }
+
$allowed_tags['img']['srcset'] = true;
echo wp_kses( $out, $allowed_tags );
--- a/stream/classes/class-plugin.php
+++ b/stream/classes/class-plugin.php
@@ -20,7 +20,7 @@
*
* @const string
*/
- const VERSION = '4.5.0';
+ const VERSION = '4.5.1';
/**
* WP-CLI command
--- a/stream/connectors/class-connector-buddypress.php
+++ b/stream/connectors/class-connector-buddypress.php
@@ -57,6 +57,7 @@
'groups_unban_member',
'groups_remove_member',
+ 'xprofile_field_before_save',
'xprofile_field_after_save',
'xprofile_fields_deleted_field',
@@ -98,6 +99,16 @@
public bool $ignore_activity_bulk_deletion = false;
/**
+ * Profile fields that had no ID before save, keyed by object ID.
+ *
+ * BuddyPress assigns the ID before xprofile_field_after_save, so the
+ * before-save hook is what distinguishes a new field from an update.
+ *
+ * @var array<int, bool>
+ */
+ private array $new_profile_fields = array();
+
+ /**
* Check if plugin dependencies are satisfied and add an admin notice if not
*
* @return bool
@@ -471,7 +482,7 @@
$options[ $field_key ] = $field_value;
}
- $components = bp_core_admin_get_components();
+ $components = $this->get_bp_components();
$actions = array(
true => esc_html__( 'activated', 'stream' ),
@@ -709,10 +720,10 @@
/**
* Logs group actions
*
- * @param int|object $group Group object or group ID.
- * @param string $action Action.
- * @param array $meta Meta data.
- * @param string $message Message.
+ * @param int|object $group Group object or group ID.
+ * @param string $action Action.
+ * @param array $meta Meta data.
+ * @param string|null $message Summary template. Defaults to the template for $action.
*/
public function group_action( $group, $action, $meta = array(), $message = null ) {
if ( is_numeric( $group ) ) {
@@ -723,8 +734,10 @@
);
}
- $replacements = array(
- $group->name,
+ // Placeholder values come first so they line up with the summary template.
+ // id and slug stay in the record meta without shifting those placeholders.
+ $summary_args = array(
+ 'name' => (string) $group->name,
);
if ( ! $message ) {
@@ -744,34 +757,47 @@
/* translators: %s: a group name (e.g. "Favourites") */
$message = esc_html__( 'Left group "%s"', 'stream' );
} elseif ( 'banned' === $action ) {
- /* translators: %1$s: a user display name, %2$s: a group name (e.g. "Jane Doe", "Favourites") */
- $message = esc_html__( 'Banned "%2$s" from "%1$s"', 'stream' );
- $replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
+ $summary_args['user_display_name'] = (string) get_user_by( 'id', $meta['user_id'] )->display_name;
+ /* translators: %1$s: a group name, %2$s: a user display name (e.g. "Favourites", "Jane Doe") */
+ $message = esc_html__( 'Banned "%2$s" from "%1$s"', 'stream' );
} elseif ( 'unbanned' === $action ) {
- /* translators: %1$s: a user display name, %2$s: a group name (e.g. "Jane Doe", "Favourites") */
- $message = esc_html__( 'Unbanned "%2$s" from "%1$s"', 'stream' );
- $replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
+ $summary_args['user_display_name'] = (string) get_user_by( 'id', $meta['user_id'] )->display_name;
+ /* translators: %1$s: a group name, %2$s: a user display name (e.g. "Favourites", "Jane Doe") */
+ $message = esc_html__( 'Unbanned "%2$s" from "%1$s"', 'stream' );
} elseif ( 'removed' === $action ) {
- /* translators: %1$s: a user display name, %2$s: a group name (e.g. "Jane Doe", "Favourites") */
- $message = esc_html__( 'Removed "%2$s" from "%1$s"', 'stream' );
- $replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
+ $summary_args['user_display_name'] = (string) get_user_by( 'id', $meta['user_id'] )->display_name;
+ /* translators: %1$s: a group name, %2$s: a user display name (e.g. "Favourites", "Jane Doe") */
+ $message = esc_html__( 'Removed "%2$s" from "%1$s"', 'stream' );
+ } elseif ( 'promoted' === $action ) {
+ $summary_args = array(
+ 'user_display_name' => (string) $meta['user_display_name'],
+ 'role_label' => (string) $meta['role_label'],
+ 'name' => (string) $group->name,
+ );
+ /* translators: %1$s: a user's display name, %2$s: a user role, %3$s: a group name (e.g. "Jane Doe", "subscriber", "Favourites") */
+ $message = __( 'Promoted "%1$s" to "%2$s" in "%3$s"', 'stream' );
+ } elseif ( 'demoted' === $action ) {
+ $summary_args = array(
+ 'user_display_name' => (string) $meta['user_display_name'],
+ 'role_label' => (string) $meta['role_label'],
+ 'name' => (string) $group->name,
+ );
+ /* translators: %1$s: a user's display name, %2$s: a user role, %3$s: a group name (e.g. "Jane Doe", "Member", "Favourites") */
+ $message = __( 'Demoted "%1$s" to "%2$s" in "%3$s"', 'stream' );
} else {
return;
}
}
$this->log(
- vsprintf(
- $message,
- $replacements
- ),
+ $message,
array_merge(
+ $summary_args,
+ $meta,
array(
'id' => $group->id,
- 'name' => $group->name,
'slug' => $group->slug,
- ),
- $meta
+ )
),
$group->id,
'groups',
@@ -881,24 +907,27 @@
* @param string $status Member's new user role.
*/
public function callback_groups_promote_member( $group_id, $user_id, $status ) {
- $group = groups_get_group(
+ $group = groups_get_group(
array(
'group_id' => $group_id,
)
);
- $user = new WP_User( $user_id );
- $roles = array(
+ $user = new WP_User( $user_id );
+ $roles = array(
'admin' => esc_html_x( 'Administrator', 'buddypress', 'stream' ),
'mod' => esc_html_x( 'Moderator', 'buddypress', 'stream' ),
);
- $message = sprintf(
- /* translators: %1$s: a user's display name, %2$s: a user role, %3$s: a group name (e.g. "Jane Doe", "subscriber", "Favourites") */
- __( 'Promoted "%1$s" to "%2$s" in "%3$s"', 'stream' ),
- $user->display_name,
- $roles[ $status ],
- $group->name
+
+ $this->group_action(
+ $group,
+ 'promoted',
+ array(
+ 'user_id' => $user_id,
+ 'status' => $status,
+ 'user_display_name' => $user->display_name,
+ 'role_label' => $roles[ $status ],
+ )
);
- $this->group_action( $group_id, 'promoted', compact( 'user_id', 'status' ), $message );
}
/**
@@ -910,20 +939,22 @@
* @param int $user_id User ID of member.
*/
public function callback_groups_demote_member( $group_id, $user_id ) {
- $group = groups_get_group(
+ $group = groups_get_group(
array(
'group_id' => $group_id,
)
);
- $user = new WP_User( $user_id );
- $message = sprintf(
- /* translators: %1$s: a user's display name, %2$s: a user role, %3$s: a group name (e.g. "Jane Doe", "Member", "Favourites") */
- __( 'Demoted "%1$s" to "%2$s" in "%3$s"', 'stream' ),
- $user->display_name,
- _x( 'Member', 'buddypress', 'stream' ),
- $group->name
+ $user = new WP_User( $user_id );
+
+ $this->group_action(
+ $group,
+ 'demoted',
+ array(
+ 'user_id' => $user_id,
+ 'user_display_name' => $user->display_name,
+ 'role_label' => _x( 'Member', 'buddypress', 'stream' ),
+ )
);
- $this->group_action( $group_id, 'demoted', compact( 'user_id' ), $message );
}
/**
@@ -971,10 +1002,6 @@
* @param string $message Message.
*/
public function field_action( $field, $action, $meta = array(), $message = null ) {
- $replacements = array(
- $field->name,
- );
-
if ( ! $message ) {
if ( 'created' === $action ) {
/* translators: %s: a user profile field (e.g. "Job Title") */
@@ -991,14 +1018,11 @@
}
$this->log(
- vsprintf(
- $message,
- $replacements
- ),
+ $message,
array_merge(
array(
+ 'field_name' => (string) $field->name,
'field_id' => $field->id,
- 'field_name' => $field->name,
'group_id' => $field->group_id,
),
$meta
@@ -1010,6 +1034,19 @@
}
/**
+ * Remember whether a profile field is new before BuddyPress assigns its ID.
+ *
+ * @action xprofile_field_before_save
+ *
+ * @param object $field Field object.
+ */
+ public function callback_xprofile_field_before_save( $field ) {
+ $field_id = isset( $field->id ) ? $field->id : null;
+
+ $this->new_profile_fields[ spl_object_id( $field ) ] = is_null( $field_id );
+ }
+
+ /**
* Logs field writes
*
* @action xprofile_field_after_save
@@ -1017,7 +1054,11 @@
* @param object $field Field object.
*/
public function callback_xprofile_field_after_save( $field ) {
- $action = isset( $field->id ) ? 'updated' : 'created';
+ $key = spl_object_id( $field );
+ $action = ! empty( $this->new_profile_fields[ $key ] ) ? 'created' : 'updated';
+
+ unset( $this->new_profile_fields[ $key ] );
+
$this->field_action( $field, $action );
}
@@ -1041,10 +1082,6 @@
* @param string $message Message.
*/
public function field_group_action( $group, $action, $meta = array(), $message = null ) {
- $replacements = array(
- $group->name,
- );
-
if ( ! $message ) {
if ( 'created' === $action ) {
/* translators: %s: a user profile field group (e.g. "Appearance") */
@@ -1061,14 +1098,11 @@
}
$this->log(
- vsprintf(
- $message,
- $replacements
- ),
+ $message,
array_merge(
array(
+ 'group_name' => (string) $group->name,
'group_id' => $group->id,
- 'group_name' => $group->name,
),
$meta
),
@@ -1107,6 +1141,26 @@
}
/**
+ * Component titles for the active-components log.
+ *
+ * BuddyPress only loads bp_core_admin_get_components() in wp-admin. The
+ * same titles are available from bp_core_get_components() everywhere else.
+ *
+ * @return array
+ */
+ private function get_bp_components() {
+ if ( function_exists( 'bp_core_admin_get_components' ) ) {
+ return bp_core_admin_get_components();
+ }
+
+ if ( function_exists( 'bp_core_get_components' ) ) {
+ return bp_core_get_components();
+ }
+
+ return array();
+ }
+
+ /**
* Returns the directory pages
*
* @return array
--- a/stream/stream.php
+++ b/stream/stream.php
@@ -3,7 +3,7 @@
* Plugin Name: Stream - Activity Log & Audit Trail
* Plugin URI: https://xwp.co/work/stream/
* Description: Stream is an activity log and audit trail for WordPress — track every change made on your site in beautifully organized detail. All activity is organized by context, action and IP address for easy filtering. Developers can extend Stream with custom connectors to log any kind of action.
- * Version: 4.5.0
+ * Version: 4.5.1
* Requires PHP: 7.4
* Author: XWP
* Author URI: https://xwp.co
--- a/stream/vendor/composer/installed.php
+++ b/stream/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'xwp/stream',
- 'pretty_version' => 'v4.5.0',
- 'version' => '4.5.0.0',
- 'reference' => '72db0d40817109473f157c1e2788f4e8cb6bc6ea',
+ 'pretty_version' => 'v4.5.1',
+ 'version' => '4.5.1.0',
+ 'reference' => '1ab57b6d4a1d5e3c5cc1e0ec72fe100a4007d209',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -29,9 +29,9 @@
'dev_requirement' => false,
),
'xwp/stream' => array(
- 'pretty_version' => 'v4.5.0',
- 'version' => '4.5.0.0',
- 'reference' => '72db0d40817109473f157c1e2788f4e8cb6bc6ea',
+ 'pretty_version' => 'v4.5.1',
+ 'version' => '4.5.1.0',
+ 'reference' => '1ab57b6d4a1d5e3c5cc1e0ec72fe100a4007d209',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),