Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not crash application if custom scheme is not registered #50

Closed
wants to merge 1 commit into from

Conversation

iguk
Copy link

@iguk iguk commented Apr 18, 2018

If custom url scheme such as "chrome-extension" is not registered, request with header "Origin: chrome-extension://..." will crush application:

PHP Fatal error: Uncaught Zend\Uri\Exception\InvalidArgumentException: no class registered for scheme "chrome-extension" in /vendor/zendframework/zend-uri/src/UriFactory.php:104
Stack trace:
#0 /vendor/zendframework/zend-http/src/Header/Origin.php(32): Zend\Uri\UriFactory::factory('chrome-extensio...')
#1 /vendor/zendframework/zend-http/src/Headers.php(446): Zend\Http\Header\Origin::fromString('Origin: chrome-...')
#2 /vendor/zendframework/zend-http/src/Headers.php(285): Zend\Http\Headers->lazyLoadHeader(4)
#3 /vendor/zfr/zfr-cors/src/ZfrCors/Service/CorsService.php(70): Zend\Http\Headers->get('Origin')
#4 /vendor/zfr/zfr-cors/src/ZfrCors/Mvc/CorsRequestListener.php(89): ZfrCors\Service\CorsService->isCorsRequest(Object(ZF\ContentNegotiation\Request))

It happens because nobody catch InvalidArgumentException from UriFactory in Zend\Http\Header\Origin::fromString.

Requests with "Origin: chrome-extension://..." or "Origin: moz-extension://..." sometimes occur on my production site. This requests are sent from my site users, that is why I can't just register several custom url schemes in my onBootstrap().

I think it would be better to response with 400 code (as described in CorsRequestListener->onCorsPreflight), than to crush application with 500 error.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 95.484% when pulling 8277075 on iguk:master into c6c48aa on zf-fr:master.

@svycka
Copy link
Collaborator

svycka commented Jan 17, 2019

this is not a bug #15 :)

@svycka svycka closed this Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants