fail oembed if it is attempted and less than 80% of the original content is left after html filtering. For the original poster, this will fall back to linkinfo results. If the embed gets through their site but is filtered downstream (with more than 20% of the content removed), it will result in just a link.
This commit is contained in:
parent
b63aff77df
commit
8566f91303
@ -215,6 +215,17 @@ function oembed_fetch_url($embedurl){
|
||||
if($j->html != $orig) {
|
||||
logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j->html, LOGGER_DEBUG, LOG_INFO);
|
||||
}
|
||||
|
||||
$orig_len = trim(mb_strlen($orig));
|
||||
$new_len = trim(mb_strlen($j->html));
|
||||
if(! $new_len)
|
||||
$j->type = 'error';
|
||||
elseif($orig_len) {
|
||||
$ratio = $new_len / $orig_len;
|
||||
if($ratio < 0.8)
|
||||
$j->type = 'error';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user