{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/78455973","id":78455973,"diff_hunk":"@@ -0,0 +1,348 @@\n+﻿// Licensed to the .NET Foundation under one or more agreements.\n+// The .NET Foundation licenses this file to you under the MIT license.\n+// See the LICENSE file in the project root for more information.\n+\n+using System.Collections.Specialized;\n+using System.Globalization;\n+using System.IO;\n+using System.Text;\n+using System.Web.Util;\n+\n+namespace System.Web\n+{\n+    public sealed class HttpUtility\n+    {\n+        private sealed class HttpQSCollection : NameValueCollection\n+        {\n+            internal HttpQSCollection()\n+                : base(StringComparer.OrdinalIgnoreCase)\n+            {\n+            }\n+\n+            public override string ToString()\n+            {\n+                int count = Count;\n+                if (count == 0)\n+                    return \"\";\n+                StringBuilder sb = new StringBuilder();\n+                string[] keys = AllKeys;\n+                for (int i = 0; i < count; i++)\n+                {\n+                    sb.AppendFormat(\"{0}={1}&\", keys[i], UrlEncode(this[keys[i]]));\n+                }\n+                if (sb.Length > 0)\n+                    sb.Length--;\n+                return sb.ToString();\n+            }\n+        }\n+\n+        public static NameValueCollection ParseQueryString(string query)\n+        {\n+            return ParseQueryString(query, Encoding.UTF8);\n+        }\n+\n+        public static NameValueCollection ParseQueryString(string query, Encoding encoding)\n+        {\n+            if (query == null)\n+                throw new ArgumentNullException(nameof(query));\n+\n+            if (encoding == null)\n+                throw new ArgumentNullException(nameof(encoding));\n+\n+            if ((query.Length > 0) && (query[0] == '?'))\n+                query = query.Substring(1);\n+\n+            var result = new HttpQSCollection();\n+            ParseQueryString(query, encoding, result);\n+            return result;\n+        }\n+\n+        private static void ParseQueryString(string query, Encoding encoding, NameValueCollection result)\n+        {\n+            if (query.Length == 0)\n+                return;\n+\n+            var decoded = HtmlDecode(query);\n+            var decodedLength = decoded.Length;\n+            var namePos = 0;\n+            var first = true;\n+            while (namePos <= decodedLength)\n+            {\n+                int valuePos = -1, valueEnd = -1;\n+                for (var q = namePos; q < decodedLength; q++)\n+                    if ((valuePos == -1) && (decoded[q] == '='))\n+                    {\n+                        valuePos = q + 1;\n+                    }\n+                    else if (decoded[q] == '&')\n+                    {\n+                        valueEnd = q;\n+                        break;\n+                    }\n+\n+                if (first)\n+                {\n+                    first = false;\n+                    if (decoded[namePos] == '?')\n+                        namePos++;\n+                }\n+\n+                string name;\n+                if (valuePos == -1)\n+                {\n+                    name = null;\n+                    valuePos = namePos;\n+                }\n+                else\n+                {\n+                    name = UrlDecode(decoded.Substring(namePos, valuePos - namePos - 1), encoding);\n+                }\n+                if (valueEnd < 0)\n+                {\n+                    namePos = -1;\n+                    valueEnd = decoded.Length;\n+                }\n+                else\n+                {\n+                    namePos = valueEnd + 1;\n+                }\n+                var value = UrlDecode(decoded.Substring(valuePos, valueEnd - valuePos), encoding);\n+\n+                result.Add(name, value);\n+                if (namePos == -1)\n+                    break;\n+            }\n+        }\n+\n+        /// <devdoc>\n+        ///     <para>\n+        ///         HTML decodes a string and returns the decoded string.\n+        ///     </para>\n+        /// </devdoc>\n+        public static string HtmlDecode(string s)\n+        {\n+            return HttpEncoder.HtmlDecode(s);\n+        }\n+\n+\n+        /// <devdoc>\n+        ///     <para>\n+        ///         HTML decode a string and send the result to a TextWriter output stream.\n+        ///     </para>\n+        /// </devdoc>\n+        public static void HtmlDecode(string s, TextWriter output)\n+        {\n+            HttpEncoder.HtmlDecode(s, output);\n+        }\n+\n+\n+        /// <devdoc>\n+        ///     <para>\n+        ///         HTML encodes a string and returns the encoded string.\n+        ///     </para>\n+        /// </devdoc>\n+        public static string HtmlEncode(string s)\n+        {\n+            return HttpEncoder.HtmlEncode(s);","path":"src/System.Collections.Specialized/src/System/Web/HttpUtility.cs","position":146,"original_position":146,"commit_id":"2c7a6bb99bda8de44bf1a3675f042e9636b51942","original_commit_id":"2c7a6bb99bda8de44bf1a3675f042e9636b51942","user":{"login":"weshaggard","id":9010698,"avatar_url":"https://avatars.githubusercontent.com/u/9010698?v=3","gravatar_id":"","url":"https://api.github.com/users/weshaggard","html_url":"https://github.com/weshaggard","followers_url":"https://api.github.com/users/weshaggard/followers","following_url":"https://api.github.com/users/weshaggard/following{/other_user}","gists_url":"https://api.github.com/users/weshaggard/gists{/gist_id}","starred_url":"https://api.github.com/users/weshaggard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weshaggard/subscriptions","organizations_url":"https://api.github.com/users/weshaggard/orgs","repos_url":"https://api.github.com/users/weshaggard/repos","events_url":"https://api.github.com/users/weshaggard/events{/privacy}","received_events_url":"https://api.github.com/users/weshaggard/received_events","type":"User","site_admin":false},"body":"Wouldn't this just call WebUtility.HtmlEncode? As @davidsh was pointing out? Similarly for the other overloads and UrlEncode. ","created_at":"2016-09-12T21:13:09Z","updated_at":"2016-09-12T21:13:09Z","html_url":"https://github.com/dotnet/corefx/pull/11642#discussion_r78455973","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/11642","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/78455973"},"html":{"href":"https://github.com/dotnet/corefx/pull/11642#discussion_r78455973"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/11642"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/11642","id":84912472,"html_url":"https://github.com/dotnet/corefx/pull/11642","diff_url":"https://github.com/dotnet/corefx/pull/11642.diff","patch_url":"https://github.com/dotnet/corefx/pull/11642.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/11642","number":11642,"state":"open","locked":false,"title":"Port S.Web.HttpUtility and add tests.","user":{"login":"alexperovich","id":10565410,"avatar_url":"https://avatars.githubusercontent.com/u/10565410?v=3","gravatar_id":"","url":"https://api.github.com/users/alexperovich","html_url":"https://github.com/alexperovich","followers_url":"https://api.github.com/users/alexperovich/followers","following_url":"https://api.github.com/users/alexperovich/following{/other_user}","gists_url":"https://api.github.com/users/alexperovich/gists{/gist_id}","starred_url":"https://api.github.com/users/alexperovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexperovich/subscriptions","organizations_url":"https://api.github.com/users/alexperovich/orgs","repos_url":"https://api.github.com/users/alexperovich/repos","events_url":"https://api.github.com/users/alexperovich/events{/privacy}","received_events_url":"https://api.github.com/users/alexperovich/received_events","type":"User","site_admin":false},"body":"This change ports the System.Web.HttpUtility class and tests.\r\n\r\nIt is in the System.Collections.Specialized assembly because\r\nHttpUtility.ParseQueryString depends on NameValueCollection\r\nand we want to get this code in.\r\n\r\nFixes #11262 ","created_at":"2016-09-12T17:37:26Z","updated_at":"2016-09-12T21:13:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fd5f066d43055d6625c4fb62a27bbffcd7ccd153","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/11642/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/11642/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/11642/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/2c7a6bb99bda8de44bf1a3675f042e9636b51942","head":{"label":"alexperovich:HttpUtility","ref":"HttpUtility","sha":"2c7a6bb99bda8de44bf1a3675f042e9636b51942","user":{"login":"alexperovich","id":10565410,"avatar_url":"https://avatars.githubusercontent.com/u/10565410?v=3","gravatar_id":"","url":"https://api.github.com/users/alexperovich","html_url":"https://github.com/alexperovich","followers_url":"https://api.github.com/users/alexperovich/followers","following_url":"https://api.github.com/users/alexperovich/following{/other_user}","gists_url":"https://api.github.com/users/alexperovich/gists{/gist_id}","starred_url":"https://api.github.com/users/alexperovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexperovich/subscriptions","organizations_url":"https://api.github.com/users/alexperovich/orgs","repos_url":"https://api.github.com/users/alexperovich/repos","events_url":"https://api.github.com/users/alexperovich/events{/privacy}","received_events_url":"https://api.github.com/users/alexperovich/received_events","type":"User","site_admin":false},"repo":{"id":29363919,"name":"corefx","full_name":"alexperovich/corefx","owner":{"login":"alexperovich","id":10565410,"avatar_url":"https://avatars.githubusercontent.com/u/10565410?v=3","gravatar_id":"","url":"https://api.github.com/users/alexperovich","html_url":"https://github.com/alexperovich","followers_url":"https://api.github.com/users/alexperovich/followers","following_url":"https://api.github.com/users/alexperovich/following{/other_user}","gists_url":"https://api.github.com/users/alexperovich/gists{/gist_id}","starred_url":"https://api.github.com/users/alexperovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexperovich/subscriptions","organizations_url":"https://api.github.com/users/alexperovich/orgs","repos_url":"https://api.github.com/users/alexperovich/repos","events_url":"https://api.github.com/users/alexperovich/events{/privacy}","received_events_url":"https://api.github.com/users/alexperovich/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexperovich/corefx","description":"This repository contains the foundational libraries that make up the .NET Core development stack.","fork":true,"url":"https://api.github.com/repos/alexperovich/corefx","forks_url":"https://api.github.com/repos/alexperovich/corefx/forks","keys_url":"https://api.github.com/repos/alexperovich/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexperovich/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexperovich/corefx/teams","hooks_url":"https://api.github.com/repos/alexperovich/corefx/hooks","issue_events_url":"https://api.github.com/repos/alexperovich/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/alexperovich/corefx/events","assignees_url":"https://api.github.com/repos/alexperovich/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/alexperovich/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/alexperovich/corefx/tags","blobs_url":"https://api.github.com/repos/alexperovich/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexperovich/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexperovich/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexperovich/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexperovich/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/alexperovich/corefx/languages","stargazers_url":"https://api.github.com/repos/alexperovich/corefx/stargazers","contributors_url":"https://api.github.com/repos/alexperovich/corefx/contributors","subscribers_url":"https://api.github.com/repos/alexperovich/corefx/subscribers","subscription_url":"https://api.github.com/repos/alexperovich/corefx/subscription","commits_url":"https://api.github.com/repos/alexperovich/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexperovich/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexperovich/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexperovich/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexperovich/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/alexperovich/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexperovich/corefx/merges","archive_url":"https://api.github.com/repos/alexperovich/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexperovich/corefx/downloads","issues_url":"https://api.github.com/repos/alexperovich/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/alexperovich/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/alexperovich/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/alexperovich/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexperovich/corefx/labels{/name}","releases_url":"https://api.github.com/repos/alexperovich/corefx/releases{/id}","deployments_url":"https://api.github.com/repos/alexperovich/corefx/deployments","created_at":"2015-01-16T19:21:49Z","updated_at":"2016-09-06T20:01:24Z","pushed_at":"2016-09-12T17:36:36Z","git_url":"git://github.com/alexperovich/corefx.git","ssh_url":"git@github.com:alexperovich/corefx.git","clone_url":"https://github.com/alexperovich/corefx.git","svn_url":"https://github.com/alexperovich/corefx","homepage":"","size":94980,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:dev/api","ref":"dev/api","sha":"5f43b8637ac49a0304bd55482a009c448eb83a47","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/corefx/deployments","created_at":"2014-11-06T23:42:48Z","updated_at":"2016-09-12T18:06:50Z","pushed_at":"2016-09-12T21:12:22Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"https://docs.microsoft.com/dotnet/","size":139306,"stargazers_count":10506,"watchers_count":10506,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2609,"mirror_url":null,"open_issues_count":1460,"forks":2609,"open_issues":1460,"watchers":10506,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/11642"},"html":{"href":"https://github.com/dotnet/corefx/pull/11642"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/11642"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/11642/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/11642/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/11642/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/2c7a6bb99bda8de44bf1a3675f042e9636b51942"}}}}
{"actor":{"display_login":"weshaggard"}}