oEmbed Action logic simplified (early return)
This commit is contained in:
parent
3dc30b6b8f
commit
94d3f50aee
|
@ -44,7 +44,12 @@ class OembedAction extends Action
|
|||
parent::handle();
|
||||
|
||||
$url = $this->trimmed('url');
|
||||
if (substr(strtolower($url),0,strlen(common_root_url())) == strtolower(common_root_url())) {
|
||||
if (substr(strtolower($url),0,strlen(common_root_url())) !== strtolower(common_root_url())) {
|
||||
// TRANS: Error message displaying attachments. %s is the site's base URL.
|
||||
// FIXME: 404 not found?! (this will automatically become a 500 because it's not a serverError!)
|
||||
$this->serverError(sprintf(_('Only %s URLs over plain HTTP please.'), common_root_url()), 404);
|
||||
}
|
||||
|
||||
$path = substr($url,strlen(common_root_url()));
|
||||
|
||||
$r = Router::get();
|
||||
|
@ -143,6 +148,7 @@ class OembedAction extends Action
|
|||
// TRANS: %s is a path.
|
||||
$this->serverError(sprintf(_('"%s" not supported for oembed requests.'),$path), 501);
|
||||
}
|
||||
|
||||
switch ($this->trimmed('format')) {
|
||||
case 'xml':
|
||||
$this->init_document('xml');
|
||||
|
@ -172,11 +178,6 @@ class OembedAction extends Action
|
|||
// TRANS: Error message displaying attachments. %s is a raw MIME type (eg 'image/png')
|
||||
$this->serverError(sprintf(_('Content type %s not supported.'), $apidata['content-type']), 501);
|
||||
}
|
||||
} else {
|
||||
// TRANS: Error message displaying attachments. %s is the site's base URL.
|
||||
// FIXME: 404 not found?! (this will automatically become a 500 because it's not a serverError!)
|
||||
$this->serverError(sprintf(_('Only %s URLs over plain HTTP please.'), common_root_url()), 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function init_document($type)
|
||||
|
|
Loading…
Reference in New Issue
Block a user