Permalink
Browse files

Ensure all variables work in strict mode

  • Loading branch information...
1 parent 3a1b1dc commit 4d67750ff0e4de208a19e290e00e6e392fbcc956 @dcramer dcramer committed Feb 1, 2012
Showing with 16 additions and 9 deletions.
  1. +16 −9 lib/Raven/Client.php
View
@@ -50,22 +50,29 @@ function __construct($options_or_dsn=null, $options=array())
public static function parseDSN($dsn)
{
$url = parse_url($dsn);
- $scheme = $url['scheme'];
+ $scheme = (isset($url['scheme']) ? $url['scheme'] : '');
if (!in_array($scheme, array('http', 'https'))) {
throw new InvalidArgumentException('Unsupported Sentry DSN scheme: ' . $scheme);
}
- $netloc = $url['host'];
- $pos = strrpos($url['path'], '/', 1);
- if ($pos !== false) {
- $path = substr($url['path'], 0, $pos);
- $project = substr($url['path'], $pos + 1);
+ $netloc = (isset($url['host']) ? $url['host'] : null);
+ $rawpath = (isset($url['path']) ? $url['path'] : null);
+ if ($rawpath) {
+ $pos = strrpos($rawpath, '/', 1);
+ if ($pos !== false) {
+ $path = substr($rawpath, 0, $pos);
+ $project = substr($rawpath, $pos + 1);
+ }
+ else {
+ $path = '';
+ $project = substr($rawpath, 1);
+ }
}
else {
+ $project = null;
$path = '';
- $project = substr($url['path'], 1);
}
- $username = $url['user'];
- $password = $url['pass'];
+ $username = (isset($url['user']) ? $url['user'] : null);
+ $password = (isset($url['pass']) ? $url['pass'] : null);
if (empty($netloc) || empty($project) || empty($username) || empty($password)) {
throw new InvalidArgumentException('Invalid Sentry DSN: ' . $dsn);
}

0 comments on commit 4d67750

Please sign in to comment.