We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -83,38 +83,38 @@ discard block |
||
| 83 | 83 | function __set($name, $value) |
| 84 | 84 | { |
| 85 | 85 | switch ($name) { |
| 86 | - case 'identity': |
|
| 87 | - if (strlen($value = trim((String) $value))) { |
|
| 88 | - if (preg_match('#^xri:/*#i', $value, $m)) { |
|
| 89 | - $value = substr($value, strlen($m[0])); |
|
| 90 | - } elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) { |
|
| 91 | - $value = "http://$value"; |
|
| 92 | - } |
|
| 93 | - if (preg_match('#^https?://[^/]+$#i', $value, $m)) { |
|
| 94 | - $value .= '/'; |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - $this->$name = $this->claimed_id = $value; |
|
| 98 | - break; |
|
| 99 | - case 'trustRoot': |
|
| 100 | - case 'realm': |
|
| 101 | - $this->trustRoot = trim($value); |
|
| 86 | + case 'identity': |
|
| 87 | + if (strlen($value = trim((String) $value))) { |
|
| 88 | + if (preg_match('#^xri:/*#i', $value, $m)) { |
|
| 89 | + $value = substr($value, strlen($m[0])); |
|
| 90 | + } elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) { |
|
| 91 | + $value = "http://$value"; |
|
| 92 | + } |
|
| 93 | + if (preg_match('#^https?://[^/]+$#i', $value, $m)) { |
|
| 94 | + $value .= '/'; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + $this->$name = $this->claimed_id = $value; |
|
| 98 | + break; |
|
| 99 | + case 'trustRoot': |
|
| 100 | + case 'realm': |
|
| 101 | + $this->trustRoot = trim($value); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | function __get($name) |
| 106 | 106 | { |
| 107 | 107 | switch ($name) { |
| 108 | - case 'identity': |
|
| 109 | - # We return claimed_id instead of identity, |
|
| 110 | - # because the developer should see the claimed identifier, |
|
| 111 | - # i.e. what he set as identity, not the op-local identifier (which is what we verify) |
|
| 112 | - return $this->claimed_id; |
|
| 113 | - case 'trustRoot': |
|
| 114 | - case 'realm': |
|
| 115 | - return $this->trustRoot; |
|
| 116 | - case 'mode': |
|
| 117 | - return empty($this->data['openid_mode']) ? null : $this->data['openid_mode']; |
|
| 108 | + case 'identity': |
|
| 109 | + # We return claimed_id instead of identity, |
|
| 110 | + # because the developer should see the claimed identifier, |
|
| 111 | + # i.e. what he set as identity, not the op-local identifier (which is what we verify) |
|
| 112 | + return $this->claimed_id; |
|
| 113 | + case 'trustRoot': |
|
| 114 | + case 'realm': |
|
| 115 | + return $this->trustRoot; |
|
| 116 | + case 'mode': |
|
| 117 | + return empty($this->data['openid_mode']) ? null : $this->data['openid_mode']; |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -203,73 +203,73 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $params = http_build_query($params, '', '&'); |
| 205 | 205 | switch($method) { |
| 206 | - case 'GET': |
|
| 207 | - $opts = array( |
|
| 208 | - 'http' => array( |
|
| 209 | - 'method' => 'GET', |
|
| 210 | - 'header' => 'Accept: application/xrds+xml, */*', |
|
| 211 | - 'ignore_errors' => true, |
|
| 212 | - ) |
|
| 213 | - ); |
|
| 214 | - $url = $url . ($params ? '?' . $params : ''); |
|
| 215 | - break; |
|
| 216 | - case 'POST': |
|
| 217 | - $opts = array( |
|
| 218 | - 'http' => array( |
|
| 219 | - 'method' => 'POST', |
|
| 220 | - 'header' => 'Content-type: application/x-www-form-urlencoded', |
|
| 221 | - 'content' => $params, |
|
| 222 | - 'ignore_errors' => true, |
|
| 223 | - ) |
|
| 224 | - ); |
|
| 225 | - break; |
|
| 226 | - case 'HEAD': |
|
| 227 | - # We want to send a HEAD request, |
|
| 228 | - # but since get_headers doesn't accept $context parameter, |
|
| 229 | - # we have to change the defaults. |
|
| 230 | - $default = stream_context_get_options(stream_context_get_default()); |
|
| 231 | - stream_context_get_default( |
|
| 232 | - array('http' => array( |
|
| 233 | - 'method' => 'HEAD', |
|
| 234 | - 'header' => 'Accept: application/xrds+xml, */*', |
|
| 235 | - 'ignore_errors' => true, |
|
| 236 | - )) |
|
| 237 | - ); |
|
| 238 | - |
|
| 239 | - $url = $url . ($params ? '?' . $params : ''); |
|
| 240 | - $headers_tmp = get_headers ($url); |
|
| 241 | - if(!$headers_tmp) { |
|
| 242 | - return array(); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - # Parsing headers. |
|
| 246 | - $headers = array(); |
|
| 247 | - foreach($headers_tmp as $header) { |
|
| 248 | - $pos = strpos($header,':'); |
|
| 249 | - $name = strtolower(trim(substr($header, 0, $pos))); |
|
| 250 | - $headers[$name] = trim(substr($header, $pos+1)); |
|
| 251 | - |
|
| 252 | - # Following possible redirections. The point is just to have |
|
| 253 | - # claimed_id change with them, because get_headers() will |
|
| 254 | - # follow redirections automatically. |
|
| 255 | - # We ignore redirections with relative paths. |
|
| 256 | - # If any known provider uses them, file a bug report. |
|
| 257 | - if($name == 'location') { |
|
| 258 | - if(strpos($headers[$name], 'http') === 0) { |
|
| 259 | - $this->identity = $this->claimed_id = $headers[$name]; |
|
| 260 | - } elseif($headers[$name][0] == '/') { |
|
| 261 | - $parsed_url = parse_url($this->claimed_id); |
|
| 262 | - $this->identity = |
|
| 263 | - $this->claimed_id = $parsed_url['scheme'] . '://' |
|
| 264 | - . $parsed_url['host'] |
|
| 265 | - . $headers[$name]; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - # And restore them. |
|
| 271 | - stream_context_get_default($default); |
|
| 272 | - return $headers; |
|
| 206 | + case 'GET': |
|
| 207 | + $opts = array( |
|
| 208 | + 'http' => array( |
|
| 209 | + 'method' => 'GET', |
|
| 210 | + 'header' => 'Accept: application/xrds+xml, */*', |
|
| 211 | + 'ignore_errors' => true, |
|
| 212 | + ) |
|
| 213 | + ); |
|
| 214 | + $url = $url . ($params ? '?' . $params : ''); |
|
| 215 | + break; |
|
| 216 | + case 'POST': |
|
| 217 | + $opts = array( |
|
| 218 | + 'http' => array( |
|
| 219 | + 'method' => 'POST', |
|
| 220 | + 'header' => 'Content-type: application/x-www-form-urlencoded', |
|
| 221 | + 'content' => $params, |
|
| 222 | + 'ignore_errors' => true, |
|
| 223 | + ) |
|
| 224 | + ); |
|
| 225 | + break; |
|
| 226 | + case 'HEAD': |
|
| 227 | + # We want to send a HEAD request, |
|
| 228 | + # but since get_headers doesn't accept $context parameter, |
|
| 229 | + # we have to change the defaults. |
|
| 230 | + $default = stream_context_get_options(stream_context_get_default()); |
|
| 231 | + stream_context_get_default( |
|
| 232 | + array('http' => array( |
|
| 233 | + 'method' => 'HEAD', |
|
| 234 | + 'header' => 'Accept: application/xrds+xml, */*', |
|
| 235 | + 'ignore_errors' => true, |
|
| 236 | + )) |
|
| 237 | + ); |
|
| 238 | + |
|
| 239 | + $url = $url . ($params ? '?' . $params : ''); |
|
| 240 | + $headers_tmp = get_headers ($url); |
|
| 241 | + if(!$headers_tmp) { |
|
| 242 | + return array(); |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + # Parsing headers. |
|
| 246 | + $headers = array(); |
|
| 247 | + foreach($headers_tmp as $header) { |
|
| 248 | + $pos = strpos($header,':'); |
|
| 249 | + $name = strtolower(trim(substr($header, 0, $pos))); |
|
| 250 | + $headers[$name] = trim(substr($header, $pos+1)); |
|
| 251 | + |
|
| 252 | + # Following possible redirections. The point is just to have |
|
| 253 | + # claimed_id change with them, because get_headers() will |
|
| 254 | + # follow redirections automatically. |
|
| 255 | + # We ignore redirections with relative paths. |
|
| 256 | + # If any known provider uses them, file a bug report. |
|
| 257 | + if($name == 'location') { |
|
| 258 | + if(strpos($headers[$name], 'http') === 0) { |
|
| 259 | + $this->identity = $this->claimed_id = $headers[$name]; |
|
| 260 | + } elseif($headers[$name][0] == '/') { |
|
| 261 | + $parsed_url = parse_url($this->claimed_id); |
|
| 262 | + $this->identity = |
|
| 263 | + $this->claimed_id = $parsed_url['scheme'] . '://' |
|
| 264 | + . $parsed_url['host'] |
|
| 265 | + . $headers[$name]; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + # And restore them. |
|
| 271 | + stream_context_get_default($default); |
|
| 272 | + return $headers; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | if($this->verify_peer) { |