sanitize user_login

This commit is contained in:
Matthias Pfefferle 2023-09-11 11:33:31 +02:00
parent 8a74aa5891
commit 5fbf931d41
3 changed files with 8 additions and 6 deletions

View file

@ -1,5 +1,5 @@
# ActivityPub # # ActivityPub #
**Contributors:** [automattic](https://profiles.wordpress.org/automattic/), [pfefferle](https://profiles.wordpress.org/pfefferle/), [mediaformat](https://profiles.wordpress.org/mediaformat/), [mattwiebe](https://profiles.wordpress.org/mattwiebe/), [akirk](https://profiles.wordpress.org/akirk/), [jeherve](https://profiles.wordpress.org/jeherve/), [nuriapena](https://profiles.wordpress.org/nuriapena/) **Contributors:** [automattic](https://profiles.wordpress.org/automattic/), [pfefferle](https://profiles.wordpress.org/pfefferle/), [mediaformat](https://profiles.wordpress.org/mediaformat/), [mattwiebe](https://profiles.wordpress.org/mattwiebe/), [akirk](https://profiles.wordpress.org/akirk/), [jeherve](https://profiles.wordpress.org/jeherve/), [nuriapena](https://profiles.wordpress.org/nuriapena/), [cavalierlife](https://profiles.wordpress.org/cavalierlife/)
**Tags:** OStatus, fediverse, activitypub, activitystream **Tags:** OStatus, fediverse, activitypub, activitystream
**Requires at least:** 4.7 **Requires at least:** 4.7
**Tested up to:** 6.3 **Tested up to:** 6.3

View file

@ -121,17 +121,19 @@ class Signature {
} }
/** /**
* Undocumented function * Return the option key for a given user.
* *
* @param [type] $user_id * @param int $user_id The WordPress User ID.
* @return void *
* @return string The option key.
*/ */
protected static function get_signature_options_key_for( $user_id ) { protected static function get_signature_options_key_for( $user_id ) {
$id = $user_id; $id = $user_id;
if ( $user_id > 0 ) { if ( $user_id > 0 ) {
$user = \get_userdata( $user_id ); $user = \get_userdata( $user_id );
$id = $user->user_login; // sanatize username because it could include spaces and special chars
$id = sanitize_title( $user->user_login );
} }
return 'activitypub_keypair_for_' . $id; return 'activitypub_keypair_for_' . $id;

View file

@ -1,5 +1,5 @@
=== ActivityPub === === ActivityPub ===
Contributors: automattic, pfefferle, mediaformat, mattwiebe, akirk, jeherve, nuriapena Contributors: automattic, pfefferle, mediaformat, mattwiebe, akirk, jeherve, nuriapena, cavalierlife
Tags: OStatus, fediverse, activitypub, activitystream Tags: OStatus, fediverse, activitypub, activitystream
Requires at least: 4.7 Requires at least: 4.7
Tested up to: 6.3 Tested up to: 6.3