MDL-76131 core_user: encode social profile fields data.

This commit is contained in:
Meirza 2022-11-08 10:57:13 +07:00 committed by Sara Arjona
parent 5548743ece
commit 8a4d06bcaa
2 changed files with 6 additions and 4 deletions

View File

@ -66,9 +66,9 @@ class helper {
*/
public static function get_network_urls(): array {
return [
'skype' => '<a href="skype:%%DATA%%?call">%%DATA%%</a>',
'icq' => '<a href="http://www.icq.com/whitepages/cmd.php?uin=%%DATA%%&action=message">%%DATA%%</a>',
'url' => '<a href="%%DATA%%">%%DATA%%</a>'
'skype' => '<a href="skype:%%ENCODED%%?call">%%PLAIN%%</a>',
'icq' => '<a href="http://www.icq.com/whitepages/cmd.php?uin=%%ENCODED%%&action=message">%%PLAIN%%</a>',
'url' => '<a href="%%PLAIN%%">%%PLAIN%%</a>'
];
}
}

View File

@ -63,7 +63,9 @@ class profile_field_social extends profile_field_base {
$networkurls = profilefield_social\helper::get_network_urls();
if (array_key_exists($network, $networkurls)) {
return str_replace('%%DATA%%', $this->data, $networkurls[$network]);
$pattern = ['%%ENCODED%%', '%%PLAIN%%'];
$data = [rawurlencode($this->data), $this->data];
return str_replace($pattern, $data, $networkurls[$network]);
}
return $this->data;