{"action":"created","comment":{"url":"https://api.github.com/repos/cakephp/cakephp/pulls/comments/195268856","pull_request_review_id":128603100,"id":195268856,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NTI2ODg1Ng==","diff_hunk":"@@ -577,16 +584,54 @@ public function session(Session $session = null)\n      */\n     public function clientIp()\n     {\n-        if ($this->trustProxy && $this->getEnv('HTTP_X_FORWARDED_FOR')) {\n-            $addresses = explode(',', $this->getEnv('HTTP_X_FORWARDED_FOR'));\n-            $ipaddr = end($addresses);\n-        } elseif ($this->trustProxy && $this->getEnv('HTTP_CLIENT_IP')) {\n-            $ipaddr = $this->getEnv('HTTP_CLIENT_IP');\n-        } else {\n-            $ipaddr = $this->getEnv('REMOTE_ADDR');\n+        if ($this->trustProxy) {\n+            if ($forwarded = $this->getEnv('HTTP_X_FORWARDED_FOR')) {\n+                $addresses = array_map('trim', explode(',', $forwarded));\n+                $trusted = (count($this->trustedProxies) > 0);\n+                $n = count($addresses);\n+\n+                if ($trusted) {\n+                    for ($i = 1; $i < $n; $i++) {\n+                        if (in_array($addresses[$i], $this->trustedProxies) === false) {\n+                            $trusted = false;\n+                            break;\n+                        }\n+                    }\n+                }\n+\n+                return (($trusted) ? $addresses[0] : $addresses[$n - 1]);\n+            } else {\n+                if ($ip = $this->getEnv('HTTP_X_REAL_IP')) {\n+                    return $ip;\n+                } elseif ($ip = $this->getEnv('HTTP_CLIENT_IP')) {\n+                    return $ip;\n+                }\n+            }\n         }\n \n-        return trim($ipaddr);\n+        return $this->getEnv('REMOTE_ADDR');","path":"src/Http/ServerRequest.php","position":56,"original_position":51,"commit_id":"9a0bc4303675f6b09e81173a0b47889db815c46c","original_commit_id":"4061792e9d0a7916955e94dd5625342f3b144f9e","user":{"login":"dereuromark","id":39854,"node_id":"MDQ6VXNlcjM5ODU0","avatar_url":"https://avatars0.githubusercontent.com/u/39854?v=4","gravatar_id":"","url":"https://api.github.com/users/dereuromark","html_url":"https://github.com/dereuromark","followers_url":"https://api.github.com/users/dereuromark/followers","following_url":"https://api.github.com/users/dereuromark/following{/other_user}","gists_url":"https://api.github.com/users/dereuromark/gists{/gist_id}","starred_url":"https://api.github.com/users/dereuromark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dereuromark/subscriptions","organizations_url":"https://api.github.com/users/dereuromark/orgs","repos_url":"https://api.github.com/users/dereuromark/repos","events_url":"https://api.github.com/users/dereuromark/events{/privacy}","received_events_url":"https://api.github.com/users/dereuromark/received_events","type":"User","site_admin":false},"body":"We must still return empty string then.","created_at":"2018-06-13T23:49:18Z","updated_at":"2018-06-13T23:49:19Z","html_url":"https://github.com/cakephp/cakephp/pull/12234#discussion_r195268856","pull_request_url":"https://api.github.com/repos/cakephp/cakephp/pulls/12234","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/comments/195268856"},"html":{"href":"https://github.com/cakephp/cakephp/pull/12234#discussion_r195268856"},"pull_request":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/12234"}},"in_reply_to_id":195264594},"pull_request":{"url":"https://api.github.com/repos/cakephp/cakephp/pulls/12234","id":194740379,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0NzQwMzc5","html_url":"https://github.com/cakephp/cakephp/pull/12234","diff_url":"https://github.com/cakephp/cakephp/pull/12234.diff","patch_url":"https://github.com/cakephp/cakephp/pull/12234.patch","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/12234","number":12234,"state":"open","locked":false,"title":"fix X-Forwarded-For for clientIp method","user":{"login":"melbahja","id":8259014,"node_id":"MDQ6VXNlcjgyNTkwMTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/8259014?v=4","gravatar_id":"","url":"https://api.github.com/users/melbahja","html_url":"https://github.com/melbahja","followers_url":"https://api.github.com/users/melbahja/followers","following_url":"https://api.github.com/users/melbahja/following{/other_user}","gists_url":"https://api.github.com/users/melbahja/gists{/gist_id}","starred_url":"https://api.github.com/users/melbahja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melbahja/subscriptions","organizations_url":"https://api.github.com/users/melbahja/orgs","repos_url":"https://api.github.com/users/melbahja/repos","events_url":"https://api.github.com/users/melbahja/events{/privacy}","received_events_url":"https://api.github.com/users/melbahja/received_events","type":"User","site_admin":false},"body":"fix X-Forwarded-For for clientIp method which we have already discussed at #12107\r\ntrusted proxies list added\r\ntestCase added\r\nthanks","created_at":"2018-06-13T23:13:03Z","updated_at":"2018-06-13T23:49:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d5598817b5ce72b912defa9fa065b5fe63e40e2c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/173","html_url":"https://github.com/cakephp/cakephp/milestone/173","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/173/labels","id":3413121,"node_id":"MDk6TWlsZXN0b25lMzQxMzEyMQ==","number":173,"title":"3.6.6","description":"Bugfixes for 3.6.","creator":{"login":"markstory","id":24086,"node_id":"MDQ6VXNlcjI0MDg2","avatar_url":"https://avatars3.githubusercontent.com/u/24086?v=4","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"open_issues":36,"closed_issues":6,"state":"open","created_at":"2018-06-10T01:40:19Z","updated_at":"2018-06-13T23:18:37Z","due_on":"2018-06-24T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/cakephp/cakephp/pulls/12234/commits","review_comments_url":"https://api.github.com/repos/cakephp/cakephp/pulls/12234/comments","review_comment_url":"https://api.github.com/repos/cakephp/cakephp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/12234/comments","statuses_url":"https://api.github.com/repos/cakephp/cakephp/statuses/9a0bc4303675f6b09e81173a0b47889db815c46c","head":{"label":"melbahja:master","ref":"master","sha":"9a0bc4303675f6b09e81173a0b47889db815c46c","user":{"login":"melbahja","id":8259014,"node_id":"MDQ6VXNlcjgyNTkwMTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/8259014?v=4","gravatar_id":"","url":"https://api.github.com/users/melbahja","html_url":"https://github.com/melbahja","followers_url":"https://api.github.com/users/melbahja/followers","following_url":"https://api.github.com/users/melbahja/following{/other_user}","gists_url":"https://api.github.com/users/melbahja/gists{/gist_id}","starred_url":"https://api.github.com/users/melbahja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melbahja/subscriptions","organizations_url":"https://api.github.com/users/melbahja/orgs","repos_url":"https://api.github.com/users/melbahja/repos","events_url":"https://api.github.com/users/melbahja/events{/privacy}","received_events_url":"https://api.github.com/users/melbahja/received_events","type":"User","site_admin":false},"repo":{"id":134100030,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQxMDAwMzA=","name":"cakephp","full_name":"melbahja/cakephp","owner":{"login":"melbahja","id":8259014,"node_id":"MDQ6VXNlcjgyNTkwMTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/8259014?v=4","gravatar_id":"","url":"https://api.github.com/users/melbahja","html_url":"https://github.com/melbahja","followers_url":"https://api.github.com/users/melbahja/followers","following_url":"https://api.github.com/users/melbahja/following{/other_user}","gists_url":"https://api.github.com/users/melbahja/gists{/gist_id}","starred_url":"https://api.github.com/users/melbahja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melbahja/subscriptions","organizations_url":"https://api.github.com/users/melbahja/orgs","repos_url":"https://api.github.com/users/melbahja/repos","events_url":"https://api.github.com/users/melbahja/events{/privacy}","received_events_url":"https://api.github.com/users/melbahja/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/melbahja/cakephp","description":"CakePHP: The Rapid Development Framework for PHP - Official Repository","fork":true,"url":"https://api.github.com/repos/melbahja/cakephp","forks_url":"https://api.github.com/repos/melbahja/cakephp/forks","keys_url":"https://api.github.com/repos/melbahja/cakephp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/melbahja/cakephp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/melbahja/cakephp/teams","hooks_url":"https://api.github.com/repos/melbahja/cakephp/hooks","issue_events_url":"https://api.github.com/repos/melbahja/cakephp/issues/events{/number}","events_url":"https://api.github.com/repos/melbahja/cakephp/events","assignees_url":"https://api.github.com/repos/melbahja/cakephp/assignees{/user}","branches_url":"https://api.github.com/repos/melbahja/cakephp/branches{/branch}","tags_url":"https://api.github.com/repos/melbahja/cakephp/tags","blobs_url":"https://api.github.com/repos/melbahja/cakephp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/melbahja/cakephp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/melbahja/cakephp/git/refs{/sha}","trees_url":"https://api.github.com/repos/melbahja/cakephp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/melbahja/cakephp/statuses/{sha}","languages_url":"https://api.github.com/repos/melbahja/cakephp/languages","stargazers_url":"https://api.github.com/repos/melbahja/cakephp/stargazers","contributors_url":"https://api.github.com/repos/melbahja/cakephp/contributors","subscribers_url":"https://api.github.com/repos/melbahja/cakephp/subscribers","subscription_url":"https://api.github.com/repos/melbahja/cakephp/subscription","commits_url":"https://api.github.com/repos/melbahja/cakephp/commits{/sha}","git_commits_url":"https://api.github.com/repos/melbahja/cakephp/git/commits{/sha}","comments_url":"https://api.github.com/repos/melbahja/cakephp/comments{/number}","issue_comment_url":"https://api.github.com/repos/melbahja/cakephp/issues/comments{/number}","contents_url":"https://api.github.com/repos/melbahja/cakephp/contents/{+path}","compare_url":"https://api.github.com/repos/melbahja/cakephp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/melbahja/cakephp/merges","archive_url":"https://api.github.com/repos/melbahja/cakephp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/melbahja/cakephp/downloads","issues_url":"https://api.github.com/repos/melbahja/cakephp/issues{/number}","pulls_url":"https://api.github.com/repos/melbahja/cakephp/pulls{/number}","milestones_url":"https://api.github.com/repos/melbahja/cakephp/milestones{/number}","notifications_url":"https://api.github.com/repos/melbahja/cakephp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/melbahja/cakephp/labels{/name}","releases_url":"https://api.github.com/repos/melbahja/cakephp/releases{/id}","deployments_url":"https://api.github.com/repos/melbahja/cakephp/deployments","created_at":"2018-05-19T21:43:33Z","updated_at":"2018-06-13T23:41:11Z","pushed_at":"2018-06-13T23:41:09Z","git_url":"git://github.com/melbahja/cakephp.git","ssh_url":"git@github.com:melbahja/cakephp.git","clone_url":"https://github.com/melbahja/cakephp.git","svn_url":"https://github.com/melbahja/cakephp","homepage":"http://cakephp.org","size":77630,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cakephp:master","ref":"master","sha":"f1306115051be2d8f9b10d3ede64d23e448b785a","user":{"login":"cakephp","id":23666,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNjY2","avatar_url":"https://avatars0.githubusercontent.com/u/23666?v=4","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"repo":{"id":656494,"node_id":"MDEwOlJlcG9zaXRvcnk2NTY0OTQ=","name":"cakephp","full_name":"cakephp/cakephp","owner":{"login":"cakephp","id":23666,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNjY2","avatar_url":"https://avatars0.githubusercontent.com/u/23666?v=4","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cakephp/cakephp","description":"CakePHP: The Rapid Development Framework for PHP - Official Repository","fork":false,"url":"https://api.github.com/repos/cakephp/cakephp","forks_url":"https://api.github.com/repos/cakephp/cakephp/forks","keys_url":"https://api.github.com/repos/cakephp/cakephp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cakephp/cakephp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cakephp/cakephp/teams","hooks_url":"https://api.github.com/repos/cakephp/cakephp/hooks","issue_events_url":"https://api.github.com/repos/cakephp/cakephp/issues/events{/number}","events_url":"https://api.github.com/repos/cakephp/cakephp/events","assignees_url":"https://api.github.com/repos/cakephp/cakephp/assignees{/user}","branches_url":"https://api.github.com/repos/cakephp/cakephp/branches{/branch}","tags_url":"https://api.github.com/repos/cakephp/cakephp/tags","blobs_url":"https://api.github.com/repos/cakephp/cakephp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cakephp/cakephp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cakephp/cakephp/git/refs{/sha}","trees_url":"https://api.github.com/repos/cakephp/cakephp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cakephp/cakephp/statuses/{sha}","languages_url":"https://api.github.com/repos/cakephp/cakephp/languages","stargazers_url":"https://api.github.com/repos/cakephp/cakephp/stargazers","contributors_url":"https://api.github.com/repos/cakephp/cakephp/contributors","subscribers_url":"https://api.github.com/repos/cakephp/cakephp/subscribers","subscription_url":"https://api.github.com/repos/cakephp/cakephp/subscription","commits_url":"https://api.github.com/repos/cakephp/cakephp/commits{/sha}","git_commits_url":"https://api.github.com/repos/cakephp/cakephp/git/commits{/sha}","comments_url":"https://api.github.com/repos/cakephp/cakephp/comments{/number}","issue_comment_url":"https://api.github.com/repos/cakephp/cakephp/issues/comments{/number}","contents_url":"https://api.github.com/repos/cakephp/cakephp/contents/{+path}","compare_url":"https://api.github.com/repos/cakephp/cakephp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cakephp/cakephp/merges","archive_url":"https://api.github.com/repos/cakephp/cakephp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cakephp/cakephp/downloads","issues_url":"https://api.github.com/repos/cakephp/cakephp/issues{/number}","pulls_url":"https://api.github.com/repos/cakephp/cakephp/pulls{/number}","milestones_url":"https://api.github.com/repos/cakephp/cakephp/milestones{/number}","notifications_url":"https://api.github.com/repos/cakephp/cakephp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cakephp/cakephp/labels{/name}","releases_url":"https://api.github.com/repos/cakephp/cakephp/releases{/id}","deployments_url":"https://api.github.com/repos/cakephp/cakephp/deployments","created_at":"2010-05-08T14:38:22Z","updated_at":"2018-06-13T19:07:59Z","pushed_at":"2018-06-13T23:41:10Z","git_url":"git://github.com/cakephp/cakephp.git","ssh_url":"git@github.com:cakephp/cakephp.git","clone_url":"https://github.com/cakephp/cakephp.git","svn_url":"https://github.com/cakephp/cakephp","homepage":"http://cakephp.org","size":78298,"stargazers_count":7556,"watchers_count":7556,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3337,"mirror_url":null,"archived":false,"open_issues_count":252,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":3337,"open_issues":252,"watchers":7556,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/12234"},"html":{"href":"https://github.com/cakephp/cakephp/pull/12234"},"issue":{"href":"https://api.github.com/repos/cakephp/cakephp/issues/12234"},"comments":{"href":"https://api.github.com/repos/cakephp/cakephp/issues/12234/comments"},"review_comments":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/12234/comments"},"review_comment":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/12234/commits"},"statuses":{"href":"https://api.github.com/repos/cakephp/cakephp/statuses/9a0bc4303675f6b09e81173a0b47889db815c46c"}},"author_association":"NONE"}}
{"actor":{"display_login":"dereuromark"}}