embed filter adjustments
This commit is contained in:
parent
45dc995967
commit
0637a71669
@ -1,8 +1,10 @@
|
|||||||
<?php /** @file */
|
<?php /** @file */
|
||||||
|
|
||||||
|
|
||||||
use Zotlabs\Lib as Zlib;
|
use Zotlabs\Lib as Zlib;
|
||||||
|
|
||||||
|
require_once('include/hubloc.php');
|
||||||
|
|
||||||
|
|
||||||
function oembed_replacecb($matches){
|
function oembed_replacecb($matches){
|
||||||
|
|
||||||
$embedurl=$matches[1];
|
$embedurl=$matches[1];
|
||||||
@ -130,6 +132,9 @@ function oembed_fetch_url($embedurl){
|
|||||||
|
|
||||||
$txt = null;
|
$txt = null;
|
||||||
|
|
||||||
|
// we should try to cache this and avoid a lookup on each render
|
||||||
|
$zrl = is_matrix_url($embedurl);
|
||||||
|
|
||||||
if($action !== 'block') {
|
if($action !== 'block') {
|
||||||
$txt = Zlib\Cache::get('[' . App::$videowidth . '] ' . $embedurl);
|
$txt = Zlib\Cache::get('[' . App::$videowidth . '] ' . $embedurl);
|
||||||
|
|
||||||
@ -142,15 +147,11 @@ function oembed_fetch_url($embedurl){
|
|||||||
|
|
||||||
$txt = "";
|
$txt = "";
|
||||||
$furl = $embedurl;
|
$furl = $embedurl;
|
||||||
$zrl = false;
|
|
||||||
|
|
||||||
if(local_channel()) {
|
logger('local_channel: ' . local_channel());
|
||||||
require_once('include/hubloc.php');
|
|
||||||
$zrl = is_matrix_url($furl);
|
if(local_channel() && $zrl)
|
||||||
if($zrl)
|
|
||||||
$furl = zid($furl);
|
$furl = zid($furl);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($action !== 'block') {
|
if ($action !== 'block') {
|
||||||
// try oembed autodiscovery
|
// try oembed autodiscovery
|
||||||
@ -216,14 +217,17 @@ function oembed_fetch_url($embedurl){
|
|||||||
logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j->html, LOGGER_DEBUG, LOG_INFO);
|
logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j->html, LOGGER_DEBUG, LOG_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
$orig_len = mb_strlen(trim($orig));
|
$orig_len = mb_strlen(preg_replace('/\s+/','',$orig));
|
||||||
$new_len = mb_strlen(trim($j->html));
|
$new_len = mb_strlen(preg_replace('/\s+/','',$j->html));
|
||||||
if(! $new_len)
|
|
||||||
|
if(stripos($orig,'<script') || (! $new_len))
|
||||||
$j->type = 'error';
|
$j->type = 'error';
|
||||||
elseif($orig_len) {
|
elseif($orig_len) {
|
||||||
$ratio = $new_len / $orig_len;
|
$ratio = $new_len / $orig_len;
|
||||||
if($ratio < 0.8)
|
if($ratio < 0.5) {
|
||||||
$j->type = 'error';
|
$j->type = 'error';
|
||||||
|
logger('oembed html truncated: ' . $ratio, LOGGER_DEBUG, LOG_INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -231,7 +235,7 @@ function oembed_fetch_url($embedurl){
|
|||||||
|
|
||||||
$j->embedurl = $embedurl;
|
$j->embedurl = $embedurl;
|
||||||
|
|
||||||
// logger('fetch return: ' . print_r($j,true));
|
// logger('fetch return: ' . print_r($j,true));
|
||||||
|
|
||||||
return $j;
|
return $j;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user