{"action":"created","issue":{"url":"https://api.github.com/repos/blind-coder/rcmcarddav/issues/83","repository_url":"https://api.github.com/repos/blind-coder/rcmcarddav","labels_url":"https://api.github.com/repos/blind-coder/rcmcarddav/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/blind-coder/rcmcarddav/issues/83/comments","events_url":"https://api.github.com/repos/blind-coder/rcmcarddav/issues/83/events","html_url":"https://github.com/blind-coder/rcmcarddav/issues/83","id":56945182,"number":83,"title":"XML parsing errors with Baikal","user":{"login":"gregkster","id":10905215,"avatar_url":"https://avatars.githubusercontent.com/u/10905215?v=3","gravatar_id":"","url":"https://api.github.com/users/gregkster","html_url":"https://github.com/gregkster","followers_url":"https://api.github.com/users/gregkster/followers","following_url":"https://api.github.com/users/gregkster/following{/other_user}","gists_url":"https://api.github.com/users/gregkster/gists{/gist_id}","starred_url":"https://api.github.com/users/gregkster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregkster/subscriptions","organizations_url":"https://api.github.com/users/gregkster/orgs","repos_url":"https://api.github.com/users/gregkster/repos","events_url":"https://api.github.com/users/gregkster/events{/privacy}","received_events_url":"https://api.github.com/users/gregkster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-08T09:18:37Z","updated_at":"2016-05-25T16:14:44Z","closed_at":null,"body":"I am using Baikal 0.2.5.  It seems Baikal adds some space and a newline character to its XML responses.  The causes the following error:\r\n\r\n[08-Feb-2015 08:05:55 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'Unable to parse response as XML' in /home/gregk/git_repos/rcmcarddav/inc/Httpful/Handlers/XmlHandler.php:44\r\nStack trace:\r\n#0 /home/gregk/git_repos/rcmcarddav/inc/Httpful/Response.php(103): Httpful\\Handlers\\XmlHandler->parse('   ?<?xml versi...')\r\n#1 /home/gregk/git_repos/rcmcarddav/inc/Httpful/Response.php(42): Httpful\\Response->_parse('   ?<?xml versi...')\r\n#2 /home/gregk/git_repos/rcmcarddav/inc/Httpful/Request.php(229): Httpful\\Response->__construct('   ?<?xml versi...', 'HTTP/1.1 401 Un...', Object(Httpful\\Request))\r\n#3 /home/gregk/git_repos/rcmcarddav/carddav_common.php(182): Httpful\\Request->send()\r\n#4 /home/gregk/git_repos/rcmcarddav/carddav_discovery.php(123): carddav_common->cdfopen('https://localho...', Array, Array)\r\n#5 /home/gregk/git_repos/rcmcarddav/carddav_discovery.php(93): carddav_discovery->retrieve_addressbooks('/card.php/addre...', Array)\r\n#6 /home/gregk/git_repos/rcmcarddav/carddav.php(144): carddav_discovery->find_addressbooks('https://localho...', ' in /home/gregk/git_repos/rcmcarddav/inc/Httpful/Handlers/XmlHandler.php on line 44\r\n\r\nI fixed it by adding trim() in two places.\r\n--- a/carddav_common.php\r\n+++ b/carddav_common.php\r\n@@ -112,7 +112,7 @@ class carddav_common\r\n                if(!self::check_contenttype($reply['headers']['content-type'], ';(text|application)/xml;'))\r\n                        return false;\r\n\r\n-               $xml = new SimpleXMLElement($reply['body']);\r\n+               $xml = new SimpleXMLElement(trim($reply['body']));\r\n                $this->registerNamespaces($xml);\r\n                return $xml;\r\n        }\r\n\r\n--- a/inc/Httpful/Request.php\r\n+++ b/inc/Httpful/Request.php\r\n@@ -226,7 +226,8 @@ class Request\r\n\r\n         curl_close($this->_ch);\r\n\r\n-        return new Response($body, $headers, $this);\r\n+        return new Response(trim($body), $headers, $this);\r\n     }\r\n     public function sendIt()\r\n     {\r\n"},"comment":{"url":"https://api.github.com/repos/blind-coder/rcmcarddav/issues/comments/221627006","html_url":"https://github.com/blind-coder/rcmcarddav/issues/83#issuecomment-221627006","issue_url":"https://api.github.com/repos/blind-coder/rcmcarddav/issues/83","id":221627006,"user":{"login":"hcderaad","id":3189378,"avatar_url":"https://avatars.githubusercontent.com/u/3189378?v=3","gravatar_id":"","url":"https://api.github.com/users/hcderaad","html_url":"https://github.com/hcderaad","followers_url":"https://api.github.com/users/hcderaad/followers","following_url":"https://api.github.com/users/hcderaad/following{/other_user}","gists_url":"https://api.github.com/users/hcderaad/gists{/gist_id}","starred_url":"https://api.github.com/users/hcderaad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hcderaad/subscriptions","organizations_url":"https://api.github.com/users/hcderaad/orgs","repos_url":"https://api.github.com/users/hcderaad/repos","events_url":"https://api.github.com/users/hcderaad/events{/privacy}","received_events_url":"https://api.github.com/users/hcderaad/received_events","type":"User","site_admin":false},"created_at":"2016-05-25T16:14:44Z","updated_at":"2016-05-25T16:14:44Z","body":"Using rcmcard 1.0 with Baikal 0.4.4, no such issues."}}
{"actor":{"display_login":"hcderaad"}}