Skip to content

Fix non-ASCII display names producing broken usernames#585

Merged
akirk merged 1 commit intomainfrom
fix-cyrillic-username-handling
Feb 6, 2026
Merged

Fix non-ASCII display names producing broken usernames#585
akirk merged 1 commit intomainfrom
fix-cyrillic-username-handling

Conversation

@akirk
Copy link
Copy Markdown
Owner

@akirk akirk commented Feb 6, 2026

Summary

  • Fixed update_feed_details() using the ActivityPub name (display name) for suggested-username instead of preferredUsername (the actual handle)
  • Display names with emojis (DCoder 🇱🇹❤🇺🇦), Cyrillic (РосКомСвобода), or special characters (D:\side\>:idle:) would get stripped by sanitize_username(), producing empty or unusable WordPress usernames
  • preferredUsername is always ASCII-safe on Mastodon/Fediverse, so it produces clean usernames like dcoder.mastodon.social
  • If preferredUsername is not available, no suggested-username is set, falling back to the URL-based username which is always ASCII-safe

Test plan

  • Added tests in test-activitypub.php that call update_feed_details() with emoji, Cyrillic, and special character display names and verify suggested-username is derived from preferredUsername
  • Added unit tests in test-friend-user.php for sanitize_username() edge cases
  • Manually test adding a Mastodon user with a non-ASCII display name

Testing

https://playground.wordpress.net/#{%22steps%22:[{%22step%22:%22installPlugin%22,%22pluginData%22:{%22resource%22:%22git:directory%22,%22url%22:%22https://github.com/akirk/friends%22,%22ref%22:%22fix-cyrillic-username-handling%22,%22refType%22:%22branch%22},%22options%22:{%22activate%22:true}}]}

…ed-username

The suggested-username was derived from the ActivityPub "name" field (display
name), which can contain emojis, Cyrillic, or other non-ASCII characters that
get stripped during sanitization, producing empty or unusable usernames.

Now uses "preferredUsername" (the actual handle, always ASCII-safe) with the
host appended for uniqueness, matching what create_friend_subscription_from_actor
already does.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

Test this PR in WordPress Playground

You can test this pull request directly in WordPress Playground:

Launch WordPress Playground

This will install and activate the plugin with the changes from this PR.

@akirk akirk merged commit 1b4f330 into main Feb 6, 2026
25 checks passed
@akirk akirk deleted the fix-cyrillic-username-handling branch February 6, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant