{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/23379632","id":23379632,"diff_hunk":"@@ -314,6 +322,67 @@ public static String simpleClassName(Class<?> clazz) {\n         }\n     }\n \n+    /**\n+     * Escapes the specified value, if necessary according to\n+     * <a href=\"https://tools.ietf.org/html/rfc4180#section-2\">RFC-4180</a>.\n+     * <p>\n+     * The {@link CharSequence} will be escaped is if contains a\n+     * <ul>\n+     *     <li>{@link StringUtil#COMMA}</li>\n+     *     <li>{@link StringUtil#LINE_FEED}</li>\n+     *     <li>{@link StringUtil#CARRIAGE_RETURN}</li>\n+     *     <li>{@link StringUtil#DOUBLE_QUOTE}</li>\n+     * </ul>\n+     * If a double quote is found inside of the value, it will be escaped by preceeding it\n+     * with another double quote.\n+     *\n+     * @param value the value to be appended, and quoted if necessary\n+     * @return {@link CharSequence} the quoted value\n+     */\n+    public static CharSequence escapeCsv(CharSequence value) {\n+        int length = checkNotNull(value, \"value\").length();\n+        if (length == 0) {\n+            return value;\n+        }\n+        int first = 0;\n+        char previous = value.charAt(first);\n+        int last = length - 1;\n+        boolean quoted = isDoubleQuote(previous) && isDoubleQuote(value.charAt(last)) && length != 1;\n+        boolean needsQuote = false;\n+        StringBuilder escaped = new StringBuilder(DOUBLE_QUOTE_STRING);\n+        for (int i = 0; i < length; i++) {\n+            char current = value.charAt(i);\n+            switch (current) {\n+                case DOUBLE_QUOTE:\n+                    // don't quote if already quoted.\n+                    if ((i == first || i == last) && quoted) {\n+                        continue;\n+                    }\n+                    // if the current char is not escaped, escape it. But only if it is not already escaped.\n+                    // special case where a double quote exists before the last closing quote.\n+                    if (!quoted || !isDoubleQuote(previous) &&\n+                            (!isDoubleQuote(next(value, i)) || isDoubleQuote(next(value, i)) && i + 1 == last)) {\n+                        escaped.append(DOUBLE_QUOTE);\n+                    }\n+                case LINE_FEED:\n+                case CARRIAGE_RETURN:\n+                case COMMA:\n+                    needsQuote = true;","path":"common/src/main/java/io/netty/util/internal/StringUtil.java","position":76,"original_position":76,"commit_id":"42f425a0868e9e61dc3515b562ed112331231718","original_commit_id":"42f425a0868e9e61dc3515b562ed112331231718","user":{"login":"danbev","id":432351,"avatar_url":"https://avatars.githubusercontent.com/u/432351?v=3","gravatar_id":"","url":"https://api.github.com/users/danbev","html_url":"https://github.com/danbev","followers_url":"https://api.github.com/users/danbev/followers","following_url":"https://api.github.com/users/danbev/following{/other_user}","gists_url":"https://api.github.com/users/danbev/gists{/gist_id}","starred_url":"https://api.github.com/users/danbev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbev/subscriptions","organizations_url":"https://api.github.com/users/danbev/orgs","repos_url":"https://api.github.com/users/danbev/repos","events_url":"https://api.github.com/users/danbev/events{/privacy}","received_events_url":"https://api.github.com/users/danbev/received_events","type":"User","site_admin":false},"body":"Sorry about being a little slow here, but which special characters are you referring to? Are these the ones from [rfc2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2)?","created_at":"2015-01-22T14:51:30Z","updated_at":"2015-01-22T14:51:30Z","html_url":"https://github.com/netty/netty/pull/3271#discussion_r23379632","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/3271","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/23379632"},"html":{"href":"https://github.com/netty/netty/pull/3271#discussion_r23379632"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/3271"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/3271","id":26372499,"html_url":"https://github.com/netty/netty/pull/3271","diff_url":"https://github.com/netty/netty/pull/3271.diff","patch_url":"https://github.com/netty/netty/pull/3271.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/3271","number":3271,"state":"open","locked":false,"title":"Suggestion for supporting single header fields.","user":{"login":"danbev","id":432351,"avatar_url":"https://avatars.githubusercontent.com/u/432351?v=3","gravatar_id":"","url":"https://api.github.com/users/danbev","html_url":"https://github.com/danbev","followers_url":"https://api.github.com/users/danbev/followers","following_url":"https://api.github.com/users/danbev/following{/other_user}","gists_url":"https://api.github.com/users/danbev/gists{/gist_id}","starred_url":"https://api.github.com/users/danbev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbev/subscriptions","organizations_url":"https://api.github.com/users/danbev/orgs","repos_url":"https://api.github.com/users/danbev/repos","events_url":"https://api.github.com/users/danbev/events{/privacy}","received_events_url":"https://api.github.com/users/danbev/received_events","type":"User","site_admin":false},"body":"Motivation:\r\nAt the moment if you want to return a HTTP header containing multiple\r\nvalues you have to set/add that header once with the values wanted. If\r\nyou used set/add with an array/iterable multiple HTTP header fields will\r\nbe returned in the response.\r\n\r\nNote, that this is indeed a suggestion and additional work and tests\r\nshould be added. This is mainly to bring up a discussion.\r\n\r\nModifications:\r\nAdded a flag to specify that when multiple values exist for a single\r\nHTTP header then add them as a comma separated string.\r\n\r\nResult:\r\nAllows for responses to be smaller.","created_at":"2014-12-19T13:53:29Z","updated_at":"2015-01-22T14:51:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e524aa586963b632dcd9f2af80a70b9238d883fe","assignee":{"login":"danbev","id":432351,"avatar_url":"https://avatars.githubusercontent.com/u/432351?v=3","gravatar_id":"","url":"https://api.github.com/users/danbev","html_url":"https://github.com/danbev","followers_url":"https://api.github.com/users/danbev/followers","following_url":"https://api.github.com/users/danbev/following{/other_user}","gists_url":"https://api.github.com/users/danbev/gists{/gist_id}","starred_url":"https://api.github.com/users/danbev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbev/subscriptions","organizations_url":"https://api.github.com/users/danbev/orgs","repos_url":"https://api.github.com/users/danbev/repos","events_url":"https://api.github.com/users/danbev/events{/privacy}","received_events_url":"https://api.github.com/users/danbev/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/netty/netty/pulls/3271/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/3271/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments/{number}","comments_url":"https://api.github.com/repos/netty/netty/issues/3271/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/42f425a0868e9e61dc3515b562ed112331231718","head":{"label":"danbev:single-http-header-fields","ref":"single-http-header-fields","sha":"42f425a0868e9e61dc3515b562ed112331231718","user":{"login":"danbev","id":432351,"avatar_url":"https://avatars.githubusercontent.com/u/432351?v=3","gravatar_id":"","url":"https://api.github.com/users/danbev","html_url":"https://github.com/danbev","followers_url":"https://api.github.com/users/danbev/followers","following_url":"https://api.github.com/users/danbev/following{/other_user}","gists_url":"https://api.github.com/users/danbev/gists{/gist_id}","starred_url":"https://api.github.com/users/danbev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbev/subscriptions","organizations_url":"https://api.github.com/users/danbev/orgs","repos_url":"https://api.github.com/users/danbev/repos","events_url":"https://api.github.com/users/danbev/events{/privacy}","received_events_url":"https://api.github.com/users/danbev/received_events","type":"User","site_admin":false},"repo":{"id":1074091,"name":"netty","full_name":"danbev/netty","owner":{"login":"danbev","id":432351,"avatar_url":"https://avatars.githubusercontent.com/u/432351?v=3","gravatar_id":"","url":"https://api.github.com/users/danbev","html_url":"https://github.com/danbev","followers_url":"https://api.github.com/users/danbev/followers","following_url":"https://api.github.com/users/danbev/following{/other_user}","gists_url":"https://api.github.com/users/danbev/gists{/gist_id}","starred_url":"https://api.github.com/users/danbev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbev/subscriptions","organizations_url":"https://api.github.com/users/danbev/orgs","repos_url":"https://api.github.com/users/danbev/repos","events_url":"https://api.github.com/users/danbev/events{/privacy}","received_events_url":"https://api.github.com/users/danbev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danbev/netty","description":"The Netty Project","fork":true,"url":"https://api.github.com/repos/danbev/netty","forks_url":"https://api.github.com/repos/danbev/netty/forks","keys_url":"https://api.github.com/repos/danbev/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danbev/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danbev/netty/teams","hooks_url":"https://api.github.com/repos/danbev/netty/hooks","issue_events_url":"https://api.github.com/repos/danbev/netty/issues/events{/number}","events_url":"https://api.github.com/repos/danbev/netty/events","assignees_url":"https://api.github.com/repos/danbev/netty/assignees{/user}","branches_url":"https://api.github.com/repos/danbev/netty/branches{/branch}","tags_url":"https://api.github.com/repos/danbev/netty/tags","blobs_url":"https://api.github.com/repos/danbev/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danbev/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danbev/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/danbev/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danbev/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/danbev/netty/languages","stargazers_url":"https://api.github.com/repos/danbev/netty/stargazers","contributors_url":"https://api.github.com/repos/danbev/netty/contributors","subscribers_url":"https://api.github.com/repos/danbev/netty/subscribers","subscription_url":"https://api.github.com/repos/danbev/netty/subscription","commits_url":"https://api.github.com/repos/danbev/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/danbev/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/danbev/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/danbev/netty/issues/comments/{number}","contents_url":"https://api.github.com/repos/danbev/netty/contents/{+path}","compare_url":"https://api.github.com/repos/danbev/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danbev/netty/merges","archive_url":"https://api.github.com/repos/danbev/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danbev/netty/downloads","issues_url":"https://api.github.com/repos/danbev/netty/issues{/number}","pulls_url":"https://api.github.com/repos/danbev/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/danbev/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/danbev/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danbev/netty/labels{/name}","releases_url":"https://api.github.com/repos/danbev/netty/releases{/id}","created_at":"2010-11-12T08:49:52Z","updated_at":"2014-12-09T14:00:28Z","pushed_at":"2015-01-22T11:17:05Z","git_url":"git://github.com/danbev/netty.git","ssh_url":"git@github.com:danbev/netty.git","clone_url":"https://github.com/danbev/netty.git","svn_url":"https://github.com/danbev/netty","homepage":"http://www.jboss.org/netty/","size":30929,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"netty:4.1","ref":"4.1","sha":"563bf24424a5516765105cfbf3989c359925832d","user":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"repo":{"id":1064563,"name":"netty","full_name":"netty/netty","owner":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netty/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":false,"url":"https://api.github.com/repos/netty/netty","forks_url":"https://api.github.com/repos/netty/netty/forks","keys_url":"https://api.github.com/repos/netty/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netty/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netty/netty/teams","hooks_url":"https://api.github.com/repos/netty/netty/hooks","issue_events_url":"https://api.github.com/repos/netty/netty/issues/events{/number}","events_url":"https://api.github.com/repos/netty/netty/events","assignees_url":"https://api.github.com/repos/netty/netty/assignees{/user}","branches_url":"https://api.github.com/repos/netty/netty/branches{/branch}","tags_url":"https://api.github.com/repos/netty/netty/tags","blobs_url":"https://api.github.com/repos/netty/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netty/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netty/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/netty/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netty/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/netty/netty/languages","stargazers_url":"https://api.github.com/repos/netty/netty/stargazers","contributors_url":"https://api.github.com/repos/netty/netty/contributors","subscribers_url":"https://api.github.com/repos/netty/netty/subscribers","subscription_url":"https://api.github.com/repos/netty/netty/subscription","commits_url":"https://api.github.com/repos/netty/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/netty/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/netty/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/netty/netty/issues/comments/{number}","contents_url":"https://api.github.com/repos/netty/netty/contents/{+path}","compare_url":"https://api.github.com/repos/netty/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netty/netty/merges","archive_url":"https://api.github.com/repos/netty/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netty/netty/downloads","issues_url":"https://api.github.com/repos/netty/netty/issues{/number}","pulls_url":"https://api.github.com/repos/netty/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/netty/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/netty/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netty/netty/labels{/name}","releases_url":"https://api.github.com/repos/netty/netty/releases{/id}","created_at":"2010-11-09T09:22:21Z","updated_at":"2015-01-22T08:07:22Z","pushed_at":"2015-01-22T08:37:23Z","git_url":"git://github.com/netty/netty.git","ssh_url":"git@github.com:netty/netty.git","clone_url":"https://github.com/netty/netty.git","svn_url":"https://github.com/netty/netty","homepage":"http://netty.io/","size":105629,"stargazers_count":4074,"watchers_count":4074,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1980,"mirror_url":null,"open_issues_count":223,"forks":1980,"open_issues":223,"watchers":4074,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/3271"},"html":{"href":"https://github.com/netty/netty/pull/3271"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/3271"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/3271/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/3271/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/3271/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/42f425a0868e9e61dc3515b562ed112331231718"}}}}