Skip to content

Commit

Permalink
sanitize user_login
Browse files Browse the repository at this point in the history
  • Loading branch information
pfefferle committed Sep 11, 2023
1 parent 8a74aa5 commit 5fbf931
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 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
**Requires at least:** 4.7
**Tested up to:** 6.3
Expand Down
10 changes: 6 additions & 4 deletions includes/class-signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,19 @@ protected static function generate_key_pair_for( $user_id ) {
}

/**
* Undocumented function
* Return the option key for a given user.
*
* @param [type] $user_id
* @return void
* @param int $user_id The WordPress User ID.
*
* @return string The option key.
*/
protected static function get_signature_options_key_for( $user_id ) {
$id = $user_id;

if ( $user_id > 0 ) {
$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;
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=== ActivityPub ===
Contributors: automattic, pfefferle, mediaformat, mattwiebe, akirk, jeherve, nuriapena
Contributors: automattic, pfefferle, mediaformat, mattwiebe, akirk, jeherve, nuriapena, cavalierlife
Tags: OStatus, fediverse, activitypub, activitystream
Requires at least: 4.7
Tested up to: 6.3
Expand Down

0 comments on commit 5fbf931

Please sign in to comment.