{"action":"created","comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments/82085761","pull_request_review_id":3017770,"id":82085761,"diff_hunk":"@@ -30,4 +30,36 @@ module HTML\n       io << SUBSTITUTIONS.fetch(char, char)\n     end\n   end\n+\n+  def self.unescape(string : String)\n+    return string unless string.includes? '&'\n+    charlimit = 0x10ffff\n+\n+    string.gsub(/&(apos|amp|quot|gt|lt|\\#[0-9]+|\\#[xX][0-9A-Fa-f]+);/) do |string, _match|\n+      match = _match[1].dup\n+      case match\n+      when \"apos\" then \"'\"\n+      when \"amp\"  then \"&\"\n+      when \"quot\" then \"\\\"\"\n+      when \"gt\"   then \">\"\n+      when \"lt\"   then \"<\"\n+      when /\\A#0*(\\d+)\\z/\n+        n = $1.to_i\n+        if n < charlimit\n+          n.unsafe_chr\n+        else\n+          \"&##{$1};\"\n+        end\n+      when /\\A#x([0-9a-f]+)\\z/i\n+        n = $1.to_i(16)\n+        if n < charlimit","path":"src/html.cr","position":26,"original_position":26,"commit_id":"3877c73cb5041b142ea53315f01aa1e7aff91df1","original_commit_id":"3877c73cb5041b142ea53315f01aa1e7aff91df1","user":{"login":"asterite","id":209371,"avatar_url":"https://avatars.githubusercontent.com/u/209371?v=3","gravatar_id":"","url":"https://api.github.com/users/asterite","html_url":"https://github.com/asterite","followers_url":"https://api.github.com/users/asterite/followers","following_url":"https://api.github.com/users/asterite/following{/other_user}","gists_url":"https://api.github.com/users/asterite/gists{/gist_id}","starred_url":"https://api.github.com/users/asterite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterite/subscriptions","organizations_url":"https://api.github.com/users/asterite/orgs","repos_url":"https://api.github.com/users/asterite/repos","events_url":"https://api.github.com/users/asterite/events{/privacy}","received_events_url":"https://api.github.com/users/asterite/received_events","type":"User","site_admin":false},"body":"I think this should be `n <= charlimit`, since `0x10ffff` is a valid unicode value","created_at":"2016-10-05T22:35:34Z","updated_at":"2016-10-05T22:35:34Z","html_url":"https://github.com/crystal-lang/crystal/pull/3374#discussion_r82085761","pull_request_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/3374","_links":{"self":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments/82085761"},"html":{"href":"https://github.com/crystal-lang/crystal/pull/3374#discussion_r82085761"},"pull_request":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/3374"}}},"pull_request":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/3374","id":87653789,"html_url":"https://github.com/crystal-lang/crystal/pull/3374","diff_url":"https://github.com/crystal-lang/crystal/pull/3374.diff","patch_url":"https://github.com/crystal-lang/crystal/pull/3374.patch","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3374","number":3374,"state":"open","locked":false,"title":"Add HTML.unescape [Closes #3107]","user":{"login":"dukex","id":91538,"avatar_url":"https://avatars.githubusercontent.com/u/91538?v=3","gravatar_id":"","url":"https://api.github.com/users/dukex","html_url":"https://github.com/dukex","followers_url":"https://api.github.com/users/dukex/followers","following_url":"https://api.github.com/users/dukex/following{/other_user}","gists_url":"https://api.github.com/users/dukex/gists{/gist_id}","starred_url":"https://api.github.com/users/dukex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dukex/subscriptions","organizations_url":"https://api.github.com/users/dukex/orgs","repos_url":"https://api.github.com/users/dukex/repos","events_url":"https://api.github.com/users/dukex/events{/privacy}","received_events_url":"https://api.github.com/users/dukex/received_events","type":"User","site_admin":false},"body":"Given the ruby implementation [CGI::unescapeHTML](https://github.com/ruby/ruby/blob/94dc3e71bb4782b68d49e463242d348b90ad9dca/lib/cgi/util.rb#L61-L115) and the comments on https://github.com/crystal-lang/crystal/pull/3226 I'm made this implementation of `HTML.unescape`. \r\n\r\n~~I tried to translate the unescape for hexadecimal codes without success~~\r\n~~Someone can help me?~~ Thanks @chaniks ","created_at":"2016-10-03T01:13:13Z","updated_at":"2016-10-05T22:35:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9698f3d6c1918ffd0ddd39601b57d6fda4d558d1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/3374/commits","review_comments_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/3374/comments","review_comment_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3374/comments","statuses_url":"https://api.github.com/repos/crystal-lang/crystal/statuses/3877c73cb5041b142ea53315f01aa1e7aff91df1","head":{"label":"dukex:add-html-unescape","ref":"add-html-unescape","sha":"3877c73cb5041b142ea53315f01aa1e7aff91df1","user":{"login":"dukex","id":91538,"avatar_url":"https://avatars.githubusercontent.com/u/91538?v=3","gravatar_id":"","url":"https://api.github.com/users/dukex","html_url":"https://github.com/dukex","followers_url":"https://api.github.com/users/dukex/followers","following_url":"https://api.github.com/users/dukex/following{/other_user}","gists_url":"https://api.github.com/users/dukex/gists{/gist_id}","starred_url":"https://api.github.com/users/dukex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dukex/subscriptions","organizations_url":"https://api.github.com/users/dukex/orgs","repos_url":"https://api.github.com/users/dukex/repos","events_url":"https://api.github.com/users/dukex/events{/privacy}","received_events_url":"https://api.github.com/users/dukex/received_events","type":"User","site_admin":false},"repo":{"id":69817417,"name":"crystal","full_name":"dukex/crystal","owner":{"login":"dukex","id":91538,"avatar_url":"https://avatars.githubusercontent.com/u/91538?v=3","gravatar_id":"","url":"https://api.github.com/users/dukex","html_url":"https://github.com/dukex","followers_url":"https://api.github.com/users/dukex/followers","following_url":"https://api.github.com/users/dukex/following{/other_user}","gists_url":"https://api.github.com/users/dukex/gists{/gist_id}","starred_url":"https://api.github.com/users/dukex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dukex/subscriptions","organizations_url":"https://api.github.com/users/dukex/orgs","repos_url":"https://api.github.com/users/dukex/repos","events_url":"https://api.github.com/users/dukex/events{/privacy}","received_events_url":"https://api.github.com/users/dukex/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dukex/crystal","description":"The Crystal Programming Language","fork":true,"url":"https://api.github.com/repos/dukex/crystal","forks_url":"https://api.github.com/repos/dukex/crystal/forks","keys_url":"https://api.github.com/repos/dukex/crystal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dukex/crystal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dukex/crystal/teams","hooks_url":"https://api.github.com/repos/dukex/crystal/hooks","issue_events_url":"https://api.github.com/repos/dukex/crystal/issues/events{/number}","events_url":"https://api.github.com/repos/dukex/crystal/events","assignees_url":"https://api.github.com/repos/dukex/crystal/assignees{/user}","branches_url":"https://api.github.com/repos/dukex/crystal/branches{/branch}","tags_url":"https://api.github.com/repos/dukex/crystal/tags","blobs_url":"https://api.github.com/repos/dukex/crystal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dukex/crystal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dukex/crystal/git/refs{/sha}","trees_url":"https://api.github.com/repos/dukex/crystal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dukex/crystal/statuses/{sha}","languages_url":"https://api.github.com/repos/dukex/crystal/languages","stargazers_url":"https://api.github.com/repos/dukex/crystal/stargazers","contributors_url":"https://api.github.com/repos/dukex/crystal/contributors","subscribers_url":"https://api.github.com/repos/dukex/crystal/subscribers","subscription_url":"https://api.github.com/repos/dukex/crystal/subscription","commits_url":"https://api.github.com/repos/dukex/crystal/commits{/sha}","git_commits_url":"https://api.github.com/repos/dukex/crystal/git/commits{/sha}","comments_url":"https://api.github.com/repos/dukex/crystal/comments{/number}","issue_comment_url":"https://api.github.com/repos/dukex/crystal/issues/comments{/number}","contents_url":"https://api.github.com/repos/dukex/crystal/contents/{+path}","compare_url":"https://api.github.com/repos/dukex/crystal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dukex/crystal/merges","archive_url":"https://api.github.com/repos/dukex/crystal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dukex/crystal/downloads","issues_url":"https://api.github.com/repos/dukex/crystal/issues{/number}","pulls_url":"https://api.github.com/repos/dukex/crystal/pulls{/number}","milestones_url":"https://api.github.com/repos/dukex/crystal/milestones{/number}","notifications_url":"https://api.github.com/repos/dukex/crystal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dukex/crystal/labels{/name}","releases_url":"https://api.github.com/repos/dukex/crystal/releases{/id}","deployments_url":"https://api.github.com/repos/dukex/crystal/deployments","created_at":"2016-10-02T19:31:14Z","updated_at":"2016-10-02T19:31:19Z","pushed_at":"2016-10-04T14:35:04Z","git_url":"git://github.com/dukex/crystal.git","ssh_url":"git@github.com:dukex/crystal.git","clone_url":"https://github.com/dukex/crystal.git","svn_url":"https://github.com/dukex/crystal","homepage":"http://crystal-lang.org","size":31834,"stargazers_count":0,"watchers_count":0,"language":"Crystal","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"crystal-lang:master","ref":"master","sha":"ab966522ee03152e701f2d90f53a740a00e877d7","user":{"login":"crystal-lang","id":6539796,"avatar_url":"https://avatars.githubusercontent.com/u/6539796?v=3","gravatar_id":"","url":"https://api.github.com/users/crystal-lang","html_url":"https://github.com/crystal-lang","followers_url":"https://api.github.com/users/crystal-lang/followers","following_url":"https://api.github.com/users/crystal-lang/following{/other_user}","gists_url":"https://api.github.com/users/crystal-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/crystal-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crystal-lang/subscriptions","organizations_url":"https://api.github.com/users/crystal-lang/orgs","repos_url":"https://api.github.com/users/crystal-lang/repos","events_url":"https://api.github.com/users/crystal-lang/events{/privacy}","received_events_url":"https://api.github.com/users/crystal-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":6887813,"name":"crystal","full_name":"crystal-lang/crystal","owner":{"login":"crystal-lang","id":6539796,"avatar_url":"https://avatars.githubusercontent.com/u/6539796?v=3","gravatar_id":"","url":"https://api.github.com/users/crystal-lang","html_url":"https://github.com/crystal-lang","followers_url":"https://api.github.com/users/crystal-lang/followers","following_url":"https://api.github.com/users/crystal-lang/following{/other_user}","gists_url":"https://api.github.com/users/crystal-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/crystal-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crystal-lang/subscriptions","organizations_url":"https://api.github.com/users/crystal-lang/orgs","repos_url":"https://api.github.com/users/crystal-lang/repos","events_url":"https://api.github.com/users/crystal-lang/events{/privacy}","received_events_url":"https://api.github.com/users/crystal-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crystal-lang/crystal","description":"The Crystal Programming Language","fork":false,"url":"https://api.github.com/repos/crystal-lang/crystal","forks_url":"https://api.github.com/repos/crystal-lang/crystal/forks","keys_url":"https://api.github.com/repos/crystal-lang/crystal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crystal-lang/crystal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crystal-lang/crystal/teams","hooks_url":"https://api.github.com/repos/crystal-lang/crystal/hooks","issue_events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/events{/number}","events_url":"https://api.github.com/repos/crystal-lang/crystal/events","assignees_url":"https://api.github.com/repos/crystal-lang/crystal/assignees{/user}","branches_url":"https://api.github.com/repos/crystal-lang/crystal/branches{/branch}","tags_url":"https://api.github.com/repos/crystal-lang/crystal/tags","blobs_url":"https://api.github.com/repos/crystal-lang/crystal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crystal-lang/crystal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crystal-lang/crystal/git/refs{/sha}","trees_url":"https://api.github.com/repos/crystal-lang/crystal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crystal-lang/crystal/statuses/{sha}","languages_url":"https://api.github.com/repos/crystal-lang/crystal/languages","stargazers_url":"https://api.github.com/repos/crystal-lang/crystal/stargazers","contributors_url":"https://api.github.com/repos/crystal-lang/crystal/contributors","subscribers_url":"https://api.github.com/repos/crystal-lang/crystal/subscribers","subscription_url":"https://api.github.com/repos/crystal-lang/crystal/subscription","commits_url":"https://api.github.com/repos/crystal-lang/crystal/commits{/sha}","git_commits_url":"https://api.github.com/repos/crystal-lang/crystal/git/commits{/sha}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/comments{/number}","issue_comment_url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments{/number}","contents_url":"https://api.github.com/repos/crystal-lang/crystal/contents/{+path}","compare_url":"https://api.github.com/repos/crystal-lang/crystal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crystal-lang/crystal/merges","archive_url":"https://api.github.com/repos/crystal-lang/crystal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crystal-lang/crystal/downloads","issues_url":"https://api.github.com/repos/crystal-lang/crystal/issues{/number}","pulls_url":"https://api.github.com/repos/crystal-lang/crystal/pulls{/number}","milestones_url":"https://api.github.com/repos/crystal-lang/crystal/milestones{/number}","notifications_url":"https://api.github.com/repos/crystal-lang/crystal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crystal-lang/crystal/labels{/name}","releases_url":"https://api.github.com/repos/crystal-lang/crystal/releases{/id}","deployments_url":"https://api.github.com/repos/crystal-lang/crystal/deployments","created_at":"2012-11-27T17:32:32Z","updated_at":"2016-10-05T20:34:31Z","pushed_at":"2016-10-05T20:29:34Z","git_url":"git://github.com/crystal-lang/crystal.git","ssh_url":"git@github.com:crystal-lang/crystal.git","clone_url":"https://github.com/crystal-lang/crystal.git","svn_url":"https://github.com/crystal-lang/crystal","homepage":"http://crystal-lang.org","size":67059,"stargazers_count":6235,"watchers_count":6235,"language":"Crystal","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":503,"mirror_url":null,"open_issues_count":334,"forks":503,"open_issues":334,"watchers":6235,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/3374"},"html":{"href":"https://github.com/crystal-lang/crystal/pull/3374"},"issue":{"href":"https://api.github.com/repos/crystal-lang/crystal/issues/3374"},"comments":{"href":"https://api.github.com/repos/crystal-lang/crystal/issues/3374/comments"},"review_comments":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/3374/comments"},"review_comment":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/3374/commits"},"statuses":{"href":"https://api.github.com/repos/crystal-lang/crystal/statuses/3877c73cb5041b142ea53315f01aa1e7aff91df1"}}}}
{"actor":{"display_login":"asterite"}}