forked from GNUsocial/gnu-social
LinkPreview: use a local proxy for oEmbed lookups so we use a consistent common code path, and don't open up to oohembed.com being evil
This commit is contained in:
parent
b5fc71253c
commit
73f28ffabe
@ -53,7 +53,7 @@ class LinkPreviewPlugin extends Plugin
|
|||||||
if ($user) {
|
if ($user) {
|
||||||
$action->script('plugins/LinkPreview/linkpreview.js');
|
$action->script('plugins/LinkPreview/linkpreview.js');
|
||||||
$data = json_encode(array(
|
$data = json_encode(array(
|
||||||
'api' => common_config('oohembed', 'endpoint'),
|
'api' => common_local_url('oembedproxy'),
|
||||||
'width' => common_config('attachments', 'thumbwidth'),
|
'width' => common_config('attachments', 'thumbwidth'),
|
||||||
'height' => common_config('attachments', 'thumbheight'),
|
'height' => common_config('attachments', 'thumbheight'),
|
||||||
));
|
));
|
||||||
@ -73,10 +73,11 @@ class LinkPreviewPlugin extends Plugin
|
|||||||
*/
|
*/
|
||||||
function onAutoload($cls)
|
function onAutoload($cls)
|
||||||
{
|
{
|
||||||
switch ($cls)
|
$lower = strtolower($cls);
|
||||||
|
switch ($lower)
|
||||||
{
|
{
|
||||||
case 'LinkpreviewAction':
|
case 'oembedproxyaction':
|
||||||
require_once dirname(__FILE__) . '/linkpreviewaction.php';
|
require_once dirname(__FILE__) . '/' . $lower . '.php';
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
@ -92,8 +93,8 @@ class LinkPreviewPlugin extends Plugin
|
|||||||
*/
|
*/
|
||||||
function onStartInitializeRouter($m)
|
function onStartInitializeRouter($m)
|
||||||
{
|
{
|
||||||
$m->connect('main/preview/link',
|
$m->connect('main/oembed/proxy',
|
||||||
array('action' => 'linkpreview'));
|
array('action' => 'oembedproxy'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,11 @@
|
|||||||
url: url,
|
url: url,
|
||||||
format: 'json',
|
format: 'json',
|
||||||
maxwidth: oEmbed.width,
|
maxwidth: oEmbed.width,
|
||||||
maxheight: oEmbed.height,
|
maxheight: oEmbed.height
|
||||||
callback: '?'
|
|
||||||
};
|
};
|
||||||
$.get(oEmbed.api, params, function(data, xhr) {
|
$.get(oEmbed.api, params, function(data, xhr) {
|
||||||
callback(data);
|
callback(data);
|
||||||
}, 'jsonp');
|
}, 'json');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user