Problem/Motivation
In hybridauth_username_alter() we replace user name with values from hybridauth.
But in documentation for format_username():
* @return
* An unsanitized string with the username to display. The code receiving
* this result must ensure that check_plain() is called on it before it is
* printed to the page.
We should not sanitized user name in hybridauth_username_alter().
Example:
On user edit page

firstName: Shaquille
lastName: O'Neal
# displayed value
<title>Shaquille O&#039;Neal | Sitename</title>
# expected displayed value
<title>Shaquille O'Neal | Sitename</title>
Proposed resolution
Disable sanitize for token_replace().
I am not sure if we also should remove strip_tags(), will leave it as is.
$name = trim(strip_tags($hybridauth_name));
Result:

Comments
Comment #2
nikolay shapovalov commentedPatch attached.
Comment #3
klausiThank you! Yes, this absolutely makes sense to prevent double escaping.
Comment #5
duozerskNikolay, Klaus,
Thank you for the contribution. Committed to 7.x-2.x.
AndyB