{"action":"created","issue":{"url":"https://api.github.com/repos/zendframework/zend-http/issues/151","repository_url":"https://api.github.com/repos/zendframework/zend-http","labels_url":"https://api.github.com/repos/zendframework/zend-http/issues/151/labels{/name}","comments_url":"https://api.github.com/repos/zendframework/zend-http/issues/151/comments","events_url":"https://api.github.com/repos/zendframework/zend-http/issues/151/events","html_url":"https://github.com/zendframework/zend-http/pull/151","id":327706019,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkxNDMzNzM3","number":151,"title":"Passing an invalid uri to the referrer header should no longer throw","user":{"login":"roelvanduijnhoven","id":91910,"node_id":"MDQ6VXNlcjkxOTEw","avatar_url":"https://avatars1.githubusercontent.com/u/91910?v=4","gravatar_id":"","url":"https://api.github.com/users/roelvanduijnhoven","html_url":"https://github.com/roelvanduijnhoven","followers_url":"https://api.github.com/users/roelvanduijnhoven/followers","following_url":"https://api.github.com/users/roelvanduijnhoven/following{/other_user}","gists_url":"https://api.github.com/users/roelvanduijnhoven/gists{/gist_id}","starred_url":"https://api.github.com/users/roelvanduijnhoven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roelvanduijnhoven/subscriptions","organizations_url":"https://api.github.com/users/roelvanduijnhoven/orgs","repos_url":"https://api.github.com/users/roelvanduijnhoven/repos","events_url":"https://api.github.com/users/roelvanduijnhoven/events{/privacy}","received_events_url":"https://api.github.com/users/roelvanduijnhoven/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-30T12:21:36Z","updated_at":"2018-08-13T18:20:40Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/zendframework/zend-http/pulls/151","html_url":"https://github.com/zendframework/zend-http/pull/151","diff_url":"https://github.com/zendframework/zend-http/pull/151.diff","patch_url":"https://github.com/zendframework/zend-http/pull/151.patch"},"body":"Due to the change in https://github.com/zendframework/zend-http/pull/147 we removed the try/catch control structures from our code. However: exceptions are still generated. I think that this is not intended.\r\n\r\nThe only valid way to check for a referrer is now the following. Which is kind of cumbersome:\r\n```php\r\nfunction isRefererFromGitHub($headers) {\r\n    try {\r\n        $referer = $headers->get('Referer');\r\n        if (!$referer instanceof \\Zend\\Http\\Header\\GenericHeader) {\r\n            return false;\r\n        }\r\n        \r\n        return $referer->getUri()->getHost() === 'github.com';\r\n    } catch (\\Zend\\Http\\Header\\Exception\\InvalidArgumentException $e) {\r\n        return false;\r\n    }\r\n}\r\n```\r\n\r\nThis PR fixes this by wrapping the exception generated. \r\n\r\n----\r\n\r\nI am however a bit unsure if this is correct. The release notes state:\r\n\r\n> Now, Header::has() will return false for such headers\r\n\r\nHowever; in my case the `has` function _does_ yield true. Therefore I omitted that assertion from my test code.\r\n\r\nAny thoughts @webimpress @weierophinney?"},"comment":{"url":"https://api.github.com/repos/zendframework/zend-http/issues/comments/412615428","html_url":"https://github.com/zendframework/zend-http/pull/151#issuecomment-412615428","issue_url":"https://api.github.com/repos/zendframework/zend-http/issues/151","id":412615428,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjYxNTQyOA==","user":{"login":"weierophinney","id":25943,"node_id":"MDQ6VXNlcjI1OTQz","avatar_url":"https://avatars1.githubusercontent.com/u/25943?v=4","gravatar_id":"","url":"https://api.github.com/users/weierophinney","html_url":"https://github.com/weierophinney","followers_url":"https://api.github.com/users/weierophinney/followers","following_url":"https://api.github.com/users/weierophinney/following{/other_user}","gists_url":"https://api.github.com/users/weierophinney/gists{/gist_id}","starred_url":"https://api.github.com/users/weierophinney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weierophinney/subscriptions","organizations_url":"https://api.github.com/users/weierophinney/orgs","repos_url":"https://api.github.com/users/weierophinney/repos","events_url":"https://api.github.com/users/weierophinney/events{/privacy}","received_events_url":"https://api.github.com/users/weierophinney/received_events","type":"User","site_admin":false},"created_at":"2018-08-13T18:20:40Z","updated_at":"2018-08-13T18:20:40Z","author_association":"MEMBER","body":"This is a case where `has()` SHOULD return `true`, but `get()` MUST raise an exception. As such.\r\n\r\nWe have a similar situation in zend-servicemanager: an entry can be both registered, allowing `has()` to return `true`, but, due to missing dependencies or other problems, `get()` will raise an exception. This is normal; `has() ` is simply indicating that the container knows about the entry. As such, your changes make sense."}}
{"actor":{"display_login":"weierophinney"}}