{"issue":{"created_at":"2011-09-07T19:20:28Z","state":"open","updated_at":"2011-11-28T00:15:38Z","comments":2,"user":{"gravatar_id":"eb4ffc850ae4f13e7e5602b53fe49772","id":9061,"url":"https://api.github.com/users/nicholaides","login":"nicholaides","avatar_url":"https://secure.gravatar.com/avatar/eb4ffc850ae4f13e7e5602b53fe49772?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"In HTML emails `links_in_email` will include the URIs specified in the Doctype URI, any HTML namespace tags.\r\n\r\ne.g.\r\n\r\n```html\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\r\n```\r\n\r\nThis breaks `click_first_link_in_email` for HTML emails because the first link is http://www.w3.org/TR/html4/loose.dtd in this example.\r\n\r\nI patched my version to this hacky solulution:\r\n\r\n```ruby\r\ndef links_in_email(email)\r\n  URI.extract(email.default_part_body.to_s, ['http', 'https']).reject do |link|\r\n    ['www.w3.org', 'www.openmobilealliance.org'].include? URI.parse(link).host\r\n  end\r\nend\r\n```\r\n\r\nAn ideal solution would probably use Nokogiri to get the links from all the `<a href=...>` elements","assignee":null,"id":1592526,"number":72,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"title":"links_in_email includes doctype uri and namespace","closed_at":null,"html_url":"https://github.com/bmabey/email-spec/issues/72","milestone":null,"url":"https://api.github.com/repos/bmabey/email-spec/issues/72"},"action":"created","comment":{"created_at":"2011-11-28T00:15:38Z","updated_at":"2011-11-28T00:15:38Z","user":{"gravatar_id":"43b39b50295b675199c4d037321619ae","id":93362,"url":"https://api.github.com/users/iblue","login":"iblue","avatar_url":"https://secure.gravatar.com/avatar/43b39b50295b675199c4d037321619ae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"`URI.extract` also does not work for URIs in single quotes (which are generated when using HAML).\r\n\r\n```ruby\r\nURI.extract(\"<a href=3D'http://example.org/'>Click me.</a>\") # => [\"http://example.org/'\"]\r\n```\r\n\r\nUsing @nicholaides solution would require Nokogiri, so I would suggest using some simple regular expressions instead.","id":2891307,"url":"https://api.github.com/repos/bmabey/email-spec/issues/comments/2891307"}}