diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 14 | ||||
-rw-r--r-- | includes/stream_wrappers.inc | 7 |
2 files changed, 11 insertions, 10 deletions
diff --git a/includes/common.inc b/includes/common.inc index 613596ffa..e8734e0c5 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -807,20 +807,16 @@ function drupal_http_request($url, array $options = array()) { $result = new stdClass(); - // Parse the URL and make sure we can handle the schema. - $uri = @parse_url($url); - - if ($uri == FALSE) { + // 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) { $result->error = 'unable to parse URL'; $result->code = -1001; return $result; } - if (!isset($uri['scheme'])) { - $result->error = 'missing schema'; - $result->code = -1002; - return $result; - } + $uri = parse_url($url); timer_start(__FUNCTION__); diff --git a/includes/stream_wrappers.inc b/includes/stream_wrappers.inc index c58c58231..bfbe528b4 100644 --- a/includes/stream_wrappers.inc +++ b/includes/stream_wrappers.inc @@ -500,7 +500,12 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface public function url_stat($uri, $flags) { $this->uri = $uri; if ($flags & STREAM_URL_STAT_QUIET) { - return @stat($this->getLocalPath()); + if (file_exists($this->getLocalPath())) { + return stat($this->getLocalPath()); + } + else { + return FALSE; + } } else { return stat($this->getLocalPath()); |