From 8e38d459e5946d51c16bce3355ec5393143c8824 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Tue, 15 Dec 2009 05:22:05 +0000 Subject: #653940 follow-up by Damien Tournoud: Clean-up of error handling from first stab at test reporting fixes. --- includes/common.inc | 14 +++++++++----- includes/stream_wrappers.inc | 7 +------ 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index 66464963a..8ff820452 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -807,16 +807,20 @@ function drupal_http_request($url, array $options = array()) { $result = new stdClass(); - // Validate the passed URL. FILTER_VALIDATE_URL uses parse_url() internally, - // but unlike parse_url() itself, it will not throw a run-time notice for - // bogus URLs. - if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { + // Parse the URL and make sure we can handle the schema. + $uri = @parse_url($url); + + if ($uri == FALSE) { $result->error = 'unable to parse URL'; $result->code = -1001; return $result; } - $uri = parse_url($url); + if (!isset($uri['scheme'])) { + $result->error = 'missing schema'; + $result->code = -1002; + return $result; + } timer_start(__FUNCTION__); diff --git a/includes/stream_wrappers.inc b/includes/stream_wrappers.inc index bfbe528b4..c58c58231 100644 --- a/includes/stream_wrappers.inc +++ b/includes/stream_wrappers.inc @@ -500,12 +500,7 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface public function url_stat($uri, $flags) { $this->uri = $uri; if ($flags & STREAM_URL_STAT_QUIET) { - if (file_exists($this->getLocalPath())) { - return stat($this->getLocalPath()); - } - else { - return FALSE; - } + return @stat($this->getLocalPath()); } else { return stat($this->getLocalPath()); -- cgit v1.2.3