Skip to content

Loading…

Handle apache_request_headers() non-array return values #57

Merged
merged 1 commit into from

2 participants

@arnaud-lb
FriendsOfSymfony member

apache_request_headers() can return false on failure: http://php.net/apache_request_headers

This PR handles this. (Diff best viewed with ?w=1.)

@alanbem alanbem merged commit a9e5247 into master

1 check passed

Details default The Travis CI build passed
@alanbem

Thanks!

@stof stof deleted the pr/apache-request-headers-failure branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 5, 2014
  1. @arnaud-lb
Showing with 7 additions and 4 deletions.
  1. +7 −4 lib/OAuth2/OAuth2.php
View
11 lib/OAuth2/OAuth2.php
@@ -589,11 +589,14 @@ protected function getBearerTokenFromHeaders(Request $request, $removeFromReques
if (function_exists('apache_request_headers')) {
$headers = apache_request_headers();
- // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization)
- $headers = array_combine(array_map('ucwords', array_keys($headers)), array_values($headers));
+ if (is_array($headers)) {
- if (isset($headers['Authorization'])) {
- $header = $headers['Authorization'];
+ // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization)
+ $headers = array_combine(array_map('ucwords', array_keys($headers)), array_values($headers));
+
+ if (isset($headers['Authorization'])) {
+ $header = $headers['Authorization'];
+ }
}
}
} else {
Something went wrong with that request. Please try again.