{"action":"created","comment":{"url":"https://api.github.com/repos/snapcore/snapd/pulls/comments/177391864","pull_request_review_id":107250836,"id":177391864,"diff_hunk":"@@ -0,0 +1,194 @@\n+// -*- Mode: Go; indent-tabs-mode: t -*-\n+\n+/*\n+ * Copyright (C) 2018 Canonical Ltd\n+ *\n+ * This program is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License version 3 as\n+ * published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ *\n+ */\n+\n+package safejson\n+\n+import (\n+\t\"fmt\"\n+\t\"strconv\"\n+\t\"unicode\"\n+\t\"unicode/utf16\"\n+\t\"unicode/utf8\"\n+\n+\t\"github.com/snapcore/snapd/strutil\"\n+)\n+\n+// String accepts any valid JSON string\n+type String struct {\n+\ts string\n+}\n+\n+func (str *String) UnmarshalJSON(in []byte) (err error) {\n+\tstr.s, err = unmarshal(in, uOpt{})\n+\treturn\n+}\n+\n+// Clean returns the string, with any control characters stripped.\n+func (str String) Clean() string {","path":"jsonutil/safejson/safejson.go","position":43,"original_position":43,"commit_id":"4972b660062df527f914a8b376e0a90c74dfc100","original_commit_id":"4972b660062df527f914a8b376e0a90c74dfc100","user":{"login":"zyga","id":784262,"avatar_url":"https://avatars0.githubusercontent.com/u/784262?v=4","gravatar_id":"","url":"https://api.github.com/users/zyga","html_url":"https://github.com/zyga","followers_url":"https://api.github.com/users/zyga/followers","following_url":"https://api.github.com/users/zyga/following{/other_user}","gists_url":"https://api.github.com/users/zyga/gists{/gist_id}","starred_url":"https://api.github.com/users/zyga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyga/subscriptions","organizations_url":"https://api.github.com/users/zyga/orgs","repos_url":"https://api.github.com/users/zyga/repos","events_url":"https://api.github.com/users/zyga/events{/privacy}","received_events_url":"https://api.github.com/users/zyga/received_events","type":"User","site_admin":false},"body":"I suggested to make this String() below, let me know if this is insane in good or bad way please.","created_at":"2018-03-27T11:31:46Z","updated_at":"2018-03-27T11:34:07Z","html_url":"https://github.com/snapcore/snapd/pull/4790#discussion_r177391864","pull_request_url":"https://api.github.com/repos/snapcore/snapd/pulls/4790","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/comments/177391864"},"html":{"href":"https://github.com/snapcore/snapd/pull/4790#discussion_r177391864"},"pull_request":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/4790"}}},"pull_request":{"url":"https://api.github.com/repos/snapcore/snapd/pulls/4790","id":173007460,"html_url":"https://github.com/snapcore/snapd/pull/4790","diff_url":"https://github.com/snapcore/snapd/pull/4790.diff","patch_url":"https://github.com/snapcore/snapd/pull/4790.patch","issue_url":"https://api.github.com/repos/snapcore/snapd/issues/4790","number":4790,"state":"open","locked":false,"title":"jsonutil/puritan: introducing puritan.String & etc","user":{"login":"chipaca","id":1543430,"avatar_url":"https://avatars1.githubusercontent.com/u/1543430?v=4","gravatar_id":"","url":"https://api.github.com/users/chipaca","html_url":"https://github.com/chipaca","followers_url":"https://api.github.com/users/chipaca/followers","following_url":"https://api.github.com/users/chipaca/following{/other_user}","gists_url":"https://api.github.com/users/chipaca/gists{/gist_id}","starred_url":"https://api.github.com/users/chipaca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chipaca/subscriptions","organizations_url":"https://api.github.com/users/chipaca/orgs","repos_url":"https://api.github.com/users/chipaca/repos","events_url":"https://api.github.com/users/chipaca/events{/privacy}","received_events_url":"https://api.github.com/users/chipaca/received_events","type":"User","site_admin":false},"body":"In some cases snapd is given a string it can't be sure is safe to print to\r\nthe user's terminal.\r\n\r\nWith this change, jsonutil will have the tools to deal with that\r\nsafely.  store/details.go and store/details_v2.go use it to decode\r\neverything the store sends.\r\n","created_at":"2018-03-05T22:37:57Z","updated_at":"2018-03-27T11:34:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e91fdf80d464544f7972d25474657821d4a7d30","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/snapcore/snapd/pulls/4790/commits","review_comments_url":"https://api.github.com/repos/snapcore/snapd/pulls/4790/comments","review_comment_url":"https://api.github.com/repos/snapcore/snapd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snapcore/snapd/issues/4790/comments","statuses_url":"https://api.github.com/repos/snapcore/snapd/statuses/4972b660062df527f914a8b376e0a90c74dfc100","head":{"label":"chipaca:puritan","ref":"puritan","sha":"4972b660062df527f914a8b376e0a90c74dfc100","user":{"login":"chipaca","id":1543430,"avatar_url":"https://avatars1.githubusercontent.com/u/1543430?v=4","gravatar_id":"","url":"https://api.github.com/users/chipaca","html_url":"https://github.com/chipaca","followers_url":"https://api.github.com/users/chipaca/followers","following_url":"https://api.github.com/users/chipaca/following{/other_user}","gists_url":"https://api.github.com/users/chipaca/gists{/gist_id}","starred_url":"https://api.github.com/users/chipaca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chipaca/subscriptions","organizations_url":"https://api.github.com/users/chipaca/orgs","repos_url":"https://api.github.com/users/chipaca/repos","events_url":"https://api.github.com/users/chipaca/events{/privacy}","received_events_url":"https://api.github.com/users/chipaca/received_events","type":"User","site_admin":false},"repo":{"id":45061368,"name":"snappy","full_name":"chipaca/snappy","owner":{"login":"chipaca","id":1543430,"avatar_url":"https://avatars1.githubusercontent.com/u/1543430?v=4","gravatar_id":"","url":"https://api.github.com/users/chipaca","html_url":"https://github.com/chipaca","followers_url":"https://api.github.com/users/chipaca/followers","following_url":"https://api.github.com/users/chipaca/following{/other_user}","gists_url":"https://api.github.com/users/chipaca/gists{/gist_id}","starred_url":"https://api.github.com/users/chipaca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chipaca/subscriptions","organizations_url":"https://api.github.com/users/chipaca/orgs","repos_url":"https://api.github.com/users/chipaca/repos","events_url":"https://api.github.com/users/chipaca/events{/privacy}","received_events_url":"https://api.github.com/users/chipaca/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chipaca/snappy","description":"Snappy is the software at the heart of Ubuntu Core.","fork":true,"url":"https://api.github.com/repos/chipaca/snappy","forks_url":"https://api.github.com/repos/chipaca/snappy/forks","keys_url":"https://api.github.com/repos/chipaca/snappy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chipaca/snappy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chipaca/snappy/teams","hooks_url":"https://api.github.com/repos/chipaca/snappy/hooks","issue_events_url":"https://api.github.com/repos/chipaca/snappy/issues/events{/number}","events_url":"https://api.github.com/repos/chipaca/snappy/events","assignees_url":"https://api.github.com/repos/chipaca/snappy/assignees{/user}","branches_url":"https://api.github.com/repos/chipaca/snappy/branches{/branch}","tags_url":"https://api.github.com/repos/chipaca/snappy/tags","blobs_url":"https://api.github.com/repos/chipaca/snappy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chipaca/snappy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chipaca/snappy/git/refs{/sha}","trees_url":"https://api.github.com/repos/chipaca/snappy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chipaca/snappy/statuses/{sha}","languages_url":"https://api.github.com/repos/chipaca/snappy/languages","stargazers_url":"https://api.github.com/repos/chipaca/snappy/stargazers","contributors_url":"https://api.github.com/repos/chipaca/snappy/contributors","subscribers_url":"https://api.github.com/repos/chipaca/snappy/subscribers","subscription_url":"https://api.github.com/repos/chipaca/snappy/subscription","commits_url":"https://api.github.com/repos/chipaca/snappy/commits{/sha}","git_commits_url":"https://api.github.com/repos/chipaca/snappy/git/commits{/sha}","comments_url":"https://api.github.com/repos/chipaca/snappy/comments{/number}","issue_comment_url":"https://api.github.com/repos/chipaca/snappy/issues/comments{/number}","contents_url":"https://api.github.com/repos/chipaca/snappy/contents/{+path}","compare_url":"https://api.github.com/repos/chipaca/snappy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chipaca/snappy/merges","archive_url":"https://api.github.com/repos/chipaca/snappy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chipaca/snappy/downloads","issues_url":"https://api.github.com/repos/chipaca/snappy/issues{/number}","pulls_url":"https://api.github.com/repos/chipaca/snappy/pulls{/number}","milestones_url":"https://api.github.com/repos/chipaca/snappy/milestones{/number}","notifications_url":"https://api.github.com/repos/chipaca/snappy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chipaca/snappy/labels{/name}","releases_url":"https://api.github.com/repos/chipaca/snappy/releases{/id}","deployments_url":"https://api.github.com/repos/chipaca/snappy/deployments","created_at":"2015-10-27T18:26:51Z","updated_at":"2018-03-23T14:13:05Z","pushed_at":"2018-03-23T17:52:50Z","git_url":"git://github.com/chipaca/snappy.git","ssh_url":"git@github.com:chipaca/snappy.git","clone_url":"https://github.com/chipaca/snappy.git","svn_url":"https://github.com/chipaca/snappy","homepage":null,"size":60983,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"snapcore:master","ref":"master","sha":"e80475a6a467ecf997847a659b76c522b011006f","user":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"repo":{"id":44672744,"name":"snapd","full_name":"snapcore/snapd","owner":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snapcore/snapd","description":"The snapd and snap tools enable systems to work with .snap files.","fork":false,"url":"https://api.github.com/repos/snapcore/snapd","forks_url":"https://api.github.com/repos/snapcore/snapd/forks","keys_url":"https://api.github.com/repos/snapcore/snapd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snapd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snapd/teams","hooks_url":"https://api.github.com/repos/snapcore/snapd/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snapd/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snapd/events","assignees_url":"https://api.github.com/repos/snapcore/snapd/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snapd/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snapd/tags","blobs_url":"https://api.github.com/repos/snapcore/snapd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snapd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snapd/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snapd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snapd/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snapd/languages","stargazers_url":"https://api.github.com/repos/snapcore/snapd/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snapd/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snapd/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snapd/subscription","commits_url":"https://api.github.com/repos/snapcore/snapd/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snapd/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snapd/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snapd/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snapd/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snapd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snapd/merges","archive_url":"https://api.github.com/repos/snapcore/snapd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snapd/downloads","issues_url":"https://api.github.com/repos/snapcore/snapd/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snapd/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snapd/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snapd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snapd/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snapd/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snapd/deployments","created_at":"2015-10-21T11:51:46Z","updated_at":"2018-03-27T10:23:48Z","pushed_at":"2018-03-27T11:28:19Z","git_url":"git://github.com/snapcore/snapd.git","ssh_url":"git@github.com:snapcore/snapd.git","clone_url":"https://github.com/snapcore/snapd.git","svn_url":"https://github.com/snapcore/snapd","homepage":"","size":61321,"stargazers_count":909,"watchers_count":909,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":228,"mirror_url":null,"archived":false,"open_issues_count":53,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":228,"open_issues":53,"watchers":909,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/4790"},"html":{"href":"https://github.com/snapcore/snapd/pull/4790"},"issue":{"href":"https://api.github.com/repos/snapcore/snapd/issues/4790"},"comments":{"href":"https://api.github.com/repos/snapcore/snapd/issues/4790/comments"},"review_comments":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/4790/comments"},"review_comment":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/4790/commits"},"statuses":{"href":"https://api.github.com/repos/snapcore/snapd/statuses/4972b660062df527f914a8b376e0a90c74dfc100"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"zyga"}}