diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 299dacd91d6..7454923f94a 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3012,8 +3012,16 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor
}
} else {
if (!empty($dictsocialnetworks[$type]['url'])) {
+ $tmpvirginurl = preg_replace('/\/?{socialid}/', '', $dictsocialnetworks[$type]['url']);
+ if ($tmpvirginurl) {
+ $value = preg_replace('/'.preg_quote($tmpvirginurl, '/').'\/?/', '', $value);
+ }
$link = str_replace('{socialid}', $value, $dictsocialnetworks[$type]['url']);
- $htmllink .= ' '.dol_escape_htmltag($value).'';
+ if (preg_match('/^https?:\/\//i', $link)) {
+ $htmllink .= ' '.dol_escape_htmltag($value).'';
+ } else {
+ $htmllink .= ' '.dol_escape_htmltag($value).'';
+ }
} else {
$htmllink .= dol_escape_htmltag($value);
}