Skip to content

Commit

Permalink
begone fould namespaces! testing a fix for issue #120
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmunro committed Nov 15, 2018
1 parent 483812c commit b63d02a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions modules/carddav_contacts/hm-carddav.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class Hm_Carddav {
private $pass;
private $principal_url;
private $address_url;
private $principal_path = '//a:response/a:propstat/a:prop/a:current-user-principal/a:href';
private $addressbook_path = '//a:response/a:propstat/a:prop/CR:addressbook-home-set/a:href';
private $addr_list_path = '//a:response/a:href';
private $addr_detail_path = '//a:response/a:propstat/a:prop/CR:address-data';
private $principal_path = '//response/propstat/prop/current-user-principal/href';
private $addressbook_path = '//response/propstat/prop/addressbook-home-set/href';
private $addr_list_path = '//response/href';
private $addr_detail_path = '//response/propstat/prop/address-data';

public function __construct($src, $url, $user, $pass) {
$this->user = $user;
Expand Down Expand Up @@ -116,6 +116,9 @@ private function discover() {
}

private function parse_xml($xml) {
$xml = preg_replace("/<[a-zA-Z]+:/Um", "<", $xml);
$xml = preg_replace("/<\/[a-zA-Z]+:/Um", "</", $xml);
$xml = str_replace('xmlns=', 'ns=', $xml);
try {
$data = new SimpleXMLElement($xml);
return $data;
Expand All @@ -132,12 +135,6 @@ private function xml_find($xml, $path, $multi=false) {
if (!$data) {
return false;
}
foreach ($data->getDocNamespaces() as $pre => $ns) {
if (!$pre) {
$pre = 'a';
}
$data->registerXPathNamespace($pre, $ns);
}
$res = array();
foreach ($data->xpath($path) as $node) {
if (!$multi) {
Expand Down

0 comments on commit b63d02a

Please sign in to comment.