{"action":"opened","issue":{"url":"https://api.github.com/repos/bitwalker/exirc/issues/77","repository_url":"https://api.github.com/repos/bitwalker/exirc","labels_url":"https://api.github.com/repos/bitwalker/exirc/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/bitwalker/exirc/issues/77/comments","events_url":"https://api.github.com/repos/bitwalker/exirc/issues/77/events","html_url":"https://github.com/bitwalker/exirc/issues/77","id":285141504,"number":77,"title":"no function clause matching in String.contains?/2","user":{"login":"mjaneczek","id":3797771,"avatar_url":"https://avatars3.githubusercontent.com/u/3797771?v=4","gravatar_id":"","url":"https://api.github.com/users/mjaneczek","html_url":"https://github.com/mjaneczek","followers_url":"https://api.github.com/users/mjaneczek/followers","following_url":"https://api.github.com/users/mjaneczek/following{/other_user}","gists_url":"https://api.github.com/users/mjaneczek/gists{/gist_id}","starred_url":"https://api.github.com/users/mjaneczek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjaneczek/subscriptions","organizations_url":"https://api.github.com/users/mjaneczek/orgs","repos_url":"https://api.github.com/users/mjaneczek/repos","events_url":"https://api.github.com/users/mjaneczek/events{/privacy}","received_events_url":"https://api.github.com/users/mjaneczek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-29T19:13:03Z","updated_at":"2017-12-29T19:13:03Z","closed_at":null,"author_association":"NONE","body":"Hello!\r\n\r\nThe error:\r\n```\r\n** (FunctionClauseError) no function clause matching in String.contains?/2\r\n    (elixir) lib/string.ex:1767: String.contains?({:incomplete, \"⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐\", <<226>>}, \"example\")\r\n    (exirc) lib/exirc/client.ex:721: ExIrc.Client.handle_data/2\r\n    (stdlib) gen_server.erl:601: :gen_server.try_dispatch/4\r\n    (stdlib) gen_server.erl:667: :gen_server.handle_msg/5\r\n    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3\r\n```\r\n\r\nI have investigated it a little bit and think that the problem is here:\r\n```elixir\r\n|> Enum.map(fn(s) ->\r\n  case String.valid?(s) do\r\n    true -> :unicode.characters_to_binary(s)\r\n    false -> :unicode.characters_to_binary(s, :latin1, :unicode)\r\n  end\r\nend)\r\n```\r\n\r\nhttps://github.com/bitwalker/exirc/blob/master/lib/exirc/utils.ex#L81\r\n\r\nFrom the erlang doc:\r\n\r\n```\r\ncharacters_to_binary\r\n\r\nResult = \r\n    binary() |\r\n    {error, binary(), RestData} |\r\n    {incomplete, binary(), binary()}\r\n```\r\n\r\nhttp://erlang.org/doc/man/unicode.html#characters_to_binary-1\r\n\r\nSo basically we need to handle the situation when the string is incomplete, maybe a fallback to empty string would be enough?\r\n\r\nI'm not sure about the proper solution, any ideas?\r\n\r\nThank you!"}}
{"actor":{"display_login":"mjaneczek"}}