Validate::uri replaced with filter_var for HTTP[S] URL checks

Also, a bug in checking the OAuth callback URL for validity was fixed,
where it referenced the wrong variable when going through form data.
This commit is contained in:
Mikael Nordfeldth
2013-10-07 14:46:09 +02:00
parent 2c0790be54
commit 8912cdc7a4
18 changed files with 57 additions and 110 deletions

View File

@@ -74,7 +74,7 @@ class BookmarkforurlAction extends Action
throw new ClientException(_('URL is required.'), 400);
}
if (!Validate::uri($this->url, array('allowed_schemes' => array('http', 'https')))) {
if (!common_valid_http_url($this->url)) {
throw new ClientException(_('Invalid URL.'), 400);
}

View File

@@ -267,10 +267,7 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
$this->removeAll($user, 'website');
$i = 0;
foreach($sites as $site) {
if (!empty($site['value']) && !Validate::uri(
$site['value'],
array('allowed_schemes' => array('http', 'https')))
) {
if (!empty($site['value']) && !common_valid_http_url($site['value'])) {
// TRANS: Exception thrown when entering an invalid URL.
// TRANS: %s is the invalid URL.
throw new Exception(sprintf(_m('Invalid URL: %s.'), $site['value']));

View File

@@ -1323,7 +1323,7 @@ class Ostatus_profile extends Managed_DataObject
}
if ($url) {
$opts = array('allowed_schemes' => array('http', 'https'));
if (Validate::uri($url, $opts)) {
if (common_valid_http_url($url)) {
return $url;
}
}
@@ -1615,7 +1615,7 @@ class Ostatus_profile extends Managed_DataObject
$profile->profileurl = $object->link;
} else if (array_key_exists('profileurl', $hints)) {
$profile->profileurl = $hints['profileurl'];
} else if (Validate::uri($object->id, array('allowed_schemes' => array('http', 'https')))) {
} else if (common_valid_http_url($object->id)) {
$profile->profileurl = $object->id;
}