X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FBookmark%2Factions%2Fbookmarkforurl.php;h=f4393dd1931ab1948ad8f16f6a29ad5794f7fb82;hb=5c0a3102ff60472f60da76d69b0830dca726cca4;hp=8eb02e64a00a56f17a046345271e7111e6e62689;hpb=64df40e409812249748723b8acb0b48920ed786b;p=quix0rs-gnu-social.git diff --git a/plugins/Bookmark/actions/bookmarkforurl.php b/plugins/Bookmark/actions/bookmarkforurl.php index 8eb02e64a0..f4393dd193 100644 --- a/plugins/Bookmark/actions/bookmarkforurl.php +++ b/plugins/Bookmark/actions/bookmarkforurl.php @@ -59,7 +59,7 @@ class BookmarkforurlAction extends Action * * @return boolean true */ - function prepare($args) + function prepare(array $args = array()) { parent::prepare($args); @@ -74,21 +74,23 @@ 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); } - $f = File::getKV('url', $this->url); - - if (empty($url)) { - $f = File::processNew($this->url); + try { + // processNew will first try to fetch a locally stored File entry + $f = File::processNew($this->url); + } catch (ServerException $e) { + $f = null; } // How about now? - if (!empty($f)) { + if ($f instanceof File) { + // FIXME: Use some File metadata Event instead $this->oembed = File_oembed::getKV('file_id', $f->id); - if (!empty($this->oembed)) { + if ($this->oembed instanceof File_oembed) { $this->title = $this->oembed->title; } $this->thumbnail = File_thumbnail::getKV('file_id', $f->id);