{"action":"created","issue":{"url":"https://api.github.com/repos/lxml/lxml/issues/219","repository_url":"https://api.github.com/repos/lxml/lxml","labels_url":"https://api.github.com/repos/lxml/lxml/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/lxml/lxml/issues/219/comments","events_url":"https://api.github.com/repos/lxml/lxml/issues/219/events","html_url":"https://github.com/lxml/lxml/pull/219","id":197691882,"number":219,"title":"Fix attribute misquoting","user":{"login":"plq","id":79872,"avatar_url":"https://avatars.githubusercontent.com/u/79872?v=3","gravatar_id":"","url":"https://api.github.com/users/plq","html_url":"https://github.com/plq","followers_url":"https://api.github.com/users/plq/followers","following_url":"https://api.github.com/users/plq/following{/other_user}","gists_url":"https://api.github.com/users/plq/gists{/gist_id}","starred_url":"https://api.github.com/users/plq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plq/subscriptions","organizations_url":"https://api.github.com/users/plq/orgs","repos_url":"https://api.github.com/users/plq/repos","events_url":"https://api.github.com/users/plq/events{/privacy}","received_events_url":"https://api.github.com/users/plq/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-27T11:48:49Z","updated_at":"2016-12-27T11:49:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/lxml/lxml/pulls/219","html_url":"https://github.com/lxml/lxml/pull/219","diff_url":"https://github.com/lxml/lxml/pull/219.diff","patch_url":"https://github.com/lxml/lxml/pull/219.patch"},"body":"Behold:\r\n\r\n```\r\n>>> from lxml import html\r\n>>> from lxml.etree import htmlfile\r\n>>> from lxml.html.builder import E\r\n>>> from StringIO import StringIO\r\n>>> out = StringIO()\r\n>>> with htmlfile(out) as f:\r\n... with f.element(\"tagname\", attrib={\"attr\": '\"misquoted\"'}):\r\n... f.write(\"foo\")\r\n...\r\n>>> out.getvalue()\r\n'<tagname attr=\"\"misquoted\"\">foo</tagname>'\r\n```\r\n\r\n\r\n\r\nExpected output:\r\n\r\n```\r\n'<tagname attr=\"&quot;misquoted&quot;\">foo</tagname>'\r\n```\r\n\r\nhttps://bugs.launchpad.net/lxml/+bug/1594155\r\n\r\nNot fixed yet but we're closer than we were yesterday :)"},"comment":{"url":"https://api.github.com/repos/lxml/lxml/issues/comments/269315769","html_url":"https://github.com/lxml/lxml/pull/219#issuecomment-269315769","issue_url":"https://api.github.com/repos/lxml/lxml/issues/219","id":269315769,"user":{"login":"plq","id":79872,"avatar_url":"https://avatars.githubusercontent.com/u/79872?v=3","gravatar_id":"","url":"https://api.github.com/users/plq","html_url":"https://github.com/plq","followers_url":"https://api.github.com/users/plq/followers","following_url":"https://api.github.com/users/plq/following{/other_user}","gists_url":"https://api.github.com/users/plq/gists{/gist_id}","starred_url":"https://api.github.com/users/plq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plq/subscriptions","organizations_url":"https://api.github.com/users/plq/orgs","repos_url":"https://api.github.com/users/plq/repos","events_url":"https://api.github.com/users/plq/events{/privacy}","received_events_url":"https://api.github.com/users/plq/received_events","type":"User","site_admin":false},"created_at":"2016-12-27T11:49:13Z","updated_at":"2016-12-27T11:49:13Z","body":"So I did some research on this. This bug exists because here:\r\n\r\nhttps://github.com/lxml/lxml/blob/fb23f64abd87aa79924c9db3dab0f01f050e2cb3/src/lxml/serializer.pxi#L886\r\n\r\nthe wrong string output function is used. xmlOutputBufferWriteEscape is for writing text into tag bodies, not attribute values.\r\n\r\nI'm inclined to say that the function that we rather need to use is xmlBufAttrSerializeTxtContent, here:\r\n\r\nhttps://git.gnome.org/browse/libxml2/tree/xmlsave.c?id=229d1f93ceaa5e29a1e8455e73a7f346993d20b3#n2039\r\n\r\nAs can be seen, this is a non-trivial function so I'd be reluctant to copy it to lxml source.\r\n\r\nHowever, it takes an xmlAttrPtr, which we don't seem to have at that point in lxml source code.\r\n\r\nI'm not sure how to proceed from here. Any ideas?"}}
{"actor":{"display_login":"plq"}}