{"action":"created","issue":{"url":"https://api.github.com/repos/Kuniwak/vint/issues/248","repository_url":"https://api.github.com/repos/Kuniwak/vint","labels_url":"https://api.github.com/repos/Kuniwak/vint/issues/248/labels{/name}","comments_url":"https://api.github.com/repos/Kuniwak/vint/issues/248/comments","events_url":"https://api.github.com/repos/Kuniwak/vint/issues/248/events","html_url":"https://github.com/Kuniwak/vint/pull/248","id":271188195,"number":248,"title":"Try to fix #255, #242","user":{"login":"Kuniwak","id":1124024,"avatar_url":"https://avatars2.githubusercontent.com/u/1124024?v=4","gravatar_id":"","url":"https://api.github.com/users/Kuniwak","html_url":"https://github.com/Kuniwak","followers_url":"https://api.github.com/users/Kuniwak/followers","following_url":"https://api.github.com/users/Kuniwak/following{/other_user}","gists_url":"https://api.github.com/users/Kuniwak/gists{/gist_id}","starred_url":"https://api.github.com/users/Kuniwak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kuniwak/subscriptions","organizations_url":"https://api.github.com/users/Kuniwak/orgs","repos_url":"https://api.github.com/users/Kuniwak/repos","events_url":"https://api.github.com/users/Kuniwak/events{/privacy}","received_events_url":"https://api.github.com/users/Kuniwak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-11-04T12:22:41Z","updated_at":"2017-11-04T14:49:56Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/Kuniwak/vint/pulls/248","html_url":"https://github.com/Kuniwak/vint/pull/248","diff_url":"https://github.com/Kuniwak/vint/pull/248.diff","patch_url":"https://github.com/Kuniwak/vint/pull/248.patch"},"body":"# What is changed\r\n\r\nBefore this patch, Vint can be crashed by short scripts that including Emoji such as 💜.\r\n\r\nThe cause is Chardet that is a package for encoding detection.\r\nChardet can be confused by short scripts. For example, Chardet returned wrong encodings by the short script that is noted on #255:\r\n\r\n```console\r\n$ python2 dev_tool/show_chardet_result.py test/fixture/encodings/issue-225.vim\r\n{'confidence': 0.5658124254347925,\r\n 'encoding': 'Windows-1254', 👈 It is wrong. The correct encoding is UTF-8.\r\n 'language': 'Turkish'}\r\n```\r\n\r\nAfter this patch, Vint read `scriptencoding` and try to decode the encoding.\r\n\r\n1. If the input is empty, this encoding will be `ascii`\r\n2. Try to decode by the encoding that specified with `:scriptencoding`\r\n3. Try to decode by the encoding that detected by Chardet\r\n4. Try to decode as UTF-8 that is an encoding widely used\r\n5. Finally, Vint raises `EncodeDetectionError`\r\n\r\n```console\r\n$ python3 ./dev_tool/show_encoding.py test/fixture/encodings/issue-225.vim\r\n{'composed_strategies': ['DecodingStrategyForEmpty',\r\n                         'DecodingStrategyByScriptencoding',\r\n                         'DecodingStrategyByChardet',\r\n                         'DecodingStrategyForUTF8'],\r\n 'empty': 'false',\r\n 'scriptencoding': b'utf-8',\r\n 'selected_strategy': 'DecodingStrategyByScriptencoding',\r\n 'version': '3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) \\n'\r\n            '[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]'}\r\n```"},"comment":{"url":"https://api.github.com/repos/Kuniwak/vint/issues/comments/341902453","html_url":"https://github.com/Kuniwak/vint/pull/248#issuecomment-341902453","issue_url":"https://api.github.com/repos/Kuniwak/vint/issues/248","id":341902453,"user":{"login":"blueyed","id":9766,"avatar_url":"https://avatars1.githubusercontent.com/u/9766?v=4","gravatar_id":"","url":"https://api.github.com/users/blueyed","html_url":"https://github.com/blueyed","followers_url":"https://api.github.com/users/blueyed/followers","following_url":"https://api.github.com/users/blueyed/following{/other_user}","gists_url":"https://api.github.com/users/blueyed/gists{/gist_id}","starred_url":"https://api.github.com/users/blueyed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blueyed/subscriptions","organizations_url":"https://api.github.com/users/blueyed/orgs","repos_url":"https://api.github.com/users/blueyed/repos","events_url":"https://api.github.com/users/blueyed/events{/privacy}","received_events_url":"https://api.github.com/users/blueyed/received_events","type":"User","site_admin":false},"created_at":"2017-11-04T14:49:56Z","updated_at":"2017-11-04T14:49:56Z","author_association":"CONTRIBUTOR","body":"> I can implement the multiple scriptencoding behavior in this patch\r\n\r\nThat would make more sense to me."}}
{"actor":{"display_login":"blueyed"}}