diff options
author | tailor <cygnus@janrain.com> | 2008-05-21 00:32:13 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2008-05-21 00:32:13 +0000 |
commit | bad45cb45aea88552dc61bbfca03b946b173bf76 (patch) | |
tree | e3ff84bf5a3db0449ea779ae37f7279f20912ef2 /Auth/Yadis/HTTPFetcher.php | |
parent | 1b5a2a7cf7fb6c01b503d49a17eda69d4293ddde (diff) | |
download | php-openid-bad45cb45aea88552dc61bbfca03b946b173bf76.zip php-openid-bad45cb45aea88552dc61bbfca03b946b173bf76.tar.gz php-openid-bad45cb45aea88552dc61bbfca03b946b173bf76.tar.bz2 |
[project @ Collapse allowedURL and isHTTPS checks into HTTPFetcher.canFetchURL]
Diffstat (limited to 'Auth/Yadis/HTTPFetcher.php')
-rw-r--r-- | Auth/Yadis/HTTPFetcher.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Auth/Yadis/HTTPFetcher.php b/Auth/Yadis/HTTPFetcher.php index 97617bf..6c2d6fa 100644 --- a/Auth/Yadis/HTTPFetcher.php +++ b/Auth/Yadis/HTTPFetcher.php @@ -13,6 +13,11 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL */ +/** + * Require logging functionality + */ +require_once "Auth/OpenID.php"; + class Auth_Yadis_HTTPResponse { function Auth_Yadis_HTTPResponse($final_url = null, $status = null, $headers = null, $body = null) @@ -37,6 +42,30 @@ class Auth_Yadis_HTTPFetcher { var $timeout = 20; // timeout in seconds. /** + * Return whether a URL can be fetched. Returns false if the URL + * scheme is not allowed or is not supported by this fetcher + * implementation; returns true otherwise. + * + * @return bool + */ + function canFetchURL($url) + { + if ($this->isHTTPS($url) && !$this->supportsSSL()) { + Auth_OpenID::log("HTTPS URL unsupported fetching %s", + $url); + return false; + } + + if (!$this->allowedURL($url)) { + Auth_OpenID::log("URL fetching not allowed for '%s'", + $url); + return false; + } + + return true; + } + + /** * Return whether a URL should be allowed. Override this method to * conform to your local policy. * |