API: use regex instead of SimpleXMLElement

It's easier with exotic chars.
And the editor replaced all leading spaces with tabs.
This commit is contained in:
fabrixxm 2016-07-14 13:32:31 +02:00
parent ce2f765d28
commit 18bd7f5eb7

View file

@ -2294,11 +2294,20 @@
* 'url => 'url'
*/
function api_contactlink_to_array($txt) {
$elm = new SimpleXMLElement($txt);
return array(
'name' => $elm->__toString(),
'url' => $elm->attributes()['href']->__toString()
$match = array();
$r = preg_match_all('|<a href="([^"]*)">([^<]*)</a>|', $txt, $match);
if ($r && count($match)==3) {
$res = array(
'name' => $match[2],
'url' => $match[1]
);
} else {
$res = array(
'name' => $text,
'url' => ""
);
}
return $res;
}