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