From 8566f9130395ecdbe19f9fce85a26dac39d9fe24 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 21 Jul 2016 17:44:04 -0700 Subject: 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. --- include/oembed.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/oembed.php b/include/oembed.php index fe068278e..fe3a3c33c 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -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'; + } + } } -- cgit v1.2.3