{"action":"created","issue":{"url":"https://api.github.com/repos/TAXIIProject/libtaxii/issues/170","labels_url":"https://api.github.com/repos/TAXIIProject/libtaxii/issues/170/labels{/name}","comments_url":"https://api.github.com/repos/TAXIIProject/libtaxii/issues/170/comments","events_url":"https://api.github.com/repos/TAXIIProject/libtaxii/issues/170/events","html_url":"https://github.com/TAXIIProject/libtaxii/issues/170","id":57147281,"number":170,"title":"StartTag: invalid element name","user":{"login":"c-x","id":1864136,"avatar_url":"https://avatars.githubusercontent.com/u/1864136?v=3","gravatar_id":"","url":"https://api.github.com/users/c-x","html_url":"https://github.com/c-x","followers_url":"https://api.github.com/users/c-x/followers","following_url":"https://api.github.com/users/c-x/following{/other_user}","gists_url":"https://api.github.com/users/c-x/gists{/gist_id}","starred_url":"https://api.github.com/users/c-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-x/subscriptions","organizations_url":"https://api.github.com/users/c-x/orgs","repos_url":"https://api.github.com/users/c-x/repos","events_url":"https://api.github.com/users/c-x/events{/privacy}","received_events_url":"https://api.github.com/users/c-x/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-02-10T09:02:49Z","updated_at":"2015-02-12T15:21:59Z","closed_at":"2015-02-12T14:05:59Z","body":"Hello,\r\n\r\nI have the following error with libtaxii-1.1.104 (when receiving content from Soltra).\r\n\r\n```\r\nStartTag: invalid element name, line 555, column 2\r\n```\r\n\r\nThis error is caught when libtaxii process a addinfourl like the following.\r\n```\r\n<addinfourl at 140659822923856 whose fp = <socket._fileobject object at 0x7fedead42ed0>>\r\n```\r\n\r\nMy piece of code that fails is the following:\r\n```\r\ntry:\r\n\t\t# the connection to the TAXII server works correctly\r\n\t\ttaxii_client = get_taxii_connection(taxii_login, taxii_password, taxii_cert_pem, taxii_cert_key, taxii_use_https)\r\n\r\n\t\tpoll_req = tm.PollRequest(\r\n\t\t\t\tmessage_id = tm.generate_message_id(), \r\n\t\t\t\tcollection_name = taxii_feed_id,\r\n\t\t\t\texclusive_begin_timestamp_label = timestamp_label,\r\n\t\t\t\tpoll_parameters = tm.PollRequest.PollParameters()\r\n\t\t)\r\n\r\n\t\tresp = taxii_client.callTaxiiService2(taxii_host, taxii_path, t.VID_TAXII_XML_11, poll_req.to_xml(pretty_print=True), taxii_port)\r\n\r\n\t\t# When entering this method, the above error about StartTag is thrown.\r\n\t\ttaxii_message = t.get_message_from_http_response(resp, poll_req.message_id)\r\n\r\n\t\t# so this never happens\r\n\t\tprint \"Bonjour :)\"\r\nexcept Exception, e:\r\n\t\traise e\r\n```\r\n\r\n\r\nHave you seen this error before ? Is this a known issue ? Have you any idea on what's going on ? \r\n\r\nThanks.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/TAXIIProject/libtaxii/issues/comments/74088278","html_url":"https://github.com/TAXIIProject/libtaxii/issues/170#issuecomment-74088278","issue_url":"https://api.github.com/repos/TAXIIProject/libtaxii/issues/170","id":74088278,"user":{"login":"jasenj1","id":67039,"avatar_url":"https://avatars.githubusercontent.com/u/67039?v=3","gravatar_id":"","url":"https://api.github.com/users/jasenj1","html_url":"https://github.com/jasenj1","followers_url":"https://api.github.com/users/jasenj1/followers","following_url":"https://api.github.com/users/jasenj1/following{/other_user}","gists_url":"https://api.github.com/users/jasenj1/gists{/gist_id}","starred_url":"https://api.github.com/users/jasenj1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasenj1/subscriptions","organizations_url":"https://api.github.com/users/jasenj1/orgs","repos_url":"https://api.github.com/users/jasenj1/repos","events_url":"https://api.github.com/users/jasenj1/events{/privacy}","received_events_url":"https://api.github.com/users/jasenj1/received_events","type":"User","site_admin":false},"created_at":"2015-02-12T15:21:59Z","updated_at":"2015-02-12T15:21:59Z","body":"Yep. The Java-TAXII library has to do this XML string to XML tree dance to properly embed STIX. Initially I was trying to embed the XML string and it got escaped just as shown.\r\n\r\n- Jasen.\r\n\r\nFrom: MarkDavidson <notifications@github.com<mailto:notifications@github.com>>\r\nReply-To: TAXIIProject/libtaxii <reply@reply.github.com<mailto:reply@reply.github.com>>\r\nDate: Thursday, February 12, 2015 at 10:10 AM\r\nTo: TAXIIProject/libtaxii <libtaxii@noreply.github.com<mailto:libtaxii@noreply.github.com>>\r\nCc: Jasen Jacobsen <jasenj1@mitre.org<mailto:jasenj1@mitre.org>>\r\nSubject: Re: [libtaxii] StartTag: invalid element name (#170)\r\n\r\n\r\nAs an FYI, the most common cause I've seen for this is attempting to assign the Content's text value to some XML string instead of appending an XML tree. It's kind of an easy thing to get tripped up on, especially when reading XML out of a database.\r\n\r\nFor instance, using python and lxml:\r\n\r\nThe \"wrong\" way:\r\n\r\nfrom lxml import etree\r\nelt = etree.Element('name')\r\nelt.text = '<xml/>'\r\netree.tostring(elt)\r\n# '<name>&lt;xml/&gt;</name>'\r\n\r\nThe \"right\" way:\r\n\r\nfrom lxml import etree\r\nelt = etree.Element('name')\r\nelt.append(etree.XML('<xml/>'))\r\netree.tostring(elt)\r\n# '<name><xml/></name>'\r\n\r\nWhat's interesting though, at least for libtaxii, is that ContentBlock.from_xml() doesn't fail on the provided input. Perhaps there was an extra bracket ('<' or '>') in the description or observable fields that you redacted? If there is, that's a likely culprit.\r\n\r\n-Mark\r\n\r\n—\r\nReply to this email directly or view it on GitHub<https://github.com/TAXIIProject/libtaxii/issues/170#issuecomment-74086029>.\r\n"}}